Patchwork [1,of,3] setdiscovery: drop unused 'initial' argument for '_takequicksample'

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 7, 2015, 9:53 p.m.
Message ID <ed5aebd7f4915573c77e.1420667633@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/7358/
State Accepted
Commit 668f9a82273c526c96d24e49bdd37c0b43a58900
Headers show

Comments

Pierre-Yves David - Jan. 7, 2015, 9:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1420590743 28800
#      Tue Jan 06 16:32:23 2015 -0800
# Node ID ed5aebd7f4915573c77ee40a07d41520123d34a1
# Parent  1a9d7acf660777eb80dd1fdf80affd3fe622604b
setdiscovery: drop unused 'initial' argument for '_takequicksample'

There is a single call site, and it is always using 'initial=True'. So we just drop
the argument and the associated condition.
Matt Mackall - Jan. 7, 2015, 11:21 p.m.
On Wed, 2015-01-07 at 13:53 -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1420590743 28800
> #      Tue Jan 06 16:32:23 2015 -0800
> # Node ID ed5aebd7f4915573c77ee40a07d41520123d34a1
> # Parent  1a9d7acf660777eb80dd1fdf80affd3fe622604b
> setdiscovery: drop unused 'initial' argument for '_takequicksample'

Something in this set is sad, dropping for now:

searching for changes
** Unknown exception encountered with possibly-broken third-party extension dbsh
** which supports versions unknown of Mercurial.
** Please disable dbsh and try your action again.
** If that fixes the bug please report it to the extension author.
** Python 2.7.5+ (default, Sep 17 2013, 15:31:50) [GCC 4.8.1]
** Mercurial Distributed SCM (version 3.2.4+509-171653dc8906+20150102)
** Extensions loaded: strip, mq, purge, dbsh, extdiff, gpg, perf, color, histedit, evolve, patchbomb, pager, progress, rebase, record, share, shelve
Traceback (most recent call last):
  File "/home/mpm/bin/hg", line 43, in <module>
    mercurial.dispatch.run()
  File "/home/mpm/hg/mercurial/dispatch.py", line 28, in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/home/mpm/hg/mercurial/dispatch.py", line 71, in dispatch
    ret = _runcatch(req)
  File "/home/mpm/hg/mercurial/dispatch.py", line 140, in _runcatch
    return _dispatch(req)
  File "/home/mpm/hg/mercurial/dispatch.py", line 850, in _dispatch
    cmdpats, cmdoptions)
  File "/home/mpm/hg/mercurial/dispatch.py", line 611, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/home/mpm/hg/mercurial/extensions.py", line 196, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/home/mpm/hg/hgext/pager.py", line 158, in pagecmd
    return orig(ui, options, cmd, cmdfunc)
  File "/home/mpm/hg/mercurial/extensions.py", line 196, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/home/mpm/hg/hgext/color.py", line 490, in colorcmd
    return orig(ui_, opts, cmd, cmdfunc)
  File "/home/mpm/hg/mercurial/dispatch.py", line 941, in _runcommand
    return checkargs()
  File "/home/mpm/hg/mercurial/dispatch.py", line 912, in checkargs
    return cmdfunc()
  File "/home/mpm/hg/mercurial/dispatch.py", line 847, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/home/mpm/hg/mercurial/util.py", line 702, in check
    return func(*args, **kwargs)
  File "/home/mpm/hg/mercurial/extensions.py", line 151, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File "/home/mpm/hg/mercurial/util.py", line 702, in check
    return func(*args, **kwargs)
  File "/home/mpm/hg/hgext/mq.py", line 3483, in mqcommand
    return orig(ui, repo, *args, **kwargs)
  File "/home/mpm/hg/mercurial/util.py", line 702, in check
    return func(*args, **kwargs)
  File "/home/mpm/hg/mercurial/extensions.py", line 151, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File "/home/mpm/hg/mercurial/util.py", line 702, in check
    return func(*args, **kwargs)
  File "/home/mpm/src/evolve/hgext/evolve.py", line 596, in warnobserrors
    ret = orig(ui, repo, *args, **kwargs)
  File "/home/mpm/hg/mercurial/util.py", line 702, in check
    return func(*args, **kwargs)
  File "/home/mpm/hg/mercurial/commands.py", line 5091, in push
    bookmarks=opts.get('bookmark', ()))
  File "/home/mpm/hg/mercurial/extensions.py", line 196, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/home/mpm/src/evolve/hgext/evolve.py", line 619, in push
    return orig(repo, *args, **opts)
  File "/home/mpm/hg/mercurial/exchange.py", line 219, in push
    _pushdiscovery(pushop)
  File "/home/mpm/hg/mercurial/exchange.py", line 269, in _pushdiscovery
    step(pushop)
  File "/home/mpm/src/evolve/hgext/evolve.py", line 2348, in newdisco
    _pushdiscoveryobsmarkers(olddisco, pushop)
  File "/home/mpm/src/evolve/hgext/evolve.py", line 2313, in _pushdiscoveryobsmarkers
    common = findcommonobsmarkers(pushop.ui, unfi, pushop.remote, commonrevs)
  File "/home/mpm/src/evolve/hgext/evolve.py", line 2393, in findcommonobsmarkers
    sample = _takefullsample(dag, undecided, size=fullsamplesize)
  File "/home/mpm/hg/mercurial/setdiscovery.py", line 105, in _takefullsample
    sample.update(random.sample(list(nodes - sample - always), more))
  File "/usr/lib/python2.7/random.py", line 322, in sample
    raise ValueError("sample larger than population")
ValueError: sample larger than population
Pierre-Yves David - Jan. 7, 2015, 11:27 p.m.
On 01/07/2015 03:21 PM, Matt Mackall wrote:
> On Wed, 2015-01-07 at 13:53 -0800, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1420590743 28800
>> #      Tue Jan 06 16:32:23 2015 -0800
>> # Node ID ed5aebd7f4915573c77ee40a07d41520123d34a1
>> # Parent  1a9d7acf660777eb80dd1fdf80affd3fe622604b
>> setdiscovery: drop unused 'initial' argument for '_takequicksample'
>
> Something in this set is sad, dropping for now:

You need some new evolve changesets that I just pushed.

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -82,19 +82,15 @@  def _setupsample(dag, nodes, size):
         # This could be bad if there are very many heads, all unknown to the
         # server. We're counting on long request support here.
         return always, None, desiredlen
     return always, set(), desiredlen
 
-def _takequicksample(dag, nodes, size, initial):
+def _takequicksample(dag, nodes, size):
     always, sample, desiredlen = _setupsample(dag, nodes, size)
     if sample is None:
         return always
-    if initial:
-        fromset = None
-    else:
-        fromset = nodes
-    _updatesample(dag, fromset, sample, always, quicksamplesize=desiredlen)
+    _updatesample(dag, None, sample, always, quicksamplesize=desiredlen)
     sample.update(always)
     return sample
 
 def _takefullsample(dag, nodes, size):
     always, sample, desiredlen = _setupsample(dag, nodes, size)
@@ -205,12 +201,11 @@  def findcommonheads(ui, local, remote,
             sample = _takefullsample(dag, undecided, size=fullsamplesize)
             targetsize = fullsamplesize
         else:
             # use even cheaper initial sample
             ui.debug("taking quick initial sample\n")
-            sample = _takequicksample(dag, undecided, size=initialsamplesize,
-                                      initial=True)
+            sample = _takequicksample(dag, undecided, size=initialsamplesize)
             targetsize = initialsamplesize
         sample = _limitsample(sample, targetsize)
 
         roundtrips += 1
         ui.progress(_('searching'), roundtrips, unit=_('queries'))