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

Ryan McElroy rm at fb.com
Tue Sep 6 08:35:57 EDT 2016


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1473164309 25200
#      Tue Sep 06 05:18:29 2016 -0700
# Node ID d477c6241411af4dfc198fa779bcb7e3302efcc0
# 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/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 = []
@@ -94,7 +94,7 @@ class outgoing(object):
             included = set(csets)
             missingheads = heads
             commonheads = [n for n in discbases if n not in included]
-        elif not commonheads:
+        elif commonheads is None:
             commonheads = [nullid]
         self.commonheads = commonheads
         self.missingheads = missingheads


More information about the Mercurial-devel mailing list