[PATCH 3 of 3] discovery: improve "note: unsynced remote changes!" warning

Mads Kiilerich mads at kiilerich.com
Wed Feb 5 19:19:58 CST 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1391649578 -3600
#      Thu Feb 06 02:19:38 2014 +0100
# Node ID ea894a314d8fe9825f878a15256179f69661768c
# Parent  3ac5557f7c88e6a1771e8fa9d11e2166b125c9d5
discovery: improve "note: unsynced remote changes!" warning

This note (which actually is a warning) frequently caused confusion.
"unsynced" is not a well established user-facing concept in Mercurial and the
message was not very specific or helpful.

Instead, show a messages like:
  remote has heads on branch 'default' that not are known locally: 6c0482d977a3
and show it before aborting on "push creates new remote head". This will also
give more of a hint in the case where the branch has been closed remotely and
'hg heads' thus not would show any new heads after pulling.

A similar (but actually very different) message was addressed in 6b618aa08b6e.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -268,7 +268,6 @@ def checkheads(repo, remote, outgoing, r
     # If there are more heads after the push than before, a suitable
     # error message, depending on unsynced status, is displayed.
     error = None
-    unsynced = False
     allmissing = set(outgoing.missing)
     allfuturecommon = set(c.node() for c in repo.set('%ld', outgoing.common))
     allfuturecommon.update(allmissing)
@@ -312,8 +311,15 @@ def checkheads(repo, remote, outgoing, r
                         newhs.add(nh)
         else:
             newhs = candidate_newhs
-        if [h for h in unsyncedheads if h not in discardedheads]:
-            unsynced = True
+        unsynced = sorted(h for h in unsyncedheads if h not in discardedheads)
+        if unsynced:
+            heads = ' '.join(short(h) for h in unsynced)
+            if branch is None:
+                repo.ui.warn(_("remote has heads that not are known locally: "
+                               "%s\n") % heads)
+            else:
+                repo.ui.warn(_("remote has heads on branch '%s' that not "
+                               "are known locally: %s\n") % (branch, heads))
         if remoteheads is None:
             if len(newhs) > 1:
                 dhs = list(newhs)
@@ -350,7 +356,3 @@ def checkheads(repo, remote, outgoing, r
                 repo.ui.note((" %s\n") % short(h))
     if error:
         raise util.Abort(error, hint=hint)
-
-    # 6. Check for unsynced changes on involved branches.
-    if unsynced:
-        repo.ui.warn(_("note: unsynced remote changes!\n"))
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -223,7 +223,7 @@ push should succeed even though it has a
   $ hg push
   pushing to ssh://user@dummy/remote
   searching for changes
-  note: unsynced remote changes!
+  remote has heads on branch 'default' that not are known locally: 6c0482d977a3
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes


More information about the Mercurial-devel mailing list