Changeset - 5554aa9c2480
[Not reviewed]
beta
0 18 0
Marcin Kuzminski - 15 years ago 2011-02-13 00:29:31
marcin@python-works.com
another major code rafactor, reimplemented (almost from scratch)
the way caching works, Should be solid rock for now. Some code optymizations on scmModel.get() to make it don't load unneded things. Changed db cache to file that should also reduce memory size
18 files changed with 134 insertions and 150 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/admin/repos.py
Show inline comments
 
@@ -126,48 +126,49 @@ class ReposController(BaseController):
 
    def update(self, repo_name):
 
        """PUT /repos/repo_name: Update an existing item"""
 
        # Forms posted to this method should contain a hidden field:
 
        #    <input type="hidden" name="_method" value="PUT" />
 
        # Or using helpers:
 
        #    h.form(url('repo', repo_name=ID),
 
        #           method='put')
 
        # url('repo', repo_name=ID)
 
        repo_model = RepoModel()
 
        changed_name = repo_name
 
        _form = RepoForm(edit=True, old_data={'repo_name':repo_name})()
 

	
 
        try:
 
            form_result = _form.to_python(dict(request.POST))
 
            repo_model.update(repo_name, form_result)
 
            invalidate_cache('get_repo_cached_%s' % repo_name)
 
            h.flash(_('Repository %s updated successfully' % repo_name),
 
                    category='success')
 
            changed_name = form_result['repo_name']
 
            action_logger(self.rhodecode_user, 'admin_updated_repo',
 
                              changed_name, '', self.sa)
 

	
 
        except formencode.Invalid, errors:
 
            c.repo_info = repo_model.get_by_repo_name(repo_name)
 

	
 
            if c.repo_info.stats:
 
                last_rev = c.repo_info.stats.stat_on_revision
 
            else:
 
                last_rev = 0
 
            c.stats_revision = last_rev
 
            r = ScmModel().get(repo_name)
 
            c.repo_last_rev = r.revisions[-1] if r.revisions else 0
 

	
 
            if last_rev == 0:
 
                c.stats_percentage = 0
 
            else:
 
                c.stats_percentage = '%.2f' % ((float((last_rev)) /
 
                                                c.repo_last_rev) * 100)
 

	
 
            c.users_array = repo_model.get_users_js()
 
            c.users_groups_array = repo_model.get_users_groups_js()
 

	
 
            errors.value.update({'user':c.repo_info.user.username})
 
            return htmlfill.render(
 
                render('admin/repos/repo_edit.html'),
 
                defaults=errors.value,
 
                errors=errors.error_dict or {},
 
                prefix_error=False,
 
                encoding="UTF-8")
 
@@ -260,50 +261,51 @@ class ReposController(BaseController):
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def repo_cache(self, repo_name):
 
        """INVALIDATE existing repository cache
 
        
 
        :param repo_name:
 
        """
 

	
 
        try:
 
            ScmModel().mark_for_invalidation(repo_name)
 
        except Exception, e:
 
            h.flash(_('An error occurred during cache invalidation'),
 
                    category='error')
 
        return redirect(url('edit_repo', repo_name=repo_name))
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def show(self, repo_name, format='html'):
 
        """GET /repos/repo_name: Show a specific item"""
 
        # url('repo', repo_name=ID)
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def edit(self, repo_name, format='html'):
 
        """GET /repos/repo_name/edit: Form to edit an existing item"""
 
        # url('edit_repo', repo_name=ID)
 
        r = ScmModel().get(repo_name)[0]
 

	
 
        repo_model = RepoModel()
 
        r = ScmModel().get(repo_name)
 
        c.repo_info = repo_model.get_by_repo_name(repo_name)
 

	
 
        if c.repo_info is None:
 
            h.flash(_('%s repository is not mapped to db perhaps'
 
                      ' it was created or renamed from the filesystem'
 
                      ' please run the application again'
 
                      ' in order to rescan repositories') % repo_name,
 
                      category='error')
 

	
 
            return redirect(url('repos'))
 

	
 
        if c.repo_info.stats:
 
            last_rev = c.repo_info.stats.stat_on_revision
 
        else:
 
            last_rev = 0
 
        c.stats_revision = last_rev
 

	
 
        c.repo_last_rev = r.revisions[-1] if r.revisions else 0
 

	
 
        if last_rev == 0 or c.repo_last_rev == 0:
 
            c.stats_percentage = 0
 
        else:
 
            c.stats_percentage = '%.2f' % ((float((last_rev)) /
 
                                            c.repo_last_rev) * 100)
rhodecode/controllers/branches.py
Show inline comments
 
@@ -24,31 +24,30 @@
 
# along with this program; if not, write to the Free Software
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
# MA  02110-1301, USA.
 

	
 
import logging
 

	
 
from pylons import tmpl_context as c
 

	
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.utils import OrderedDict
 
from rhodecode.model.scm import ScmModel
 

	
 
log = logging.getLogger(__name__)
 

	
 
class BranchesController(BaseController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(BranchesController, self).__before__()
 

	
 
    def index(self):
 
        hg_model = ScmModel()
 
        c.repo_info = hg_model.get_repo(c.repo_name)
 
        c.repo_info, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 
        c.repo_branches = OrderedDict()
 
        for name, hash_ in c.repo_info.branches.items():
 
            c.repo_branches[name] = c.repo_info.get_changeset(hash_)
 

	
 
        return render('branches/branches.html')
rhodecode/controllers/changelog.py
Show inline comments
 
@@ -46,56 +46,56 @@ log = logging.getLogger(__name__)
 

	
 
class ChangelogController(BaseController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(ChangelogController, self).__before__()
 

	
 
    def index(self):
 
        limit = 100
 
        default = 20
 
        if request.params.get('size'):
 
            try:
 
                int_size = int(request.params.get('size'))
 
            except ValueError:
 
                int_size = default
 
            int_size = int_size if int_size <= limit else limit
 
            c.size = int_size
 
            session['changelog_size'] = c.size
 
            session.save()
 
        else:
 
            c.size = int(session.get('changelog_size', default))
 

	
 
        changesets = ScmModel().get_repo(c.repo_name)
 
        repo, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 

	
 
        p = int(request.params.get('page', 1))
 
        c.total_cs = len(changesets)
 
        c.pagination = Page(changesets, page=p, item_count=c.total_cs,
 
        c.total_cs = len(repo)
 
        c.pagination = Page(repo, page=p, item_count=c.total_cs,
 
                            items_per_page=c.size)
 

	
 
        self._graph(changesets, c.size, p)
 
        self._graph(repo, c.size, p)
 

	
 
        return render('changelog/changelog.html')
 

	
 

	
 
    def _graph(self, repo, size, p):
 
        revcount = size
 
        if not repo.revisions or repo.alias == 'git':
 
            c.jsdata = json.dumps([])
 
            return
 

	
 
        max_rev = repo.revisions[-1]
 

	
 
        offset = 1 if p == 1 else  ((p - 1) * revcount + 1)
 

	
 
        rev_start = repo.revisions[(-1 * offset)]
 

	
 
        revcount = min(max_rev, revcount)
 
        rev_end = max(0, rev_start - revcount)
 
        dag = graph_rev(repo._repo, rev_start, rev_end)
 

	
 
        c.dag = tree = list(colored(dag))
 
        data = []
 
        for (id, type, ctx, vtx, edges) in tree:
 
            if type != CHANGESET:
rhodecode/controllers/changeset.py
Show inline comments
 
@@ -34,64 +34,63 @@ from pylons.controllers.util import redi
 

	
 
import rhodecode.lib.helpers as h
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.utils import EmptyChangeset
 
from rhodecode.model.scm import ScmModel
 

	
 
from vcs.exceptions import RepositoryError, ChangesetError, \
 
ChangesetDoesNotExistError
 
from vcs.nodes import FileNode
 
from vcs.utils import diffs as differ
 
from vcs.utils.ordered_dict import OrderedDict
 

	
 
log = logging.getLogger(__name__)
 

	
 
class ChangesetController(BaseController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(ChangesetController, self).__before__()
 

	
 
    def index(self, revision):
 
        hg_model = ScmModel()
 

	
 
        def wrap_to_table(str):
 

	
 
            return '''<table class="code-difftable">
 
                        <tr class="line">
 
                        <td class="lineno new"></td>
 
                        <td class="code"><pre>%s</pre></td>
 
                        </tr>
 
                      </table>''' % str
 

	
 
        #get ranges of revisions if preset
 
        rev_range = revision.split('...')[:2]
 
        range_limit = 50
 
        try:
 
            repo = hg_model.get_repo(c.repo_name)
 
            repo, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 
            if len(rev_range) == 2:
 
                rev_start = rev_range[0]
 
                rev_end = rev_range[1]
 
                rev_ranges = repo.get_changesets_ranges(rev_start, rev_end,
 
                                                       range_limit)
 
            else:
 
                rev_ranges = [repo.get_changeset(revision)]
 

	
 
            c.cs_ranges = list(rev_ranges)
 

	
 
        except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
 
            log.error(traceback.format_exc())
 
            h.flash(str(e), category='warning')
 
            return redirect(url('home'))
 

	
 
        c.changes = OrderedDict()
 
        c.sum_added = 0
 
        c.sum_removed = 0
 

	
 

	
 
        for changeset in c.cs_ranges:
 
            c.changes[changeset.raw_id] = []
 
            try:
 
                changeset_parent = changeset.parents[0]
 
@@ -142,54 +141,53 @@ class ChangesetController(BaseController
 
                        diff = wrap_to_table(_('Changeset is to big and was cut'
 
                                            ' off, see raw changeset instead'))
 

	
 

	
 
                cs1 = filenode_old.last_changeset.raw_id
 
                cs2 = node.last_changeset.raw_id
 
                c.changes[changeset.raw_id].append(('changed', node, diff, cs1, cs2))
 

	
 
            #==================================================================
 
            # REMOVED FILES    
 
            #==================================================================
 
            for node in changeset.removed:
 
                c.changes[changeset.raw_id].append(('removed', node, None, None, None))
 

	
 
        if len(c.cs_ranges) == 1:
 
            c.changeset = c.cs_ranges[0]
 
            c.changes = c.changes[c.changeset.raw_id]
 

	
 
            return render('changeset/changeset.html')
 
        else:
 
            return render('changeset/changeset_range.html')
 

	
 
    def raw_changeset(self, revision):
 

	
 
        hg_model = ScmModel()
 
        method = request.GET.get('diff', 'show')
 
        try:
 
            r = hg_model.get_repo(c.repo_name)
 
            c.scm_type = r.alias
 
            c.changeset = r.get_changeset(revision)
 
            repo, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 
            c.scm_type = repo.alias
 
            c.changeset = repo.get_changeset(revision)
 
        except RepositoryError:
 
            log.error(traceback.format_exc())
 
            return redirect(url('home'))
 
        else:
 
            try:
 
                c.changeset_parent = c.changeset.parents[0]
 
            except IndexError:
 
                c.changeset_parent = None
 
            c.changes = []
 

	
 
            for node in c.changeset.added:
 
                filenode_old = FileNode(node.path, '')
 
                if filenode_old.is_binary or node.is_binary:
 
                    diff = _('binary file') + '\n'
 
                else:
 
                    f_udiff = differ.get_udiff(filenode_old, node)
 
                    diff = differ.DiffProcessor(f_udiff).raw_diff()
 

	
 
                cs1 = None
 
                cs2 = node.last_changeset.raw_id
 
                c.changes.append(('added', node, diff, cs1, cs2))
 

	
 
            for node in c.changeset.changed:
 
                filenode_old = c.changeset_parent.get_node(node.path)
rhodecode/controllers/feed.py
Show inline comments
 
@@ -7,84 +7,85 @@
 
    
 
    :created_on: Apr 23, 2010
 
    :author: marcink
 
    :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>    
 
    :license: GPLv3, see COPYING for more details.
 
"""
 
# This program is free software; you can redistribute it and/or
 
# modify it under the terms of the GNU General Public License
 
# as published by the Free Software Foundation; version 2
 
# of the License or (at your opinion) any later version of the license.
 
# 
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
# 
 
# You should have received a copy of the GNU General Public License
 
# along with this program; if not, write to the Free Software
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
# MA  02110-1301, USA.
 

	
 
import logging
 

	
 
from pylons import url, response
 
from pylons.i18n.translation import _
 

	
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController
 
from rhodecode.model.scm import ScmModel
 

	
 
from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
 

	
 
log = logging.getLogger(__name__)
 

	
 
class FeedController(BaseController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(FeedController, self).__before__()
 
        #common values for feeds
 
        self.description = 'Changes on %s repository'
 
        self.description = _('Changes on %s repository')
 
        self.title = "%s feed"
 
        self.language = 'en-us'
 
        self.ttl = "5"
 
        self.feed_nr = 10
 

	
 
    def atom(self, repo_name):
 
        """Produce an atom-1.0 feed via feedgenerator module"""
 
        feed = Atom1Feed(title=self.title % repo_name,
 
                         link=url('summary_home', repo_name=repo_name, qualified=True),
 
                         description=self.description % repo_name,
 
                         language=self.language,
 
                         ttl=self.ttl)
 

	
 
        changesets = ScmModel().get_repo(repo_name)
 
        repo, dbrepo = ScmModel().get(repo_name, retval='repo')
 

	
 
        for cs in changesets[:self.feed_nr]:
 
        for cs in repo[:self.feed_nr]:
 
            feed.add_item(title=cs.message,
 
                          link=url('changeset_home', repo_name=repo_name,
 
                                   revision=cs.raw_id, qualified=True),
 
                                   description=str(cs.date))
 

	
 
        response.content_type = feed.mime_type
 
        return feed.writeString('utf-8')
 

	
 

	
 
    def rss(self, repo_name):
 
        """Produce an rss2 feed via feedgenerator module"""
 
        feed = Rss201rev2Feed(title=self.title % repo_name,
 
                         link=url('summary_home', repo_name=repo_name, qualified=True),
 
                         description=self.description % repo_name,
 
                         language=self.language,
 
                         ttl=self.ttl)
 

	
 
        changesets = ScmModel().get_repo(repo_name)
 
        for cs in changesets[:self.feed_nr]:
 
        repo, dbrepo = ScmModel().get(repo_name, retval='repo')
 
        for cs in repo[:self.feed_nr]:
 
            feed.add_item(title=cs.message,
 
                          link=url('changeset_home', repo_name=repo_name,
 
                                   revision=cs.raw_id, qualified=True),
 
                          description=str(cs.date))
 

	
 
        response.content_type = feed.mime_type
 
        return feed.writeString('utf-8')
rhodecode/controllers/files.py
Show inline comments
 
@@ -36,50 +36,50 @@ from pylons.controllers.util import redi
 

	
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.utils import EmptyChangeset
 
from rhodecode.model.scm import ScmModel
 

	
 
from vcs.backends import ARCHIVE_SPECS
 
from vcs.exceptions import RepositoryError, ChangesetError, \
 
    ChangesetDoesNotExistError, EmptyRepositoryError, ImproperArchiveTypeError
 
from vcs.nodes import FileNode
 
from vcs.utils import diffs as differ
 

	
 
log = logging.getLogger(__name__)
 

	
 
class FilesController(BaseController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(FilesController, self).__before__()
 
        c.cut_off_limit = self.cut_off_limit
 

	
 
    def index(self, repo_name, revision, f_path):
 
        hg_model = ScmModel()
 
        c.repo = hg_model.get_repo(c.repo_name)
 
        c.repo, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 

	
 

	
 
        try:
 
            #reditect to given revision from form
 
            post_revision = request.POST.get('at_rev', None)
 
            if post_revision:
 
                post_revision = c.repo.get_changeset(post_revision).raw_id
 
                redirect(url('files_home', repo_name=c.repo_name,
 
                             revision=post_revision, f_path=f_path))
 

	
 
            c.branch = request.GET.get('branch', None)
 

	
 
            c.f_path = f_path
 

	
 
            c.changeset = c.repo.get_changeset(revision)
 
            cur_rev = c.changeset.revision
 

	
 
            #prev link
 
            try:
 
                prev_rev = c.repo.get_changeset(cur_rev).prev(c.branch).raw_id
 
                c.url_prev = url('files_home', repo_name=c.repo_name,
 
                             revision=prev_rev, f_path=f_path)
 
                if c.branch:
 
                    c.url_prev += '?branch=%s' % c.branch
 
            except ChangesetDoesNotExistError:
 
@@ -95,124 +95,120 @@ class FilesController(BaseController):
 
            except ChangesetDoesNotExistError:
 
                c.url_next = '#'
 

	
 
            #files
 
            try:
 
                c.files_list = c.changeset.get_node(f_path)
 
                c.file_history = self._get_history(c.repo, c.files_list, f_path)
 
            except RepositoryError, e:
 
                h.flash(str(e), category='warning')
 
                redirect(h.url('files_home', repo_name=repo_name, revision=revision))
 

	
 
        except EmptyRepositoryError, e:
 
            h.flash(_('There are no files yet'), category='warning')
 
            redirect(h.url('summary_home', repo_name=repo_name))
 

	
 
        except RepositoryError, e:
 
            h.flash(str(e), category='warning')
 
            redirect(h.url('files_home', repo_name=repo_name, revision='tip'))
 

	
 

	
 

	
 
        return render('files/files.html')
 

	
 
    def rawfile(self, repo_name, revision, f_path):
 
        hg_model = ScmModel()
 
        c.repo = hg_model.get_repo(c.repo_name)
 
        c.repo, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 
        file_node = c.repo.get_changeset(revision).get_node(f_path)
 
        response.content_type = file_node.mimetype
 
        response.content_disposition = 'attachment; filename=%s' \
 
                                                    % f_path.split('/')[-1]
 
        return file_node.content
 

	
 
    def raw(self, repo_name, revision, f_path):
 
        hg_model = ScmModel()
 
        c.repo = hg_model.get_repo(c.repo_name)
 
        c.repo, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 
        file_node = c.repo.get_changeset(revision).get_node(f_path)
 
        response.content_type = 'text/plain'
 

	
 
        return file_node.content
 

	
 
    def annotate(self, repo_name, revision, f_path):
 
        hg_model = ScmModel()
 
        c.repo = hg_model.get_repo(c.repo_name)
 
        c.repo, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 

	
 
        try:
 
            c.cs = c.repo.get_changeset(revision)
 
            c.file = c.cs.get_node(f_path)
 
        except RepositoryError, e:
 
            h.flash(str(e), category='warning')
 
            redirect(h.url('files_home', repo_name=repo_name, revision=revision))
 

	
 
        c.file_history = self._get_history(c.repo, c.file, f_path)
 

	
 
        c.f_path = f_path
 

	
 
        return render('files/files_annotate.html')
 

	
 
    def archivefile(self, repo_name, fname):
 

	
 
        fileformat = None
 
        revision = None
 
        ext = None
 

	
 
        for a_type, ext_data in ARCHIVE_SPECS.items():
 
            archive_spec = fname.split(ext_data[1])
 
            if len(archive_spec) == 2 and archive_spec[1] == '':
 
                fileformat = a_type or ext_data[1]
 
                revision = archive_spec[0]
 
                ext = ext_data[1]
 

	
 
        try:
 
            repo = ScmModel().get_repo(repo_name)
 
            repo, dbrepo = ScmModel().get(repo_name)
 

	
 
            if repo.dbrepo.enable_downloads is False:
 
            if dbrepo.enable_downloads is False:
 
                return _('downloads disabled')
 

	
 
            cs = repo.get_changeset(revision)
 
            content_type = ARCHIVE_SPECS[fileformat][0]
 
        except ChangesetDoesNotExistError:
 
            return _('Unknown revision %s') % revision
 
        except EmptyRepositoryError:
 
            return _('Empty repository')
 
        except (ImproperArchiveTypeError, KeyError):
 
            return _('Unknown archive type')
 

	
 
        response.content_type = content_type
 
        response.content_disposition = 'attachment; filename=%s-%s%s' \
 
            % (repo_name, revision, ext)
 

	
 
        return cs.get_chunked_archive(kind=fileformat)
 

	
 

	
 
    def diff(self, repo_name, f_path):
 
        hg_model = ScmModel()
 
        diff1 = request.GET.get('diff1')
 
        diff2 = request.GET.get('diff2')
 
        c.action = request.GET.get('diff')
 
        c.no_changes = diff1 == diff2
 
        c.f_path = f_path
 
        c.repo = hg_model.get_repo(c.repo_name)
 
        c.repo, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 

	
 
        try:
 
            if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
 
                c.changeset_1 = c.repo.get_changeset(diff1)
 
                node1 = c.changeset_1.get_node(f_path)
 
            else:
 
                c.changeset_1 = EmptyChangeset()
 
                node1 = FileNode('.', '', changeset=c.changeset_1)
 

	
 
            if diff2 not in ['', None, 'None', '0' * 12, '0' * 40]:
 
                c.changeset_2 = c.repo.get_changeset(diff2)
 
                node2 = c.changeset_2.get_node(f_path)
 
            else:
 
                c.changeset_2 = EmptyChangeset()
 
                node2 = FileNode('.', '', changeset=c.changeset_2)
 
        except RepositoryError:
 
            return redirect(url('files_home',
 
                                repo_name=c.repo_name, f_path=f_path))
 

	
 
        f_udiff = differ.get_udiff(node1, node2)
 
        diff = differ.DiffProcessor(f_udiff)
 

	
 
        if c.action == 'download':
 
            diff_name = '%s_vs_%s.diff' % (diff1, diff2)
rhodecode/controllers/shortlog.py
Show inline comments
 
@@ -26,31 +26,31 @@
 
# MA  02110-1301, USA.
 

	
 
import logging
 

	
 
from pylons import tmpl_context as c, request
 

	
 
from webhelpers.paginate import Page
 

	
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.model.scm import ScmModel
 

	
 
log = logging.getLogger(__name__)
 

	
 
class ShortlogController(BaseController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(ShortlogController, self).__before__()
 

	
 
    def index(self):
 
        p = int(request.params.get('page', 1))
 
        repo = ScmModel().get_repo(c.repo_name)
 
        repo, dbrepo = ScmModel().get(c.repo_name, 'repo')
 
        c.repo_changesets = Page(repo, page=p, items_per_page=20)
 
        c.shortlog_data = render('shortlog/shortlog_data.html')
 
        if request.params.get('partial'):
 
            return c.shortlog_data
 
        r = render('shortlog/shortlog.html')
 
        return r
rhodecode/controllers/summary.py
Show inline comments
 
@@ -43,128 +43,129 @@ from rhodecode.lib.base import BaseContr
 
from rhodecode.lib.utils import OrderedDict, EmptyChangeset
 

	
 
from rhodecode.lib.celerylib import run_task
 
from rhodecode.lib.celerylib.tasks import get_commits_stats
 

	
 
from webhelpers.paginate import Page
 

	
 
try:
 
    import json
 
except ImportError:
 
    #python 2.5 compatibility
 
    import simplejson as json
 
log = logging.getLogger(__name__)
 

	
 
class SummaryController(BaseController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(SummaryController, self).__before__()
 

	
 
    def index(self):
 
        scm_model = ScmModel()
 
        c.repo_info = scm_model.get_repo(c.repo_name)
 
        c.repo, dbrepo = scm_model.get(c.repo_name)
 
        c.dbrepo = dbrepo
 
        c.following = scm_model.is_following_repo(c.repo_name,
 
                                             c.rhodecode_user.user_id)
 
        def url_generator(**kw):
 
            return url('shortlog_home', repo_name=c.repo_name, **kw)
 

	
 
        c.repo_changesets = Page(c.repo_info, page=1, items_per_page=10,
 
        c.repo_changesets = Page(c.repo, page=1, items_per_page=10,
 
                                 url=url_generator)
 

	
 
        e = request.environ
 

	
 
        if self.rhodecode_user.username == 'default':
 
            #for default(anonymous) user we don't need to pass credentials
 
            username = ''
 
            password = ''
 
        else:
 
            username = str(c.rhodecode_user.username)
 
            password = '@'
 

	
 
        uri = u'%(protocol)s://%(user)s%(password)s%(host)s%(prefix)s/%(repo_name)s' % {
 
                                        'protocol': e.get('wsgi.url_scheme'),
 
                                        'user':username,
 
                                        'password':password,
 
                                        'host':e.get('HTTP_HOST'),
 
                                        'prefix':e.get('SCRIPT_NAME'),
 
                                        'repo_name':c.repo_name, }
 
        c.clone_repo_url = uri
 
        c.repo_tags = OrderedDict()
 
        for name, hash in c.repo_info.tags.items()[:10]:
 
        for name, hash in c.repo.tags.items()[:10]:
 
            try:
 
                c.repo_tags[name] = c.repo_info.get_changeset(hash)
 
                c.repo_tags[name] = c.repo.get_changeset(hash)
 
            except ChangesetError:
 
                c.repo_tags[name] = EmptyChangeset(hash)
 

	
 
        c.repo_branches = OrderedDict()
 
        for name, hash in c.repo_info.branches.items()[:10]:
 
        for name, hash in c.repo.branches.items()[:10]:
 
            try:
 
                c.repo_branches[name] = c.repo_info.get_changeset(hash)
 
                c.repo_branches[name] = c.repo.get_changeset(hash)
 
            except ChangesetError:
 
                c.repo_branches[name] = EmptyChangeset(hash)
 

	
 
        td = date.today() + timedelta(days=1)
 
        td_1m = td - timedelta(days=calendar.mdays[td.month])
 
        td_1y = td - timedelta(days=365)
 

	
 
        ts_min_m = mktime(td_1m.timetuple())
 
        ts_min_y = mktime(td_1y.timetuple())
 
        ts_max_y = mktime(td.timetuple())
 

	
 
        if c.repo_info.dbrepo.enable_statistics:
 
        if dbrepo.enable_statistics:
 
            c.no_data_msg = _('No data loaded yet')
 
            run_task(get_commits_stats, c.repo_info.name, ts_min_y, ts_max_y)
 
            run_task(get_commits_stats, c.repo.name, ts_min_y, ts_max_y)
 
        else:
 
            c.no_data_msg = _('Statistics update are disabled for this repository')
 
        c.ts_min = ts_min_m
 
        c.ts_max = ts_max_y
 

	
 
        stats = self.sa.query(Statistics)\
 
            .filter(Statistics.repository == c.repo_info.dbrepo)\
 
            .filter(Statistics.repository == dbrepo)\
 
            .scalar()
 

	
 

	
 
        if stats and stats.languages:
 
            c.no_data = False is c.repo_info.dbrepo.enable_statistics
 
            c.no_data = False is dbrepo.enable_statistics
 
            lang_stats = json.loads(stats.languages)
 
            c.commit_data = stats.commit_activity
 
            c.overview_data = stats.commit_activity_combined
 
            c.trending_languages = json.dumps(OrderedDict(
 
                                       sorted(lang_stats.items(), reverse=True,
 
                                            key=lambda k: k[1])[:10]
 
                                        )
 
                                    )
 
        else:
 
            c.commit_data = json.dumps({})
 
            c.overview_data = json.dumps([[ts_min_y, 0], [ts_max_y, 10] ])
 
            c.trending_languages = json.dumps({})
 
            c.no_data = True
 

	
 
        c.enable_downloads = c.repo_info.dbrepo.enable_downloads
 
        c.enable_downloads = dbrepo.enable_downloads
 
        if c.enable_downloads:
 
            c.download_options = self._get_download_links(c.repo_info)
 
            c.download_options = self._get_download_links(c.repo)
 

	
 
        return render('summary/summary.html')
 

	
 

	
 

	
 
    def _get_download_links(self, repo):
 

	
 
        download_l = []
 

	
 
        branches_group = ([], _("Branches"))
 
        tags_group = ([], _("Tags"))
 

	
 
        for name, chs in c.repository_branches.items():
 
            #chs = chs.split(':')[-1]
 
            branches_group[0].append((chs, name),)
 
        download_l.append(branches_group)
 

	
 
        for name, chs in c.repository_tags.items():
 
            #chs = chs.split(':')[-1]
 
            tags_group[0].append((chs, name),)
 
        download_l.append(tags_group)
 

	
 
        return download_l
rhodecode/controllers/tags.py
Show inline comments
 
@@ -23,31 +23,30 @@
 
# You should have received a copy of the GNU General Public License
 
# along with this program; if not, write to the Free Software
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
# MA  02110-1301, USA.
 
import logging
 

	
 
from pylons import tmpl_context as c
 

	
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.utils import OrderedDict
 
from rhodecode.model.scm import ScmModel
 

	
 
log = logging.getLogger(__name__)
 

	
 
class TagsController(BaseController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(TagsController, self).__before__()
 

	
 
    def index(self):
 
        hg_model = ScmModel()
 
        c.repo_info = hg_model.get_repo(c.repo_name)
 
        c.repo_info, dbrepo = ScmModel().get(c.repo_name, retval='repo')
 
        c.repo_tags = OrderedDict()
 
        for name, hash_ in c.repo_info.tags.items():
 
            c.repo_tags[name] = c.repo_info.get_changeset(hash_)
 

	
 
        return render('tags/tags.html')
rhodecode/lib/base.py
Show inline comments
 
@@ -7,48 +7,48 @@ from pylons.controllers import WSGIContr
 
from pylons.templating import render_mako as render
 
from rhodecode import __version__
 
from rhodecode.lib import auth
 
from rhodecode.lib.utils import get_repo_slug
 
from rhodecode.model import meta
 
from rhodecode.model.scm import ScmModel
 
from rhodecode import BACKENDS
 

	
 
class BaseController(WSGIController):
 

	
 
    def __before__(self):
 
        c.rhodecode_version = __version__
 
        c.rhodecode_name = config.get('rhodecode_title')
 
        c.ga_code = config.get('rhodecode_ga_code')
 
        c.repo_name = get_repo_slug(request)
 
        c.backends = BACKENDS.keys()
 
        self.cut_off_limit = int(config.get('cut_off_limit'))
 

	
 
        self.sa = meta.Session()
 
        scm_model = ScmModel(self.sa)
 
        c.cached_repo_list = scm_model.get_repos()
 
        #c.unread_journal = scm_model.get_unread_journal()
 

	
 
        if c.repo_name:
 
            cached_repo = scm_model.get(c.repo_name)
 
            if cached_repo:
 
                c.repository_tags = cached_repo.tags
 
                c.repository_branches = cached_repo.branches
 
                c.repository_followers = scm_model.get_followers(cached_repo.dbrepo.repo_id)
 
                c.repository_forks = scm_model.get_forks(cached_repo.dbrepo.repo_id)
 
            repo, dbrepo = scm_model.get(c.repo_name)
 
            if repo:
 
                c.repository_tags = repo.tags
 
                c.repository_branches = repo.branches
 
                c.repository_followers = scm_model.get_followers(dbrepo.repo_id)
 
                c.repository_forks = scm_model.get_forks(dbrepo.repo_id)
 
            else:
 
                c.repository_tags = {}
 
                c.repository_branches = {}
 
                c.repository_followers = 0
 
                c.repository_forks = 0
 

	
 

	
 
    def __call__(self, environ, start_response):
 
        """Invoke the Controller"""
 
        # WSGIController.__call__ dispatches to the Controller method
 
        # the request is routed to. This routing information is
 
        # available in environ['pylons.routes_dict']
 
        try:
 
            #putting this here makes sure that we update permissions every time
 
            self.rhodecode_user = c.rhodecode_user = auth.get_user(session)
 
            return WSGIController.__call__(self, environ, start_response)
 
        finally:
 
            meta.Session.remove()
rhodecode/lib/helpers.py
Show inline comments
 
@@ -462,54 +462,54 @@ def action_parser(user_log):
 
                        )
 

	
 
        if len(revs) > revs_limit:
 
            uniq_id = revs[0]
 
            html_tmpl = ('<span> %s '
 
            '<a class="show_more" id="_%s" href="#more">%s</a> '
 
            '%s</span>')
 
            cs_links += html_tmpl % (_('and'), uniq_id, _('%s more') \
 
                                        % (len(revs) - revs_limit),
 
                                        _('revisions'))
 

	
 
            html_tmpl = '<span id="%s" style="display:none"> %s </span>'
 
            cs_links += html_tmpl % (uniq_id, ', '.join([link_to(rev,
 
                url('changeset_home',
 
                repo_name=repo_name, revision=rev),
 
                title=message(rev), class_='tooltip')
 
                for rev in revs[revs_limit:revs_top_limit]]))
 
        if len(revs) > 1:
 
            cs_links += compare_view
 
        return cs_links
 

	
 
    def get_fork_name():
 
        from rhodecode.model.scm import ScmModel
 
        repo_name = action_params
 
        repo = ScmModel().get(repo_name)
 
        repo, dbrepo = ScmModel().get(repo_name)
 
        if repo is None:
 
            return repo_name
 
        return link_to(action_params, url('summary_home',
 
                                          repo_name=repo.name,),
 
                                          title=repo.dbrepo.description)
 
                                          title=dbrepo.description)
 

	
 
    map = {'user_deleted_repo':(_('User [deleted] repository'), None),
 
           'user_created_repo':(_('User [created] repository'), None),
 
           'user_forked_repo':(_('User [forked] repository as:'), get_fork_name),
 
           'user_updated_repo':(_('User [updated] repository'), None),
 
           'admin_deleted_repo':(_('Admin [delete] repository'), None),
 
           'admin_created_repo':(_('Admin [created] repository'), None),
 
           'admin_forked_repo':(_('Admin [forked] repository'), None),
 
           'admin_updated_repo':(_('Admin [updated] repository'), None),
 
           'push':(_('[Pushed]'), get_cs_links),
 
           'pull':(_('[Pulled]'), None),
 
           'started_following_repo':(_('User [started following] repository'), None),
 
           'stopped_following_repo':(_('User [stopped following] repository'), None),
 
            }
 

	
 
    action_str = map.get(action, action)
 
    action = action_str[0].replace('[', '<span class="journal_highlight">')\
 
                   .replace(']', '</span>')
 
    if action_str[1] is not None:
 
        action = action + " " + action_str[1]()
 

	
 
    return literal(action)
 

	
 
def action_parser_icon(user_log):
rhodecode/model/repo.py
Show inline comments
 
@@ -66,49 +66,49 @@ class RepoModel(BaseModel):
 

	
 

	
 
    def get_by_repo_name(self, repo_name, cache=False):
 
        repo = self.sa.query(Repository)\
 
            .filter(Repository.repo_name == repo_name)
 

	
 
        if cache:
 
            repo = repo.options(FromCache("sql_cache_short",
 
                                          "get_repo_%s" % repo_name))
 
        return repo.scalar()
 

	
 

	
 
    def get_full(self, repo_name, cache=False, invalidate=False):
 
        repo = self.sa.query(Repository)\
 
            .options(joinedload(Repository.fork))\
 
            .options(joinedload(Repository.user))\
 
            .options(joinedload(Repository.followers))\
 
            .options(joinedload(Repository.repo_to_perm))\
 
            .options(joinedload(Repository.users_group_to_perm))\
 
            .filter(Repository.repo_name == repo_name)\
 

	
 
        if cache:
 
            repo = repo.options(FromCache("sql_cache_long",
 
                                          "get_repo_full_%s" % repo_name))
 
        if invalidate:
 
        if invalidate and cache:
 
            repo.invalidate()
 

	
 
        return repo.scalar()
 

	
 

	
 
    def get_users_js(self):
 

	
 
        users = self.sa.query(User).filter(User.active == True).all()
 
        u_tmpl = '''{id:%s, fname:"%s", lname:"%s", nname:"%s"},'''
 
        users_array = '[%s]' % '\n'.join([u_tmpl % (u.user_id, u.name,
 
                                                    u.lastname, u.username)
 
                                        for u in users])
 
        return users_array
 

	
 

	
 
    def get_users_groups_js(self):
 
        users_groups = self.sa.query(UsersGroup)\
 
            .filter(UsersGroup.users_group_active == True).all()
 

	
 
        g_tmpl = '''{id:%s, grname:"%s",grmembers:"%s"},'''
 

	
 
        users_groups_array = '[%s]' % '\n'.join([g_tmpl % \
 
                                    (gr.users_group_id, gr.users_group_name,
 
                                     len(gr.members))
rhodecode/model/scm.py
Show inline comments
 
@@ -10,258 +10,247 @@
 
    :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>    
 
    :license: GPLv3, see COPYING for more details.
 
"""
 
# This program is free software; you can redistribute it and/or
 
# modify it under the terms of the GNU General Public License
 
# as published by the Free Software Foundation; version 2
 
# of the License or (at your opinion) any later version of the license.
 
# 
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
# 
 
# You should have received a copy of the GNU General Public License
 
# along with this program; if not, write to the Free Software
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
# MA  02110-1301, USA.
 
import os
 
import time
 
import traceback
 
import logging
 

	
 
from mercurial import ui
 

	
 
from sqlalchemy.orm import joinedload
 
from sqlalchemy.orm.session import make_transient
 
from sqlalchemy.exc import DatabaseError
 

	
 
from beaker.cache import cache_region, region_invalidate
 

	
 
from vcs import get_backend
 
from vcs.utils.helpers import get_scm
 
from vcs.exceptions import RepositoryError, VCSError
 
from vcs.utils.lazy import LazyProperty
 

	
 
from rhodecode import BACKENDS
 
from rhodecode.lib import helpers as h
 
from rhodecode.lib.auth import HasRepoPermissionAny
 
from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, action_logger
 
from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, \
 
    action_logger
 
from rhodecode.model import BaseModel
 
from rhodecode.model.user import UserModel
 
from rhodecode.model.repo import RepoModel
 
from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \
 
    UserFollowing, UserLog
 
from rhodecode.model.caching_query import FromCache
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class UserTemp(object):
 
    def __init__(self, user_id):
 
        self.user_id = user_id
 

	
 
    def __repr__(self):
 
        return "<%s('id:%s')>" % (self.__class__.__name__, self.user_id)
 

	
 
class RepoTemp(object):
 
    def __init__(self, repo_id):
 
        self.repo_id = repo_id
 

	
 
    def __repr__(self):
 
        return "<%s('id:%s')>" % (self.__class__.__name__, self.repo_id)
 

	
 
class ScmModel(BaseModel):
 
    """Generic Scm Model
 
    """
 

	
 
    @LazyProperty
 
    def repos_path(self):
 
        """Get's the repositories root path from database
 
        """
 

	
 
        q = self.sa.query(RhodeCodeUi).filter(RhodeCodeUi.ui_key == '/').one()
 

	
 
        return q.ui_value
 

	
 
    def repo_scan(self, repos_path, baseui):
 
    def repo_scan(self, repos_path=None):
 
        """Listing of repositories in given path. This path should not be a 
 
        repository itself. Return a dictionary of repository objects
 
        
 
        :param repos_path: path to directory containing repositories
 
        :param baseui: baseui instance to instantiate MercurialRepostitory with
 
        """
 

	
 
        log.info('scanning for repositories in %s', repos_path)
 

	
 
        if not isinstance(baseui, ui.ui):
 
            baseui = make_ui('db')
 
        if repos_path is None:
 
            repos_path = self.repos_path
 

	
 
        baseui = make_ui('db')
 
        repos_list = {}
 

	
 
        for name, path in get_filesystem_repos(repos_path, recursive=True):
 
            try:
 
                if repos_list.has_key(name):
 
                    raise RepositoryError('Duplicate repository name %s '
 
                                    'found in %s' % (name, path))
 
                else:
 

	
 
                    klass = get_backend(path[0])
 

	
 
                    if path[0] == 'hg' and path[0] in BACKENDS.keys():
 
                        repos_list[name] = klass(path[1], baseui=baseui)
 

	
 
                    if path[0] == 'git' and path[0] in BACKENDS.keys():
 
                        repos_list[name] = klass(path[1])
 
            except OSError:
 
                continue
 

	
 
        return repos_list
 

	
 
    def get_repos(self, all_repos=None):
 
        """Get all repos from db and for each repo create it's backend instance.
 
        and fill that backed with information from database
 
        
 
        :param all_repos: give specific repositories list, good for filtering
 
        """
 

	
 
        if all_repos is None:
 
            all_repos = self.sa.query(Repository)\
 
                .order_by(Repository.repo_name).all()
 

	
 
        #get the repositories that should be invalidated
 
        invalidation_list = [str(x.cache_key) for x in \
 
                             self.sa.query(CacheInvalidation.cache_key)\
 
                             .filter(CacheInvalidation.cache_active == False)\
 
                             .all()]
 

	
 
        for r in all_repos:
 

	
 
            repo = self.get(r.repo_name, invalidation_list)
 
            repo, dbrepo = self.get(r.repo_name, invalidation_list)
 

	
 
            if repo is not None:
 
                last_change = repo.last_change
 
                tip = h.get_changeset_safe(repo, 'tip')
 

	
 
                tmp_d = {}
 
                tmp_d['name'] = r.repo_name
 
                tmp_d['name_sort'] = tmp_d['name'].lower()
 
                tmp_d['description'] = repo.dbrepo.description
 
                tmp_d['description'] = dbrepo.description
 
                tmp_d['description_sort'] = tmp_d['description']
 
                tmp_d['last_change'] = last_change
 
                tmp_d['last_change_sort'] = time.mktime(last_change.timetuple())
 
                tmp_d['tip'] = tip.raw_id
 
                tmp_d['tip_sort'] = tip.revision
 
                tmp_d['rev'] = tip.revision
 
                tmp_d['contact'] = repo.dbrepo.user.full_contact
 
                tmp_d['contact'] = dbrepo.user.full_contact
 
                tmp_d['contact_sort'] = tmp_d['contact']
 
                tmp_d['owner_sort'] = tmp_d['contact']
 
                tmp_d['repo_archives'] = list(repo._get_archives())
 
                tmp_d['last_msg'] = tip.message
 
                tmp_d['repo'] = repo
 
                tmp_d['dbrepo'] = dbrepo
 
                yield tmp_d
 

	
 
    def get_repo(self, repo_name):
 
        return self.get(repo_name)
 

	
 
    def get(self, repo_name, invalidation_list=None):
 
        """Get's repository from given name, creates BackendInstance and
 
    def get(self, repo_name, invalidation_list=None, retval='all'):
 
        """Returns a tuple of Repository,DbRepository,
 
        Get's repository from given name, creates BackendInstance and
 
        propagates it's data from database with all additional information
 
        
 
        :param repo_name:
 
        :param invalidation_list: if a invalidation list is given the get
 
            method should not manually check if this repository needs 
 
            invalidation and just invalidate the repositories in list
 
            
 
        :param retval: string specifing what to return one of 'repo','dbrepo',
 
            'all'if repo or dbrepo is given it'll just lazy load chosen type
 
            and return None as the second
 
        """
 
        if not HasRepoPermissionAny('repository.read', 'repository.write',
 
                            'repository.admin')(repo_name, 'get repo check'):
 
            return
 

	
 
        #======================================================================
 
        # CACHE FUNCTION
 
        #======================================================================
 
        @cache_region('long_term')
 
        def _get_repo(repo_name):
 

	
 
            repo_path = os.path.join(self.repos_path, repo_name)
 

	
 
            try:
 
                alias = get_scm(repo_path)[0]
 
                log.debug('Creating instance of %s repository', alias)
 
                backend = get_backend(alias)
 
            except VCSError:
 
                log.error(traceback.format_exc())
 
                log.error('Perhaps this repository is in db and not in filesystem'
 
                          'run rescan repositories with "destroy old data "'
 
                          'option from admin panel')
 
                log.error('Perhaps this repository is in db and not in '
 
                          'filesystem run rescan repositories with '
 
                          '"destroy old data " option from admin panel')
 
                return
 

	
 
            if alias == 'hg':
 
                from pylons import app_globals as g
 
                repo = backend(repo_path, create=False, baseui=g.baseui)
 
                repo = backend(repo_path, create=False, baseui=make_ui('db'))
 
                #skip hidden web repository
 
                if repo._get_hidden():
 
                    return
 
            else:
 
                repo = backend(repo_path, create=False)
 

	
 
            dbrepo = self.sa.query(Repository)\
 
                .options(joinedload(Repository.fork))\
 
                .options(joinedload(Repository.user))\
 
                .filter(Repository.repo_name == repo_name)\
 
                .scalar()
 

	
 
            self.sa.expunge_all()
 
            log.debug('making transient %s', dbrepo)
 
            make_transient(dbrepo)
 

	
 
            for attr in ['user', 'forks', 'followers', 'group', 'repo_to_perm',
 
                         'users_group_to_perm', 'stats', 'logs']:
 
                attr = getattr(dbrepo, attr, False)
 
                if attr:
 
                    if isinstance(attr, list):
 
                        for a in attr:
 
                            log.debug('making transient %s', a)
 
                            make_transient(a)
 
                    else:
 
                        log.debug('making transient %s', attr)
 
                        make_transient(attr)
 

	
 
            repo.dbrepo = dbrepo
 
            return repo
 

	
 
        pre_invalidate = True
 
        dbinvalidate = False
 

	
 
        if invalidation_list is not None:
 
            pre_invalidate = repo_name in invalidation_list
 

	
 
        if pre_invalidate:
 
            #this returns object to invalidate
 
            invalidate = self._should_invalidate(repo_name)
 

	
 
            if invalidate:
 
                log.info('invalidating cache for repository %s', repo_name)
 
                region_invalidate(_get_repo, None, repo_name)
 
                #region_invalidate(_get_repo, None, repo_name)
 
                self._mark_invalidated(invalidate)
 
                dbinvalidate = True
 

	
 
        return _get_repo(repo_name)
 
        r, dbr = None, None
 
        if retval == 'repo' or 'all':
 
            r = _get_repo(repo_name)
 
        if retval == 'dbrepo' or 'all':
 
            dbr = RepoModel(self.sa).get_full(repo_name, cache=True,
 
                                          invalidate=dbinvalidate)
 

	
 

	
 
        return r, dbr
 

	
 

	
 

	
 
    def mark_for_invalidation(self, repo_name):
 
        """Puts cache invalidation task into db for 
 
        further global cache invalidation
 
        
 
        :param repo_name: this repo that should invalidation take place
 
        """
 

	
 
        log.debug('marking %s for invalidation', repo_name)
 
        cache = self.sa.query(CacheInvalidation)\
 
            .filter(CacheInvalidation.cache_key == repo_name).scalar()
 

	
 
        if cache:
 
            #mark this cache as inactive
 
            cache.cache_active = False
 
        else:
 
            log.debug('cache key not found in invalidation db -> creating one')
 
            cache = CacheInvalidation(repo_name)
 

	
 
        try:
 
            self.sa.add(cache)
 
            self.sa.commit()
 
@@ -349,48 +338,47 @@ class ScmModel(BaseModel):
 
            .filter(UserFollowing.user_id == user_id).scalar()
 

	
 
        return f is not None
 

	
 
    def get_followers(self, repo_id):
 
        return self.sa.query(UserFollowing)\
 
                .filter(UserFollowing.follows_repo_id == repo_id).count()
 

	
 
    def get_forks(self, repo_id):
 
        return self.sa.query(Repository)\
 
                .filter(Repository.fork_id == repo_id).count()
 

	
 

	
 
    def get_unread_journal(self):
 
        return self.sa.query(UserLog).count()
 

	
 

	
 
    def _should_invalidate(self, repo_name):
 
        """Looks up database for invalidation signals for this repo_name
 
        
 
        :param repo_name:
 
        """
 

	
 
        ret = self.sa.query(CacheInvalidation)\
 
            .options(FromCache('sql_cache_short',
 
                           'get_invalidation_%s' % repo_name))\
 
            .filter(CacheInvalidation.cache_key == repo_name)\
 
            .filter(CacheInvalidation.cache_active == False)\
 
            .scalar()
 

	
 
        return ret
 

	
 
    def _mark_invalidated(self, cache_key):
 
        """ Marks all occurences of cache to invaldation as already invalidated
 
        """ Marks all occurrences of cache to invalidation as already 
 
        invalidated
 
        
 
        :param cache_key:
 
        """
 

	
 
        if cache_key:
 
            log.debug('marking %s as already invalidated', cache_key)
 
        try:
 
            cache_key.cache_active = True
 
            self.sa.add(cache_key)
 
            self.sa.commit()
 
        except (DatabaseError,):
 
            log.error(traceback.format_exc())
 
            self.sa.rollback()
 

	
rhodecode/templates/admin/repos/repos.html
Show inline comments
 
@@ -17,68 +17,68 @@
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
        <ul class="links">
 
          <li>
 
            <span>${h.link_to(u'ADD NEW REPOSITORY',h.url('new_repo'))}</span>
 
          </li>          
 
        </ul>        
 
    </div>
 
    <!-- end box / title -->
 
    <div class="table">
 
        <table class="table_disp">
 
        <tr class="header">
 
	        <th class="left">${_('Name')}</th>
 
	        <th class="left">${_('Description')}</th>
 
	        <th class="left">${_('Last change')}</th>
 
	        <th class="left">${_('Tip')}</th>
 
	        <th class="left">${_('Contact')}</th>
 
            <th class="left">${_('action')}</th>
 
        </tr>
 
            %for cnt,repo in enumerate(c.repos_list):
 
            <tr class="parity${cnt%2}">
 
                 <td>
 
                 ## TYPE OF REPO
 
                 %if repo['repo'].dbrepo.repo_type =='hg':
 
                 %if repo['dbrepo'].repo_type =='hg':
 
                   <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="/images/icons/hgicon.png"/>
 
                 %elif repo['repo'].dbrepo.repo_type =='git':
 
                 %elif repo['dbrepo'].repo_type =='git':
 
                   <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="/images/icons/giticon.png"/>
 
                 %else:
 
                   
 
                 %endif
 
                 
 
                 ## PRIVATE/PUBLIC REPO                  
 
                 %if repo['repo'].dbrepo.private:
 
                 %if repo['dbrepo'].private:
 
                    <img alt="${_('private')}" src="/images/icons/lock.png"/>
 
                 %else:
 
                    <img alt="${_('public')}" src="/images/icons/lock_open.png"/>
 
                 %endif         
 
                ${h.link_to(repo['name'],h.url('edit_repo',repo_name=repo['name']))}
 
                
 
	            %if repo['repo'].dbrepo.fork:
 
	            	<a href="${h.url('summary_home',repo_name=repo['repo'].dbrepo.fork.repo_name)}">
 
	            %if repo['dbrepo'].fork:
 
	            	<a href="${h.url('summary_home',repo_name=repo['dbrepo'].fork.repo_name)}">
 
	            	<img class="icon" alt="${_('public')}"
 
	            	title="${_('Fork of')} ${repo['repo'].dbrepo.fork.repo_name}" 
 
	            	title="${_('Fork of')} ${repo['dbrepo'].fork.repo_name}" 
 
	            	src="/images/icons/arrow_divide.png"/></a>
 
	            %endif                
 
                </td>
 
				<td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
 
	            <td>${h.age(repo['last_change'])}</td>
 
	            <td>
 
	            	%if repo['rev']>=0:
 
	            	${h.link_to('r%s:%s' % (repo['rev'],h.short_id(repo['tip'])),
 
	                h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
 
	                class_="tooltip",
 
	                title=h.tooltip(repo['last_msg']))}
 
	            	%else:
 
	            		${_('No changesets yet')}
 
	            	%endif    
 
	            </td>
 
	            <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
 
                <td>
 
                  ${h.form(url('repo', repo_name=repo['name']),method='delete')}
 
                    ${h.submit('remove_%s' % repo['name'],'delete',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
 
                  ${h.end_form()}
 
                </td>
 
            </tr>
 
            %endfor
 
        </table>
rhodecode/templates/admin/users/user_edit_my_account.html
Show inline comments
 
@@ -98,66 +98,66 @@
 
        <input class="top-right-rounded-corner top-left-rounded-corner bottom-left-rounded-corner bottom-right-rounded-corner" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/>
 
        </h5>
 
         %if h.HasPermissionAny('hg.admin','hg.create.repository')():
 
         <ul class="links">
 
           <li>
 
             <span>${h.link_to(_('ADD REPOSITORY'),h.url('admin_settings_create_repository'))}</span>
 
           </li>          
 
         </ul>           
 
         %endif        
 
    </div>
 
    <!-- end box / title -->
 
    <div class="table">
 
	    <table>
 
	    <thead>
 
            <tr>
 
            <th class="left">${_('Name')}</th>
 
            <th class="left">${_('revision')}</th>
 
            <th colspan="2" class="left">${_('action')}</th>            
 
	    </thead>
 
	     <tbody>
 
	     %if c.user_repos:
 
		     %for repo in c.user_repos:
 
		        <tr>
 
		            <td>
 
                     %if repo['repo'].dbrepo.repo_type =='hg':
 
                     %if repo['dbrepo'].repo_type =='hg':
 
                       <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="/images/icons/hgicon.png"/>
 
                     %elif repo['repo'].dbrepo.repo_type =='git':
 
                     %elif repo['dbrepo'].repo_type =='git':
 
                       <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="/images/icons/giticon.png"/>
 
                     %else:
 
                       
 
                     %endif 		            
 
		             %if repo['repo'].dbrepo.private:
 
		             %if repo['dbrepo'].private:
 
		                <img class="icon" alt="${_('private')}" src="/images/icons/lock.png"/>
 
		             %else:
 
		                <img class="icon" alt="${_('public')}" src="/images/icons/lock_open.png"/>
 
		             %endif
 
		                                             
 
		            ${h.link_to(repo['repo'].name, h.url('summary_home',repo_name=repo['repo'].name),class_="repo_name")}
 
		            %if repo['repo'].dbrepo.fork:
 
		            	<a href="${h.url('summary_home',repo_name=repo['repo'].dbrepo.fork.repo_name)}">
 
		            %if repo['dbrepo'].fork:
 
		            	<a href="${h.url('summary_home',repo_name=repo['dbrepo'].fork.repo_name)}">
 
		            	<img class="icon" alt="${_('public')}"
 
		            	title="${_('Fork of')} ${repo['repo'].dbrepo.fork.repo_name}" 
 
		            	title="${_('Fork of')} ${repo['dbrepo'].fork.repo_name}" 
 
		            	src="/images/icons/arrow_divide.png"/></a>
 
		            %endif		            
 
		            </td> 
 
		            <td><span class="tooltip" title="${repo['repo'].last_change}">${("r%s:%s") % (h.get_changeset_safe(repo['repo'],'tip').revision,h.short_id(h.get_changeset_safe(repo['repo'],'tip').raw_id))}</span></td>
 
		            <td><a href="${h.url('repo_settings_home',repo_name=repo['repo'].name)}" title="${_('edit')}"><img class="icon" alt="${_('private')}" src="/images/icons/application_form_edit.png"/></a></td>
 
		            <td>
 
	                  ${h.form(url('repo_settings_delete', repo_name=repo['repo'].name),method='delete')}
 
	                    ${h.submit('remove_%s' % repo['repo'].name,'',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
 
	                  ${h.end_form()}	            
 
		            </td>
 
		        </tr>
 
		     %endfor
 
	     %else:
 
	     	${_('No repositories yet')} 
 
	     	%if h.HasPermissionAny('hg.admin','hg.create.repository')():
 
	     		${h.link_to(_('create one now'),h.url('admin_settings_create_repository'))}
 
	     	%endif
 
	     %endif
 
	     </tbody>
 
	     </table>
 
    </div>
 
    
 
</div>
 
    <script type="text/javascript">
rhodecode/templates/base/base.html
Show inline comments
 
@@ -121,52 +121,52 @@
 
<%def name="page_nav()">
 
	${self.menu()}
 
</%def>
 

	
 
<%def name="menu(current=None)">
 
		<% 
 
		def is_current(selected):
 
			if selected == current:
 
				return h.literal('class="current"')
 
		%>
 
		%if current not in ['home','admin']:           		
 
		   ##REGULAR MENU            
 
	        <ul id="quick">
 
				<!-- repo switcher -->
 
				<li>
 
					<a id="repo_switcher" title="${_('Switch repository')}" href="#">
 
                    <span class="icon">
 
                        <img src="/images/icons/database.png" alt="${_('Products')}" />
 
                    </span>
 
                    <span>&darr;</span>					
 
					</a>
 
					<ul class="repo_switcher">
 
                        %for repo in c.cached_repo_list:
 
                        
 
                          %if repo['repo'].dbrepo.private:
 
                             <li><img src="/images/icons/lock.png" alt="${_('Private repository')}" class="repo_switcher_type"/>${h.link_to(repo['repo'].name,h.url('summary_home',repo_name=repo['repo'].name),class_="%s" % repo['repo'].dbrepo.repo_type)}</li>
 
                          %if repo['dbrepo'].private:
 
                             <li><img src="/images/icons/lock.png" alt="${_('Private repository')}" class="repo_switcher_type"/>${h.link_to(repo['repo'].name,h.url('summary_home',repo_name=repo['repo'].name),class_="%s" % repo['dbrepo'].repo_type)}</li>
 
                          %else:
 
                             <li><img src="/images/icons/lock_open.png" alt="${_('Public repository')}" class="repo_switcher_type" />${h.link_to(repo['repo'].name,h.url('summary_home',repo_name=repo['repo'].name),class_="%s" % repo['repo'].dbrepo.repo_type)}</li>
 
                             <li><img src="/images/icons/lock_open.png" alt="${_('Public repository')}" class="repo_switcher_type" />${h.link_to(repo['repo'].name,h.url('summary_home',repo_name=repo['repo'].name),class_="%s" % repo['dbrepo'].repo_type)}</li>
 
                          %endif  
 
                        %endfor					
 
					</ul>			
 
				</li>
 
				
 
	            <li ${is_current('summary')}>
 
	               <a title="${_('Summary')}" href="${h.url('summary_home',repo_name=c.repo_name)}">
 
	               <span class="icon">
 
	                   <img src="/images/icons/clipboard_16.png" alt="${_('Summary')}" />
 
	               </span>
 
	               <span>${_('Summary')}</span>                 
 
	               </a>	            
 
	            </li>
 
                ##<li ${is_current('shortlog')}>
 
                ##   <a title="${_('Shortlog')}" href="${h.url('shortlog_home',repo_name=c.repo_name)}">
 
                ##   <span class="icon">
 
                ##       <img src="/images/icons/application_view_list.png" alt="${_('Shortlog')}" />
 
                ##   </span>
 
                ##   <span>${_('Shortlog')}</span>                 
 
                ##   </a>             
 
                ##</li>	            
 
                <li ${is_current('changelog')}>
 
                   <a title="${_('Changelog')}" href="${h.url('changelog_home',repo_name=c.repo_name)}">
 
                   <span class="icon">
rhodecode/templates/index.html
Show inline comments
 
@@ -39,70 +39,70 @@
 
		        </ul>  	        
 
		        %endif
 
		    %endif
 
	    </div>
 
	    <!-- end box / title -->
 
        <div class="table">
 
            <table>
 
            <thead>
 
	            <tr>
 
			        <th class="left">${get_sort(_('Name'))}</th>
 
			        <th class="left">${get_sort(_('Description'))}</th>
 
			        <th class="left">${get_sort(_('Last change'))}</th>
 
			        <th class="left">${get_sort(_('Tip'))}</th>
 
			        <th class="left">${get_sort(_('Owner'))}</th>
 
			        <th class="left">${_('RSS')}</th>
 
			        <th class="left">${_('Atom')}</th>
 
	            </tr>
 
            </thead>
 
            <tbody>
 
		    %for cnt,repo in enumerate(c.repos_list):
 
		        <tr class="parity${cnt%2}">
 
		            <td>
 
		            <div style="white-space: nowrap">
 
		             ## TYPE OF REPO
 
		             %if repo['repo'].dbrepo.repo_type =='hg':
 
		             %if repo['dbrepo'].repo_type =='hg':
 
		               <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="/images/icons/hgicon.png"/>
 
		             %elif repo['repo'].dbrepo.repo_type =='git':
 
		             %elif repo['dbrepo'].repo_type =='git':
 
		               <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="/images/icons/giticon.png"/>
 
		             %else:
 
		               
 
		             %endif 
 
		            
 
		             ##PRIVATE/PUBLIC
 
		             %if repo['repo'].dbrepo.private:
 
		             %if repo['dbrepo'].private:
 
		                <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="/images/icons/lock.png"/>
 
		             %else:
 
		                <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="/images/icons/lock_open.png"/>
 
		             %endif
 
		            
 
		            ##NAME   
 
		            ${h.link_to(repo['name'],
 
		                h.url('summary_home',repo_name=repo['name']),class_="repo_name")}
 
		            %if repo['repo'].dbrepo.fork:
 
		            	<a href="${h.url('summary_home',repo_name=repo['repo'].dbrepo.fork.repo_name)}">
 
		            %if repo['dbrepo'].fork:
 
		            	<a href="${h.url('summary_home',repo_name=repo['dbrepo'].fork.repo_name)}">
 
		            	<img class="icon" alt="${_('fork')}"
 
		            	title="${_('Fork of')} ${repo['repo'].dbrepo.fork.repo_name}" 
 
		            	title="${_('Fork of')} ${repo['dbrepo'].fork.repo_name}" 
 
		            	src="/images/icons/arrow_divide.png"/></a>
 
		            %endif
 
		            </div>
 
		            </td>
 
		            ##DESCRIPTION
 
		            <td><span class="tooltip" title="${h.tooltip(repo['description'])}">
 
		               ${h.truncate(repo['description'],60)}</span>
 
		            </td>
 
		            ##LAST CHANGE
 
		            <td>
 
		              <span class="tooltip" title="${repo['last_change']}">
 
		              ${h.age(repo['last_change'])}</span>
 
		            </td>
 
		            <td>
 
		            	%if repo['rev']>=0:
 
		            	${h.link_to('r%s:%s' % (repo['rev'],h.short_id(repo['tip'])),
 
		                h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
 
		                class_="tooltip",
 
		                title=h.tooltip(repo['last_msg']))}
 
		            	%else:
 
		            		${_('No changesets yet')}
 
		            	%endif    
 
		            </td>
 
		            <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
rhodecode/templates/summary/summary.html
Show inline comments
 
@@ -10,174 +10,174 @@
 
    ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
 
    &raquo;
 
    ${_('summary')}
 
</%def>
 

	
 
<%def name="page_nav()">
 
	${self.menu('summary')}    
 
</%def>
 

	
 
<%def name="main()">
 
<div class="box box-left">
 
    <!-- box / title -->
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
    </div>
 
    <!-- end box / title -->
 
	<div class="form">
 
	  <div class="fields">
 
		 
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Name')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
		         %if c.repo_info.dbrepo.repo_type =='hg':
 
		         %if c.dbrepo.repo_type =='hg':
 
		           <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="/images/icons/hgicon.png"/>
 
		         %endif
 
		         %if c.repo_info.dbrepo.repo_type =='git':
 
		         %if c.dbrepo.repo_type =='git':
 
		           <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="/images/icons/giticon.png"/>
 
		         %endif 
 
                                 			  
 
	             %if c.repo_info.dbrepo.private:
 
	             %if c.dbrepo.private:
 
	                <img style="margin-bottom:2px" class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="/images/icons/lock.png"/>
 
	             %else:
 
	                <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="/images/icons/lock_open.png"/>
 
	             %endif
 
			      <span style="font-size: 1.6em;font-weight: bold;vertical-align: baseline;">${c.repo_info.name}</span>
 
			      <span style="font-size: 1.6em;font-weight: bold;vertical-align: baseline;">${c.repo.name}</span>
 
			      %if c.rhodecode_user.username != 'default':
 
				      %if c.following:
 
	                  <span id="follow_toggle" class="following" title="${_('Stop following this repository')}"
 
	                        onclick="javascript:toggleFollowingRepo(this,${c.repo_info.dbrepo.repo_id},'${str(h.get_token())}')">
 
	                        onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')">
 
	                  </span>			      
 
				      %else:
 
				      <span id="follow_toggle" class="follow" title="${_('Start following this repository')}"
 
				            onclick="javascript:toggleFollowingRepo(this,${c.repo_info.dbrepo.repo_id},'${str(h.get_token())}')">
 
				            onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')">
 
				      </span>
 
				      %endif
 
				  %endif:
 
			      <br/>
 
		            %if c.repo_info.dbrepo.fork:
 
		            %if c.dbrepo.fork:
 
		            	<span style="margin-top:5px">
 
		            	<a href="${h.url('summary_home',repo_name=c.repo_info.dbrepo.fork.repo_name)}">
 
		            	<a href="${h.url('summary_home',repo_name=c.dbrepo.fork.repo_name)}">
 
		            	<img class="icon" alt="${_('public')}"
 
		            	title="${_('Fork of')} ${c.repo_info.dbrepo.fork.repo_name}" 
 
		            	title="${_('Fork of')} ${c.dbrepo.fork.repo_name}" 
 
		            	src="/images/icons/arrow_divide.png"/>
 
		            	${_('Fork of')} ${c.repo_info.dbrepo.fork.repo_name}
 
		            	${_('Fork of')} ${c.dbrepo.fork.repo_name}
 
		            	</a>
 
		            	</span>
 
		            %endif			      
 
			  </div>
 
			 </div>
 
			
 
			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Description')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			      ${c.repo_info.dbrepo.description}
 
			      ${c.dbrepo.description}
 
			  </div>
 
			 </div>
 
			
 
			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Contact')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			  	<div class="gravatar">
 
			  		<img alt="gravatar" src="${h.gravatar_url(c.repo_info.dbrepo.user.email)}"/>
 
			  		<img alt="gravatar" src="${h.gravatar_url(c.dbrepo.user.email)}"/>
 
			  	</div>
 
			  		${_('Username')}: ${c.repo_info.dbrepo.user.username}<br/>
 
			  		${_('Name')}: ${c.repo_info.dbrepo.user.name} ${c.repo_info.dbrepo.user.lastname}<br/>
 
			  		${_('Email')}: <a href="mailto:${c.repo_info.dbrepo.user.email}">${c.repo_info.dbrepo.user.email}</a>
 
			  		${_('Username')}: ${c.dbrepo.user.username}<br/>
 
			  		${_('Name')}: ${c.dbrepo.user.name} ${c.dbrepo.user.lastname}<br/>
 
			  		${_('Email')}: <a href="mailto:${c.dbrepo.user.email}">${c.dbrepo.user.email}</a>
 
			  </div>
 
			 </div>
 
			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Last change')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			      ${h.age(c.repo_info.last_change)} - ${c.repo_info.last_change} 
 
			      ${_('by')} ${h.get_changeset_safe(c.repo_info,'tip').author} 
 
			      ${h.age(c.repo.last_change)} - ${c.repo.last_change} 
 
			      ${_('by')} ${h.get_changeset_safe(c.repo,'tip').author} 
 
			      
 
			  </div>
 
			 </div>
 
			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Clone url')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			      <input type="text" id="clone_url" readonly="readonly" value="hg clone ${c.clone_repo_url}" size="70"/>
 
			  </div>
 
			 </div>
 
			 
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Trending source files')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			    <div id="lang_stats"></div> 			   
 
			  </div>
 
			 </div>
 
			 			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Download')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
		        %if len(c.repo_info.revisions) == 0:
 
		        %if len(c.repo.revisions) == 0:
 
		          ${_('There are no downloads yet')}
 
		        %elif c.enable_downloads is False:
 
		          ${_('Downloads are disabled for this repository')}
 
                    %if h.HasPermissionAll('hg.admin')('enable stats on from summary'):
 
                        [${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name))}]
 
                    %endif  		          
 
		        %else:
 
			        ${h.select('download_options',c.repo_info.get_changeset().raw_id,c.download_options)}
 
			        %for cnt,archive in enumerate(c.repo_info._get_archives()):
 
			        ${h.select('download_options',c.repo.get_changeset().raw_id,c.download_options)}
 
			        %for cnt,archive in enumerate(c.repo._get_archives()):
 
			             %if cnt >=1:
 
			             |
 
			             %endif
 
			             <span class="tooltip" title="${_('Download %s as %s') %('tip',archive['type'])}" 
 
			                  id="${archive['type']+'_link'}">${h.link_to(archive['type'],
 
			                h.url('files_archive_home',repo_name=c.repo_info.name,
 
			                h.url('files_archive_home',repo_name=c.repo.name,
 
			                fname='tip'+archive['extension']),class_="archive_icon")}</span>
 
			        %endfor
 
			    %endif
 
			  </div>
 
			 </div>
 
			 
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Feeds')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
	            ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.repo_info.name),class_='rss_icon')}
 
	            ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.repo_info.name),class_='atom_icon')}
 
	            ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.repo.name),class_='rss_icon')}
 
	            ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.repo.name),class_='atom_icon')}
 
			  </div>
 
			 </div>				 			 			 
 
	  </div>		 
 
	</div>
 
  	<script type="text/javascript">
 
	  	YUE.onDOMReady(function(e){
 
	  	    id = 'clone_url';
 
	  	    YUE.on(id,'click',function(e){
 
	  	        YUD.get('clone_url').select();
 
	  	    })
 
	  	})
 
  		var data = ${c.trending_languages|n};
 
  		var total = 0;
 
  		var no_data = true;
 
  		for (k in data){
 
  		    total += data[k];
 
  		    no_data = false;
 
  		} 
 
		var tbl = document.createElement('table');
 
		tbl.setAttribute('class','trending_language_tbl');
 
		var cnt =0;
 
  		for (k in data){
 
  			cnt+=1;
 
  			var hide = cnt>2;
 
@@ -229,51 +229,51 @@
 
  		    }
 
  		    
 
  		}
 
  		if(no_data){
 
  			var tr = document.createElement('tr');
 
  			var td1 = document.createElement('td');
 
  			td1.innerHTML = "${c.no_data_msg}";
 
  			tr.appendChild(td1);
 
  			tbl.appendChild(tr);
 
		}
 
  		YUD.get('lang_stats').appendChild(tbl);
 
  		YUE.on('code_stats_show_more','click',function(){
 
  			l = YUD.getElementsByClassName('stats_hidden')
 
  			for (e in l){
 
  			    YUD.setStyle(l[e],'display','');
 
  			};
 
  			YUD.setStyle(YUD.get('code_stats_show_more'),
 
  					'display','none');
 
  		})
 
  	
 
             
 
             YUE.on('download_options','change',function(e){
 
                 var new_cs = e.target.options[e.target.selectedIndex];
 
                 var tmpl_links = {}
 
                 %for cnt,archive in enumerate(c.repo_info._get_archives()):
 
                 %for cnt,archive in enumerate(c.repo._get_archives()):
 
                	 tmpl_links['${archive['type']}'] = '${h.link_to(archive['type'],
 
                        h.url('files_archive_home',repo_name=c.repo_info.name,
 
                        h.url('files_archive_home',repo_name=c.repo.name,
 
                        fname='__CS__'+archive['extension']),class_="archive_icon")}';
 
                 %endfor
 
                
 
                 
 
                 for(k in tmpl_links){
 
                	 var s = YUD.get(k+'_link')
 
                	 title_tmpl = "${_('Download %s as %s') % ('__CS_NAME__',archive['type'])}";
 
                	 s.title = title_tmpl.replace('__CS_NAME__',new_cs.text)
 
                	 s.innerHTML = tmpl_links[k].replace('__CS__',new_cs.value);
 
                 }
 
                 
 
             })
 
             	
 
  	</script>    				
 
</div>
 
        
 
<div class="box box-right"  style="min-height:455px">
 
    <!-- box / title -->
 
    <div class="title">
 
        <h5>${_('Commit activity by day / author')}</h5>
 
    </div>
 
    
 
    <div class="table">
 
         %if c.no_data:
0 comments (0 inline, 0 general)