diff mercurial/debugcommands.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 d4b108fdf423
children c3e4f196b6e0
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Thu Dec 07 01:53:14 2017 +0100
+++ b/mercurial/debugcommands.py	Wed Dec 06 22:44:51 2017 +0100
@@ -734,6 +734,7 @@
     [('', 'old', None, _('use old-style discovery')),
     ('', 'nonheads', None,
      _('use old-style discovery with non-heads included')),
+    ('', 'rev', [], 'restrict discovery to this set of revs'),
     ] + cmdutil.remoteopts,
     _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
 def debugdiscovery(ui, repo, remoteurl="default", **opts):
@@ -747,11 +748,8 @@
     # make sure tests are repeatable
     random.seed(12323)
 
-    def doit(localheads, remoteheads, remote=remote):
+    def doit(pushedrevs, remoteheads, remote=remote):
         if opts.get('old'):
-            if localheads:
-                raise error.Abort('cannot use localheads with old style '
-                                 'discovery')
             if not util.safehasattr(remote, 'branches'):
                 # enable in-client legacy support
                 remote = localrepo.locallegacypeer(remote.local())
@@ -765,7 +763,12 @@
                 all = dag.ancestorset(dag.internalizeall(common))
                 common = dag.externalizeall(dag.headsetofconnecteds(all))
         else:
-            common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
+            nodes = None
+            if pushedrevs:
+                revs = scmutil.revrange(repo, pushedrevs)
+                nodes = [repo[r].node() for r in revs]
+            common, any, hds = setdiscovery.findcommonheads(ui, repo, remote,
+                                                            ancestorsof=nodes)
         common = set(common)
         rheads = set(hds)
         lheads = set(repo.heads())
@@ -794,7 +797,7 @@
     else:
         remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
                                                  opts.get('remote_head'))
-        localrevs = opts.get('local_head')
+        localrevs = opts.get('rev')
         doit(localrevs, remoterevs)
 
 @command('debugextensions', cmdutil.formatteropts, [], norepo=True)