Patchwork [1,of,2,re] discovery: improve "note: unsynced remote changes!" warning

login
register
mail settings
Submitter Mads Kiilerich
Date Feb. 7, 2014, 4:25 p.m.
Message ID <c024b6d06d945181f595.1391790308@mk-desktop>
Download mbox | patch
Permalink /patch/3510/
State Accepted
Commit 2bc520bd0ce0745dc2caa2bb88232c6ab8305a73
Headers show

Comments

Mads Kiilerich - Feb. 7, 2014, 4:25 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1391649578 -3600
#      Thu Feb 06 02:19:38 2014 +0100
# Node ID c024b6d06d945181f595888b6b731ce43bf03793
# Parent  9fe578297b5c3f63512cc003c6fcdca85fa66435
discovery: improve "note: unsynced remote changes!" warning

This message 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 message like:
  remote has heads on branch 'default' that are not known locally: 6c0482d977a3

This message will also (when relevant) be shown before aborting on "push
creates new remote head".

A similar (but actually very different) message was addressed in 6b618aa08b6e.
Martin Geisler - Feb. 8, 2014, 11:04 a.m.
Mads Kiilerich <mads@kiilerich.com> writes:

> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1391649578 -3600
> #      Thu Feb 06 02:19:38 2014 +0100
> # Node ID c024b6d06d945181f595888b6b731ce43bf03793
> # Parent  9fe578297b5c3f63512cc003c6fcdca85fa66435
> discovery: improve "note: unsynced remote changes!" warning
>
> This message 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 message like:
>   remote has heads on branch 'default' that are not known locally: 6c0482d977a3

Yay! I thought that "unsynced remote changes" meant something like that,
but I was never really sure :) So +1 for replacing that warning with a
very clear message.

Patch

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -268,7 +268,6 @@ 
     # 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 @@ 
                         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 are "
+                               "not known locally: %s\n") % heads)
+            else:
+                repo.ui.warn(_("remote has heads on branch '%s' that are "
+                               "not known locally: %s\n") % (branch, heads))
         if remoteheads is None:
             if len(newhs) > 1:
                 dhs = list(newhs)
@@ -350,7 +356,3 @@ 
                 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-push-warn.t b/tests/test-push-warn.t
--- a/tests/test-push-warn.t
+++ b/tests/test-push-warn.t
@@ -22,6 +22,7 @@ 
   $ hg push ../a
   pushing to ../a
   searching for changes
+  remote has heads on branch 'default' that are not known locally: 1c9246a22a0a
   abort: push creates new remote head 1e108cc5548c!
   (pull and merge or see "hg help push" for details about pushing new heads)
   [255]
@@ -35,6 +36,7 @@ 
   query 2; still undecided: 1, sample size is: 1
   2 total queries
   listing keys for "bookmarks"
+  remote has heads on branch 'default' that are not known locally: 1c9246a22a0a
   new remote heads on branch 'default':
    1e108cc5548c
   abort: push creates new remote head 1e108cc5548c!
@@ -405,6 +407,7 @@ 
   $ hg -R i push h
   pushing to h
   searching for changes
+  remote has heads on branch 'default' that are not known locally: ce4212fc8847
   abort: push creates new remote head 97bd0c84d346!
   (pull and merge or see "hg help push" for details about pushing new heads)
   [255]
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 @@ 
   $ hg push
   pushing to ssh://user@dummy/remote
   searching for changes
-  note: unsynced remote changes!
+  remote has heads on branch 'default' that are not known locally: 6c0482d977a3
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes