##// 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 @LazyProperty
67 @LazyProperty
68 def branch(self):
68 def branch(self):
69 # TODO: Cache as we walk (id <-> branch name mapping)
69
70 refs = self.repository._repo.get_refs()
70 heads = self.repository._heads(reverse=False)
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
78
71
79 for name, id in heads.iteritems():
72 ref = heads.get(self.raw_id)
80 walker = self.repository._repo.object_store.get_graph_walker([id])
73 if ref:
81 while True:
74 return safe_unicode(ref)
82 id_ = walker.next()
75
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?")
89
76
90 def _fix_path(self, path):
77 def _fix_path(self, path):
91 """
78 """
@@ -246,6 +246,19 b' class GitRepository(BaseRepository):'
246 if ref.startswith('refs/heads/') and not ref.endswith('/HEAD')]
246 if ref.startswith('refs/heads/') and not ref.endswith('/HEAD')]
247 return OrderedDict(sorted(_branches, key=sortkey, reverse=False))
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 def _get_tags(self):
262 def _get_tags(self):
250 if not self.revisions:
263 if not self.revisions:
251 return {}
264 return {}
@@ -91,7 +91,7 b''
91 %if len(cs.parents)>1:
91 %if len(cs.parents)>1:
92 <span class="merge">${_('merge')}</span>
92 <span class="merge">${_('merge')}</span>
93 %endif
93 %endif
94 %if h.is_hg(c.rhodecode_repo) and cs.branch:
94 %if cs.branch:
95 <span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}">
95 <span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}">
96 ${h.link_to(h.shorter(cs.branch),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
96 ${h.link_to(h.shorter(cs.branch),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
97 %endif
97 %endif
@@ -26,9 +26,7 b''
26 <td>
26 <td>
27 <span class="logtags">
27 <span class="logtags">
28 <span class="branchtag">
28 <span class="branchtag">
29 %if h.is_hg(c.rhodecode_repo):
30 ${cs.branch}
29 ${cs.branch}
31 %endif
32 </span>
30 </span>
33 </span>
31 </span>
34 </td>
32 </td>
General Comments 0
You need to be logged in to leave comments. Login now