discovery: explicitly check for None in outgoing init
authorRyan McElroy <rmcelroy@fb.com>
Tue, 06 Sep 2016 09:43:25 -0700
changeset 29901 4d1e6f91f1c7
parent 29900 50f2966f86ca
child 29902 a77d48219edd
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.
mercurial/commands.py
mercurial/discovery.py
--- a/mercurial/commands.py	Fri Aug 26 12:48:20 2016 +0200
+++ b/mercurial/commands.py	Tue Sep 06 09:43:25 2016 -0700
@@ -1411,7 +1411,7 @@
             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,
--- a/mercurial/discovery.py	Fri Aug 26 12:48:20 2016 +0200
+++ b/mercurial/discovery.py	Tue Sep 06 09:43:25 2016 -0700
@@ -81,7 +81,7 @@
         # 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 = []