[PATCH 2 of 3] setdiscovery: delay sample building calls to gather them in a single place

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Jan 7 15:53:54 CST 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1420651806 28800
#      Wed Jan 07 09:30:06 2015 -0800
# Node ID 44506b02be8e38d74bf1ad2fec4ff2f8421ea61a
# Parent  ed5aebd7f4915573c77ee40a07d41520123d34a1
setdiscovery: delay sample building calls to gather them in a single place

Some of the logic around sample building is duplicate in the sample builders,
it would clean up thing to extract it in the top function, but this requires
all codes to be in the same place.

This changeset mostly exists to make the next one more clear.

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -196,17 +196,18 @@ def findcommonheads(ui, local, remote,
         if full or common.hasbases():
             if full:
                 ui.note(_("sampling from both directions\n"))
             else:
                 ui.debug("taking initial sample\n")
-            sample = _takefullsample(dag, undecided, size=fullsamplesize)
+            samplefunc = _takefullsample
             targetsize = fullsamplesize
         else:
             # use even cheaper initial sample
             ui.debug("taking quick initial sample\n")
-            sample = _takequicksample(dag, undecided, size=initialsamplesize)
+            samplefunc = _takequicksample
             targetsize = initialsamplesize
+        sample = samplefunc(dag, undecided, targetsize)
         sample = _limitsample(sample, targetsize)
 
         roundtrips += 1
         ui.progress(_('searching'), roundtrips, unit=_('queries'))
         ui.debug("query %i; still undecided: %i, sample size is: %i\n"


More information about the Mercurial-devel mailing list