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

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 20, 2014, 6:05 p.m.
Message ID <6e7ea082099e457b048f.1416506743@3.1.168.192.in-addr.arpa>
Download mbox | patch
Permalink /patch/6809/
State Deferred
Headers show

Comments

Gregory Szorc - Nov. 20, 2014, 6:05 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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)