[PATCH 2 of 2] setdiscovery: factorize similar sampling code

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Jan 7 01:56:02 CST 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1420590652 28800
#      Tue Jan 06 16:30:52 2015 -0800
# Node ID 1a9d7acf660777eb80dd1fdf80affd3fe622604b
# Parent  0eb961b8ee3cf1c35d6314d05290baa220546394
setdiscovery: factorize similar sampling code

We are using full sampling of 'fullsamplesize' in both case. The only
difference is the debug message. So we factorise the sampling code and put the
message in an extra conditional.

This is going to help making changes around the sampling logic. Such changes are
needed to improve discovery performance on highly headed repository.

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -195,17 +195,15 @@ def findcommonheads(ui, local, remote,
             undecided.difference_update(missing)
 
         if not undecided:
             break
 
-        if full:
-            ui.note(_("sampling from both directions\n"))
-            sample = _takefullsample(dag, undecided, size=fullsamplesize)
-            targetsize = fullsamplesize
-        elif common.hasbases():
-            # use cheapish initial sample
-            ui.debug("taking initial sample\n")
+        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)
             targetsize = fullsamplesize
         else:
             # use even cheaper initial sample
             ui.debug("taking quick initial sample\n")


More information about the Mercurial-devel mailing list