discovery: minor fix to some conditionals
authorBoris Feld <boris.feld@octobus.net>
Fri, 04 Jan 2019 17:49:59 +0100
changeset 41110 71b0db4fa027
parent 41109 3e1960e23e6b
child 41111 3c85a62d7462
discovery: minor fix to some conditionals Since `size` is the upper limit of the sample, we should include it in the check. Otherwize the `more` variable will be zero and the sampling will be useless
mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py	Thu Dec 20 10:16:24 2018 +0100
+++ b/mercurial/setdiscovery.py	Fri Jan 04 17:49:59 2019 +0100
@@ -146,7 +146,7 @@
     _updatesample(revs, revsroots, sample, children.__getitem__)
     assert sample
     sample = _limitsample(sample, size)
-    if len(sample) < size:
+    if len(sample) <= size:
         more = size - len(sample)
         sample.update(random.sample(list(revs - sample), more))
     return sample
@@ -264,7 +264,7 @@
             ui.debug("taking quick initial sample\n")
             samplefunc = _takequicksample
             targetsize = initialsamplesize
-        if len(undecided) < targetsize:
+        if len(undecided) <= targetsize:
             sample = list(undecided)
         else:
             sample = samplefunc(local, ownheads, undecided, targetsize)