[PATCH 1 of 2] Hg pull doesn't suggest running hg merge when added heads are on different branches

Kevin Berridge kevin.w.berridge at gmail.com
Fri Mar 11 20:56:35 CST 2011


# HG changeset patch
# User Kevin Berridge <kevin.w.berridge at gmail.com>
# Date 1299894192 18000
# Node ID 91ce954ac34a868124f49570e72aca4b012ac43c
# Parent  1bb2a56a9d73b386378564381807fdf8df38ea3f
Hg pull doesn't suggest running hg merge when added heads are on different branches.

After a pull when a new head is added but no head is added on the current branch, the "run 'hg merge'" message can be misleading.  This patch doesn't output the merge message in that scenario.

diff -r 1bb2a56a9d73 -r 91ce954ac34a mercurial/commands.py
--- a/mercurial/commands.py	Thu Mar 10 13:43:47 2011 +0100
+++ b/mercurial/commands.py	Fri Mar 11 20:43:12 2011 -0500
@@ -2891,7 +2891,10 @@
         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 heads' to see heads)\n"))
     else:
         ui.status(_("(run 'hg update' to get a working copy)\n"))
 
diff -r 1bb2a56a9d73 -r 91ce954ac34a tests/test-pull-branch2.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-pull-branch2.t	Fri Mar 11 20:43:12 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 heads' to see heads)


More information about the Mercurial-devel mailing list