[PATCH 3 of 8] hidden: add a function returning ancestors of revs within a domain

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun May 21 11:20:38 EDT 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1495372906 -7200
#      Sun May 21 15:21:46 2017 +0200
# Node ID bde4b1ab7b0111988a521c4c4c28b3963010eeff
# Parent  acd7e055dbcb5830de634f52971a39dc654d73e1
# EXP-Topic dynamicblocker
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r bde4b1ab7b01
hidden: add a function returning ancestors of revs within a domain

See documentation for details. This will be used to improve the hidden
computation algorithm. See new changesets for usage.

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -92,6 +92,29 @@ def _getstatichidden(repo):
                     heappush(heap, -parent)
     return hidden
 
+def _domainancestors(pfunc, revs, domain):
+    """return ancestors of 'revs' within 'domain'
+
+    - pfunc(r): a funtion returning parent of 'r',
+    - revs: iterable of revnum,
+    - domain: consistent set of revnum.
+
+    The domain must be consistent, no connected set are the ancestors of another
+    connected set.
+
+    (Ancestors are returned inclusively)
+    """
+    stack = list(revs)
+    ancs = set(stack)
+    while stack:
+        for p in pfunc(stack.pop()):
+            nbanc = len(ancs)
+            if p != nullrev and p in domain:
+                ancs.add(p)
+            if nbanc != len(ancs): # avoid double membership testing
+                stack.append(p)
+    return ancs
+
 cacheversion = 1
 cachefile = 'cache/hidden'
 


More information about the Mercurial-devel mailing list