[PATCH] New output message from hg pull clarifies when a new branch head is added

Kevin Berridge kevin.w.berridge at gmail.com
Thu Mar 10 22:04:09 CST 2011


# HG changeset patch
# User Kevin Berridge <kevin.w.berridge at gmail.com>
# Date 1299816116 18000
# Node ID 19343cb297bce756e817afda30af19937cde0030
# Parent  0ab0ceefddf217b23d1ea80d27f2dc0cd417e664
New output message from hg pull clarifies when a new branch head is added.

After a pull when a new named branch head is added but no head is added on the current branch, the "run 'hg merge'" message can be misleading.  This patch changes the message in that scenario to "(run 'hg update' to get a working copy, new branches added)"

diff -r 0ab0ceefddf2 -r 19343cb297bc mercurial/commands.py
--- a/mercurial/commands.py	Tue Mar 08 01:21:50 2011 +0100
+++ b/mercurial/commands.py	Thu Mar 10 23:01:56 2011 -0500
@@ -2891,7 +2891,11 @@
         else:
             ui.status(_("not updating, since new heads added\n"))
     if modheads > 1:
-        ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
+        if (len(repo.branchheads()) > 1):
+            ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
+        else:
+            ui.status(_("(run 'hg update' to get a working copy, new" +
+              " branches added)\n"))
     else:
         ui.status(_("(run 'hg update' to get a working copy)\n"))
 
diff -r 0ab0ceefddf2 -r 19343cb297bc tests/test-pull-branch2.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-pull-branch2.t	Thu Mar 10 23:01:56 2011 -0500
@@ -0,0 +1,30 @@
+  $ hg init t
+  $ cd t
+  $ echo 1 > foo
+  $ hg ci -Am1
+  adding foo
+
+  $ cd ..
+  $ hg clone ./t ./tt
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd ./tt
+  $ hg branch A
+  marked working directory as branch A
+  $ echo 2 > foo
+  $ hg ci -Am2
+
+  $ cd ../t
+  $ echo a2 > foo
+  $ hg ci -ma3
+
+Pull branch A:
+
+  $ hg pull ../tt
+  pulling from ../tt
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  (run 'hg update' to get a working copy, new branches added)


More information about the Mercurial-devel mailing list