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

mail settings
Submitter Pierre-Yves David
Date Jan. 7, 2015, 9:53 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/7359/
State Accepted
Commit f828d8c0217fd3f5333d03a94771b90194218361
Headers show


Pierre-Yves David - Jan. 7, 2015, 9:53 p.m.
# HG changeset patch
# User Pierre-Yves David <>
# 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/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -196,17 +196,18 @@  def findcommonheads(ui, local, remote,
         if full or common.hasbases():
             if full:
                 ui.note(_("sampling from both directions\n"))
                 ui.debug("taking initial sample\n")
-            sample = _takefullsample(dag, undecided, size=fullsamplesize)
+            samplefunc = _takefullsample
             targetsize = fullsamplesize
             # 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"