diff --git a/kallithea/lib/vcs/backends/hg/repository.py b/kallithea/lib/vcs/backends/hg/repository.py --- a/kallithea/lib/vcs/backends/hg/repository.py +++ b/kallithea/lib/vcs/backends/hg/repository.py @@ -121,34 +121,16 @@ class MercurialRepository(BaseRepository if self._empty: return {} - def _branchtags(localrepo): - """ - Patched version of mercurial branchtags to not return the closed - branches - - :param localrepo: locarepository instance - """ + bt = OrderedDict() + for bn, _heads, tip, isclosed in sorted(self._repo.branchmap().iterbranches()): + if isclosed: + if closed: + bt[safe_unicode(bn)] = hex(tip) + else: + if normal: + bt[safe_unicode(bn)] = hex(tip) - bt = {} - bt_closed = {} - for bn, heads in localrepo.branchmap().iteritems(): - tip = heads[-1] - if 'close' in localrepo.changelog.read(tip)[5]: - bt_closed[bn] = tip - else: - bt[bn] = tip - - if not normal: - return bt_closed - if closed: - bt.update(bt_closed) - return bt - - sortkey = lambda ctx: ctx[0] # sort by name - _branches = [(safe_unicode(n), hex(h),) for n, h in - _branchtags(self._repo).items()] - - return OrderedDict(sorted(_branches, key=sortkey, reverse=False)) + return bt @LazyProperty def tags(self):