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

Ryan McElroy rm at fb.com
Tue Sep 6 12:44:11 EDT 2016

# HG changeset patch
# User Ryan McElroy <rmcelroy at 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.

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,
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 = []

More information about the Mercurial-devel mailing list