[PATCH 1 of 6 V3] hidden: add a function returning ancestors of revs within a domain

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri May 26 14:34:45 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 95b7279b3b2ec46607dbc22ebe4e8a27381c5ace
# Parent  548478efc46c6147e9c2781cf70477b3461b440d
# EXP-Topic fast-compute-hidden
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 95b7279b3b2e
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,43 @@ 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 subset are the ancestors of
+    another connected subset. In other words, if the parents of a revision are
+    not in the domains, no other ancestors of that revision. For example, with
+    the following graph:
+
+        F
+        |
+        E
+        | D
+        | |
+        | C
+        |/
+        B
+        |
+        A
+
+    If C, D, E and F are in the domain but B is not, A cannot be ((A) is an
+    ancestors disconnected subset disconnected of (C+D)).
+
+    (Ancestors are returned inclusively)
+    """
+    stack = list(revs)
+    ancestors = set(stack)
+    while stack:
+        for p in pfunc(stack.pop()):
+            if p != nullrev and p in domain and p not in ancestors:
+                ancestors.add(p)
+                stack.append(p)
+    return ancestors
+
 cacheversion = 1
 cachefile = 'cache/hidden'
 


More information about the Mercurial-devel mailing list