##// END OF EJS Templates
display current heads of branches for git in changelog and shortlog
marcink -
r2198:9784a54a beta
parent child Browse files
Show More
@@ -66,26 +66,13 b' class GitChangeset(BaseChangeset):'
66 66
67 67 @LazyProperty
68 68 def branch(self):
69 # TODO: Cache as we walk (id <-> branch name mapping)
70 refs = self.repository._repo.get_refs()
71 heads = {}
72 for key, val in refs.items():
73 for ref_key in ['refs/heads/', 'refs/remotes/origin/']:
74 if key.startswith(ref_key):
75 n = key[len(ref_key):]
76 if n not in ['HEAD']:
77 heads[n] = val
69
70 heads = self.repository._heads(reverse=False)
78 71
79 for name, id in heads.iteritems():
80 walker = self.repository._repo.object_store.get_graph_walker([id])
81 while True:
82 id_ = walker.next()
83 if not id_:
84 break
85 if id_ == self.id:
86 return safe_unicode(name)
87 raise ChangesetError("This should not happen... Have you manually "
88 "change id of the changeset?")
72 ref = heads.get(self.raw_id)
73 if ref:
74 return safe_unicode(ref)
75
89 76
90 77 def _fix_path(self, path):
91 78 """
@@ -246,6 +246,19 b' class GitRepository(BaseRepository):'
246 246 if ref.startswith('refs/heads/') and not ref.endswith('/HEAD')]
247 247 return OrderedDict(sorted(_branches, key=sortkey, reverse=False))
248 248
249 def _heads(self, reverse=False):
250 refs = self._repo.get_refs()
251 heads = {}
252
253 for key, val in refs.items():
254 for ref_key in ['refs/heads/', 'refs/remotes/origin/']:
255 if key.startswith(ref_key):
256 n = key[len(ref_key):]
257 if n not in ['HEAD']:
258 heads[n] = val
259
260 return heads if reverse else dict((y,x) for x,y in heads.iteritems())
261
249 262 def _get_tags(self):
250 263 if not self.revisions:
251 264 return {}
@@ -91,7 +91,7 b''
91 91 %if len(cs.parents)>1:
92 92 <span class="merge">${_('merge')}</span>
93 93 %endif
94 %if h.is_hg(c.rhodecode_repo) and cs.branch:
94 %if cs.branch:
95 95 <span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}">
96 96 ${h.link_to(h.shorter(cs.branch),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
97 97 %endif
@@ -26,9 +26,7 b''
26 26 <td>
27 27 <span class="logtags">
28 28 <span class="branchtag">
29 %if h.is_hg(c.rhodecode_repo):
30 29 ${cs.branch}
31 %endif
32 30 </span>
33 31 </span>
34 32 </td>
General Comments 0
You need to be logged in to leave comments. Login now