mercurial/setdiscovery.py
changeset 23814 6a5877a73141
parent 23813 932f814bf016
child 23815 31e75a362d44
--- a/mercurial/setdiscovery.py	Wed Jan 07 17:28:51 2015 -0800
+++ b/mercurial/setdiscovery.py	Wed Jan 07 10:32:17 2015 -0800
@@ -45,7 +45,7 @@
 import random
 import util, dagutil
 
-def _updatesample(dag, nodes, sample, always, quicksamplesize=0):
+def _updatesample(dag, nodes, sample, quicksamplesize=0):
     """update an existing sample to match the expected size
 
     The sample is updated with nodes exponentially distant from each head of the
@@ -58,7 +58,6 @@
     :dag: a dag object from dagutil
     :nodes:  set of nodes we want to discover (if None, assume the whole dag)
     :sample: a sample to update
-    :always: set of notable nodes that will be part of the sample anyway
     :quicksamplesize: optional target size of the sample"""
     # if nodes is empty we scan the entire graph
     if nodes:
@@ -77,10 +76,9 @@
         if d > factor:
             factor *= 2
         if d == factor:
-            if curr not in always: # need this check for the early exit below
-                sample.add(curr)
-                if quicksamplesize and (len(sample) >= quicksamplesize):
-                    return
+            sample.add(curr)
+            if quicksamplesize and (len(sample) >= quicksamplesize):
+                return
         seen.add(curr)
         for p in dag.parents(curr):
             if not nodes or p in nodes:
@@ -100,18 +98,17 @@
     always, sample, desiredlen = _setupsample(dag, nodes, size)
     if sample is None:
         return always
-    _updatesample(dag, None, sample, always, quicksamplesize=desiredlen)
-    sample.update(always)
+    sample = always
+    _updatesample(dag, None, sample, quicksamplesize=size)
     return sample
 
 def _takefullsample(dag, nodes, size):
-    sample = always = dag.headsetofconnecteds(nodes)
+    sample = dag.headsetofconnecteds(nodes)
     # update from heads
-    _updatesample(dag, nodes, sample, always)
+    _updatesample(dag, nodes, sample)
     # update from roots
-    _updatesample(dag.inverse(), nodes, sample, always)
+    _updatesample(dag.inverse(), nodes, sample)
     assert sample
-    sample.update(always)
     sample = _limitsample(sample, size)
     if len(sample) < size:
         more = size - len(sample)