1. mikespook
  2. RhodeCode

Commits

Marcin Kuzminski  committed 9784a54

display current heads of branches for git in changelog and shortlog

  • Participants
  • Parent commits b14d8bd
  • Branches beta

Comments (0)

Files changed (4)

File rhodecode/lib/vcs/backends/git/changeset.py

View file
 
     @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
 
-        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?")
+        heads = self.repository._heads(reverse=False)
+
+        ref = heads.get(self.raw_id)
+        if ref:
+            return safe_unicode(ref)
+
 
     def _fix_path(self, path):
         """

File rhodecode/lib/vcs/backends/git/repository.py

View file
             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 {}

File rhodecode/templates/changelog/changelog.html

View file
 									%if len(cs.parents)>1:
 									<span class="merge">${_('merge')}</span>
 									%endif
-									%if h.is_hg(c.rhodecode_repo) and cs.branch:
+									%if cs.branch:
 									<span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}">
 									   ${h.link_to(h.shorter(cs.branch),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
 									%endif

File rhodecode/templates/shortlog/shortlog_data.html

View file
 		<td>
 			<span class="logtags">
 				<span class="branchtag">
-                %if h.is_hg(c.rhodecode_repo):
                     ${cs.branch}
-                %endif
                 </span>
 			</span>
 		</td>