Patchwork [2,of,2] setdiscovery: factorize similar sampling code

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 7, 2015, 7:56 a.m.
Message ID <1a9d7acf660777eb80dd.1420617362@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/7347/
State Accepted
Commit f82173a90c2c9d0d32216fe7243ec51fc6d44ff7
Headers show

Comments

Pierre-Yves David - Jan. 7, 2015, 7:56 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Matt Mackall - Jan. 7, 2015, 9:20 p.m.
On Tue, 2015-01-06 at 23:56 -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1420590652 28800
> #      Tue Jan 06 16:30:52 2015 -0800
> # Node ID 1a9d7acf660777eb80dd1fdf80affd3fe622604b
> # Parent  0eb961b8ee3cf1c35d6314d05290baa220546394
> setdiscovery: factorize similar sampling code

These are queued for default, thanks.

Patch

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")