Changeset - 1cd9bdf1362d
[Not reviewed]
default
0 1 0
Mads Kiilerich - 11 years ago 2015-01-06 00:54:36
madski@unity3d.com
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.
1 file changed with 9 insertions and 27 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -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):
0 comments (0 inline, 0 general)