Mercurial > kallithea
changeset 4741:1cd9bdf1362d
hg: reimplement branch listings more efficiently
Gives a 10 x speedup - which is noticable on big slow repos where the old
implementation took several seconds.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 06 Jan 2015 00:54:36 +0100 |
parents | 7967d89fbe90 |
children | ded49765b47a |
files | kallithea/lib/vcs/backends/hg/repository.py |
diffstat | 1 files changed, 9 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/vcs/backends/hg/repository.py Tue Jan 06 00:54:36 2015 +0100 +++ b/kallithea/lib/vcs/backends/hg/repository.py Tue Jan 06 00:54:36 2015 +0100 @@ -121,34 +121,16 @@ 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):