Patchwork [01,of,10,V2] discovery: minor fix to a conditional

login
register
mail settings
Submitter Boris Feld
Date Jan. 4, 2019, 5:29 p.m.
Message ID <01a79b3269d4bfe49306.1546622962@localhost.localdomain>
Download mbox | patch
Permalink /patch/37454/
State Accepted
Headers show

Comments

Boris Feld - Jan. 4, 2019, 5:29 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1546620599 -3600
#      Fri Jan 04 17:49:59 2019 +0100
# Node ID 01a79b3269d4bfe49306b021de35637f7016fa45
# Parent  5c68b617ba2463eb6f1372a24b139a376c6bf6bd
# EXP-Topic discovery-refactor
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 01a79b3269d4
discovery: minor fix to a conditional

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

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -146,7 +146,7 @@  def _takefullsample(repo, headrevs, revs
     _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