# HG changeset patch # User Marcin Kuzminski # Date 1334691866 -7200 # Node ID 9784a54a0f5b8eb05afb8d9d89929d617702a43d # Parent b14d8bd961444bff68c73a8d2197f0440291ede9 display current heads of branches for git in changelog and shortlog diff -r b14d8bd96144 -r 9784a54a0f5b rhodecode/lib/vcs/backends/git/changeset.py --- a/rhodecode/lib/vcs/backends/git/changeset.py Tue Apr 17 21:41:46 2012 +0200 +++ b/rhodecode/lib/vcs/backends/git/changeset.py Tue Apr 17 21:44:26 2012 +0200 @@ -66,26 +66,13 @@ @LazyProperty def branch(self): - # TODO: Cache as we walk (id <-> branch name mapping) - refs = self.repository._repo.get_refs() - heads = {} - for key, val in refs.items(): - for ref_key in ['refs/heads/', 'refs/remotes/origin/']: - if key.startswith(ref_key): - n = key[len(ref_key):] - if n not in ['HEAD']: - heads[n] = val + + heads = self.repository._heads(reverse=False) - for name, id in heads.iteritems(): - walker = self.repository._repo.object_store.get_graph_walker([id]) - while True: - id_ = walker.next() - if not id_: - break - if id_ == self.id: - return safe_unicode(name) - raise ChangesetError("This should not happen... Have you manually " - "change id of the changeset?") + ref = heads.get(self.raw_id) + if ref: + return safe_unicode(ref) + def _fix_path(self, path): """ diff -r b14d8bd96144 -r 9784a54a0f5b rhodecode/lib/vcs/backends/git/repository.py --- a/rhodecode/lib/vcs/backends/git/repository.py Tue Apr 17 21:41:46 2012 +0200 +++ b/rhodecode/lib/vcs/backends/git/repository.py Tue Apr 17 21:44:26 2012 +0200 @@ -246,6 +246,19 @@ if ref.startswith('refs/heads/') and not ref.endswith('/HEAD')] return OrderedDict(sorted(_branches, key=sortkey, reverse=False)) + def _heads(self, reverse=False): + refs = self._repo.get_refs() + heads = {} + + for key, val in refs.items(): + for ref_key in ['refs/heads/', 'refs/remotes/origin/']: + if key.startswith(ref_key): + n = key[len(ref_key):] + if n not in ['HEAD']: + heads[n] = val + + return heads if reverse else dict((y,x) for x,y in heads.iteritems()) + def _get_tags(self): if not self.revisions: return {} diff -r b14d8bd96144 -r 9784a54a0f5b rhodecode/templates/changelog/changelog.html --- a/rhodecode/templates/changelog/changelog.html Tue Apr 17 21:41:46 2012 +0200 +++ b/rhodecode/templates/changelog/changelog.html Tue Apr 17 21:44:26 2012 +0200 @@ -91,7 +91,7 @@ %if len(cs.parents)>1: ${_('merge')} %endif - %if h.is_hg(c.rhodecode_repo) and cs.branch: + %if cs.branch: ${h.link_to(h.shorter(cs.branch),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))} %endif diff -r b14d8bd96144 -r 9784a54a0f5b rhodecode/templates/shortlog/shortlog_data.html --- a/rhodecode/templates/shortlog/shortlog_data.html Tue Apr 17 21:41:46 2012 +0200 +++ b/rhodecode/templates/shortlog/shortlog_data.html Tue Apr 17 21:44:26 2012 +0200 @@ -26,9 +26,7 @@ - %if h.is_hg(c.rhodecode_repo): ${cs.branch} - %endif