[PATCH] discovery: Fix error print mentioning a 'None' branch

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Mon Oct 17 04:38:22 CDT 2011


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1318844279 -7200
# Branch stable
# Node ID 1447cf424bdffec9605407c92fce58dee25ff4c0
# Parent  ebeac9c414562d0b3aaa8f353b4dcd20aac7cea8
discovery: Fix error print mentioning a 'None' branch

When talking to old server discovery use heads of the 'None' branch to refer to
topological heads. This use of None should never make it to the end user.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -159,11 +159,11 @@ def prepush(repo, remote, force, revs, n
             newhs = set(newmap[branch])
             oldhs = set(oldmap[branch])
             if len(newhs) > len(oldhs):
                 dhs = list(newhs - oldhs)
                 if error is None:
-                    if branch != 'default':
+                    if branch not in ('default', None):
                         error = _("push creates new remote head %s "
                                   "on branch '%s'!") % (short(dhs[0]), branch)
                     else:
                         error = _("push creates new remote head %s!"
                                   ) % short(dhs[0])
@@ -171,11 +171,12 @@ def prepush(repo, remote, force, revs, n
                         hint = _("you should pull and merge or "
                                  "use push -f to force")
                     else:
                         hint = _("did you forget to merge? "
                                  "use push -f to force")
-                repo.ui.note("new remote heads on branch '%s'\n" % branch)
+                if branch is not None: #if branch is None there len(branches) ==1
+                    repo.ui.note("new remote heads on branch '%s'\n" % branch)
                 for h in dhs:
                     repo.ui.note("new remote head %s\n" % short(h))
         if error:
             raise util.Abort(error, hint=hint)
 


More information about the Mercurial-devel mailing list