# HG changeset patch # User Pierre-Yves David # Date 1513576257 -3600 # Node ID 87cb2635352b083a124b58e970fa0bb4d486801b # Parent 09db38b34cb91dab77c0a1d218a6a0b162c10c53 depthcache: use parents filter in depth cache diff -r 09db38b34cb9 -r 87cb2635352b hgext3rd/evolve/depthcache.py --- a/hgext3rd/evolve/depthcache.py Mon Dec 18 06:48:49 2017 +0100 +++ b/hgext3rd/evolve/depthcache.py Mon Dec 18 06:50:57 2017 +0100 @@ -5,7 +5,6 @@ from mercurial import ( localrepo, - node as nodemod, util, scmutil, ) @@ -14,10 +13,13 @@ error, exthelper, genericcaches, + utility, ) from mercurial.i18n import _ +filterparents = utility.filterparents + eh = exthelper.exthelper() def simpledepth(repo, rev): @@ -145,14 +147,15 @@ def _depth(self, changelog, rev): cl = changelog - p1, p2 = cl.parentrevs(rev) - if p1 == nodemod.nullrev: + ps = filterparents(cl.parentrevs(rev)) + if not ps: # root case return 1 - elif p2 == nodemod.nullrev: + elif len(ps) == 1: # linear commit case - return self.get(p1) + 1 + return self.get(ps[0]) + 1 # merge case, must find the amount of exclusive content + p1, p2 = ps depth_p1 = self.get(p1) depth_p2 = self.get(p2) # computing depth of a merge