diff --git a/rhodecode/apps/_base/__init__.py b/rhodecode/apps/_base/__init__.py --- a/rhodecode/apps/_base/__init__.py +++ b/rhodecode/apps/_base/__init__.py @@ -26,7 +26,6 @@ from pyramid.httpexceptions import HTTPF from rhodecode.lib import helpers as h from rhodecode.lib.utils2 import StrictAttributeDict, safe_int, datetime_to_time from rhodecode.lib.vcs.exceptions import RepositoryRequirementError -from rhodecode.lib.ext_json import json from rhodecode.model import repo from rhodecode.model import repo_group from rhodecode.model.db import User @@ -218,28 +217,35 @@ class BaseReferencesView(RepoAppView): return c def load_refs_context(self, ref_items, partials_template): - _data = [] _render = self.request.get_partial_renderer(partials_template) pre_load = ["author", "date", "message"] is_svn = h.is_svn(self.rhodecode_vcs_repo) + is_hg = h.is_hg(self.rhodecode_vcs_repo) + format_ref_id = get_format_ref_id(self.rhodecode_vcs_repo) + closed_refs = {} + if is_hg: + closed_refs = self.rhodecode_vcs_repo.branches_closed + + data = [] for ref_name, commit_id in ref_items: commit = self.rhodecode_vcs_repo.get_commit( commit_id=commit_id, pre_load=pre_load) + closed = ref_name in closed_refs # TODO: johbo: Unify generation of reference links use_commit_id = '/' in ref_name or is_svn files_url = h.url( 'files_home', - repo_name=c.repo_name, + repo_name=self.db_repo_name, f_path=ref_name if is_svn else '', revision=commit_id if use_commit_id else ref_name, at=ref_name) - _data.append({ - "name": _render('name', ref_name, files_url), + data.append({ + "name": _render('name', ref_name, files_url, closed), "name_raw": ref_name, "date": _render('date', commit.date), "date_raw": datetime_to_time(commit.date), @@ -250,8 +256,8 @@ class BaseReferencesView(RepoAppView): "compare": _render( 'compare', format_ref_id(ref_name, commit.raw_id)), }) - c.has_references = bool(_data) - c.data = json.dumps(_data) + + return data class RepoRoutePredicate(object): diff --git a/rhodecode/apps/repository/views/repo_bookmarks.py b/rhodecode/apps/repository/views/repo_bookmarks.py --- a/rhodecode/apps/repository/views/repo_bookmarks.py +++ b/rhodecode/apps/repository/views/repo_bookmarks.py @@ -23,8 +23,10 @@ from pyramid.httpexceptions import HTTPN from pyramid.view import view_config from rhodecode.apps._base import BaseReferencesView +from rhodecode.lib.ext_json import json +from rhodecode.lib import helpers as h from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator) -from rhodecode.lib import helpers as h + log = logging.getLogger(__name__) @@ -44,7 +46,9 @@ class RepoBookmarksView(BaseReferencesVi raise HTTPNotFound() ref_items = self.rhodecode_vcs_repo.bookmarks.items() - self.load_refs_context( + data = self.load_refs_context( ref_items=ref_items, partials_template='bookmarks/bookmarks_data.mako') + c.has_references = bool(data) + c.data = json.dumps(data) return self._get_template_context(c) diff --git a/rhodecode/apps/repository/views/repo_branches.py b/rhodecode/apps/repository/views/repo_branches.py --- a/rhodecode/apps/repository/views/repo_branches.py +++ b/rhodecode/apps/repository/views/repo_branches.py @@ -22,6 +22,7 @@ import logging from pyramid.view import view_config from rhodecode.apps._base import BaseReferencesView +from rhodecode.lib.ext_json import json from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator) @@ -38,14 +39,11 @@ class RepoBranchesView(BaseReferencesVie renderer='rhodecode:templates/branches/branches.mako') def branches(self): c = self.load_default_context() - c.closed_branches = self.rhodecode_vcs_repo.branches_closed - # NOTE(marcink): - # we need this trick because of PartialRenderer still uses the - # global 'c', we might not need this after full pylons migration - self._register_global_c(c) ref_items = self.rhodecode_vcs_repo.branches_all.items() - self.load_refs_context( + data = self.load_refs_context( ref_items=ref_items, partials_template='branches/branches_data.mako') + c.has_references = bool(data) + c.data = json.dumps(data) return self._get_template_context(c) diff --git a/rhodecode/apps/repository/views/repo_tags.py b/rhodecode/apps/repository/views/repo_tags.py --- a/rhodecode/apps/repository/views/repo_tags.py +++ b/rhodecode/apps/repository/views/repo_tags.py @@ -22,6 +22,7 @@ import logging from pyramid.view import view_config from rhodecode.apps._base import BaseReferencesView +from rhodecode.lib.ext_json import json from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator) log = logging.getLogger(__name__) @@ -39,7 +40,9 @@ class RepoTagsView(BaseReferencesView): c = self.load_default_context() ref_items = self.rhodecode_vcs_repo.tags.items() - self.load_refs_context( + data = self.load_refs_context( ref_items=ref_items, partials_template='tags/tags_data.mako') + c.has_references = bool(data) + c.data = json.dumps(data) return self._get_template_context(c) diff --git a/rhodecode/templates/bookmarks/bookmarks_data.mako b/rhodecode/templates/bookmarks/bookmarks_data.mako --- a/rhodecode/templates/bookmarks/bookmarks_data.mako +++ b/rhodecode/templates/bookmarks/bookmarks_data.mako @@ -9,7 +9,7 @@ -<%def name="name(name, files_url)"> +<%def name="name(name, files_url, closed)"> diff --git a/rhodecode/templates/branches/branches_data.mako b/rhodecode/templates/branches/branches_data.mako --- a/rhodecode/templates/branches/branches_data.mako +++ b/rhodecode/templates/branches/branches_data.mako @@ -8,10 +8,10 @@ -<%def name="name(name, files_url)"> +<%def name="name(name, files_url, closed)"> ${name} - %if name in c.closed_branches: + %if closed: [closed] %endif diff --git a/rhodecode/templates/tags/tags_data.mako b/rhodecode/templates/tags/tags_data.mako --- a/rhodecode/templates/tags/tags_data.mako +++ b/rhodecode/templates/tags/tags_data.mako @@ -8,7 +8,7 @@ -<%def name="name(name, files_url)"> +<%def name="name(name, files_url, closed)"> ${name}