diff mercurial/setdiscovery.py @ 35304:f77121b6bf1b

setdiscover: allow to ignore part of the local graph Currently, the push discovery first determines the full set of common nodes before looking into what changesets are outgoing. When pushing a specific subset, this can lead to pathological situations where we search for the status of thousand of local heads that are unrelated to the requested pushes. To fix this, we need to teach the discovery to ignores part of the graph. Most of the necessary pieces were already in place. This changeset just makes them available to higher level API and tests them. Change actually impacting pushes are coming in a later changeset.
author Boris Feld <boris.feld@octobus.net>
date Wed, 06 Dec 2017 22:44:51 +0100
parents 483d47753726
children 5cfdf6137af8
line wrap: on
line diff
--- a/mercurial/setdiscovery.py	Thu Dec 07 01:53:14 2017 +0100
+++ b/mercurial/setdiscovery.py	Wed Dec 06 22:44:51 2017 +0100
@@ -133,7 +133,8 @@
 def findcommonheads(ui, local, remote,
                     initialsamplesize=100,
                     fullsamplesize=200,
-                    abortwhenunrelated=True):
+                    abortwhenunrelated=True,
+                    ancestorsof=None):
     '''Return a tuple (common, anyincoming, remoteheads) used to identify
     missing nodes from or in remote.
     '''
@@ -141,7 +142,11 @@
 
     roundtrips = 0
     cl = local.changelog
-    dag = dagutil.revlogdag(cl)
+    localsubset = None
+    if ancestorsof is not None:
+        rev = local.changelog.rev
+        localsubset = [rev(n) for n in ancestorsof]
+    dag = dagutil.revlogdag(cl, localsubset=localsubset)
 
     # early exit if we know all the specified remote heads already
     ui.debug("query 1; heads\n")