Patchwork [v2] discovery: explicitly check for None in outgoing init

login
register
mail settings
Submitter Ryan McElroy
Date Sept. 6, 2016, 4:44 p.m.
Message ID <ebfcdb4b4697ca730c3d.1473180251@devbig314.prn1.facebook.com>
Download mbox | patch
Permalink /patch/16566/
State Accepted
Headers show

Comments

Ryan McElroy - Sept. 6, 2016, 4:44 p.m.
# HG changeset patch
# User Ryan McElroy <rmcelroy@fb.com>
# Date 1473180205 25200
#      Tue Sep 06 09:43:25 2016 -0700
# Node ID ebfcdb4b4697ca730c3d7a7594abd048e666ebb7
# Parent  f148bfa40489269be2e48046734f81065129847a
discovery: explicitly check for None in outgoing init

f09d0004481c introduced default params for discovery.outgoing(), but it used a
falsy check instead of an explicit check for None. The result is that callers
that passed in an empty list would have that list overridden by the defaults,
which is not the expected behavior.

This was discovered by changes to the test-pushrebase.t test in Facebook's
repository of mercurial extensions.
Pierre-Yves David - Sept. 7, 2016, 9:53 a.m.
On 09/06/2016 06:44 PM, Ryan McElroy wrote:
> # HG changeset patch
> # User Ryan McElroy <rmcelroy@fb.com>
> # Date 1473180205 25200
> #      Tue Sep 06 09:43:25 2016 -0700
> # Node ID ebfcdb4b4697ca730c3d7a7594abd048e666ebb7
> # Parent  f148bfa40489269be2e48046734f81065129847a
> discovery: explicitly check for None in outgoing init

That one is pushed. Thanks for digging this out :-)

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1411,7 +1411,7 @@  def bundle(ui, repo, fname, dest=None, *
             raise error.Abort(_("--base is incompatible with specifying "
                                "a destination"))
         common = [repo.lookup(rev) for rev in base]
-        heads = revs and map(repo.lookup, revs) or revs
+        heads = revs and map(repo.lookup, revs) or None
         outgoing = discovery.outgoing(repo, common, heads)
         cg = changegroup.getchangegroup(repo, 'bundle', outgoing,
                                         bundlecaps=bundlecaps,
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -81,7 +81,7 @@  class outgoing(object):
         # at least one of them must not be set
         assert None in (commonheads, missingroots)
         cl = repo.changelog
-        if not missingheads:
+        if missingheads is None:
             missingheads = cl.heads()
         if missingroots:
             discbases = []