[PATCH 2 of 3 RFC] setdiscovery.findcommonheads: communicate wanted nodes

Gregory Szorc gregory.szorc at gmail.com
Thu Nov 20 12:05:43 CST 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1416504197 28800
#      Thu Nov 20 09:23:17 2014 -0800
# Node ID 6e7ea082099e457b048f268751d345392653e97e
# Parent  b2b2b245c345fa788b46f71022024e17086d4f45
setdiscovery.findcommonheads: communicate wanted nodes

findcommonheads() now takes an optional iterable of nodes that we desire
from the remote. A subsequent patch will use this.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -42,9 +42,10 @@ def findcommonincoming(repo, remote, hea
         if allknown:
             return (heads, False, heads)
 
     res = setdiscovery.findcommonheads(repo.ui, repo, remote,
-                                       abortwhenunrelated=not force)
+                                       abortwhenunrelated=not force,
+                                       wantednodes=heads)
     common, anyinc, srvheads = res
     return (list(common), anyinc, heads or list(srvheads))
 
 class outgoing(object):
diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -120,11 +120,15 @@ def _limitsample(sample, desiredlen):
 
 def findcommonheads(ui, local, remote,
                     initialsamplesize=100,
                     fullsamplesize=200,
-                    abortwhenunrelated=True):
+                    abortwhenunrelated=True,
+                    wantednodes=None):
     '''Return a tuple (common, anyincoming, remoteheads) used to identify
     missing nodes from or in remote.
+
+    "wantednodes" is an optional iterable of nodes that we want from the
+    remote. It is used as a hint to possibly enable more efficient discovery.
     '''
     roundtrips = 0
     cl = local.changelog
     dag = dagutil.revlogdag(cl)


More information about the Mercurial-devel mailing list