[PATCH 6 of 6] merge: add hints to use update in cases involving bookmarks

Kevin Bullock kbullock+mercurial at ringworld.org
Wed Dec 7 11:40:58 CST 2011


# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1323278602 21600
# Node ID fede3899ee6ebb337328dbc67f7b060f95d97afc
# Parent  6bab2e0693916ee9160f41dc9fe52b9d7304de54
merge: add hints to use update in cases involving bookmarks

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4026,9 +4026,21 @@
     if not node:
         node = opts.get('rev')
 
+    branch = repo[None].branch()
+    bheads = repo.branchheads(branch)
+    mark = repo._bookmarkcurrent
+    if mark:
+        marknode = repo._bookmarks[mark]
+        if marknode == repo.dirstate.p1():
+            if marknode not in bheads:
+                raise util.Abort(_("nothing to merge"),
+                                 hint=_("use 'hg update -B' to move active bookmark"))
+        elif len(bheads) == 1:
+            # 'current' bookmark moved, presumably on a pull
+            raise util.Abort(_("nothing to merge"),
+                             hint=(_("use 'hg update %s' to return to active bookmark") % mark))
+
     if not node:
-        branch = repo[None].branch()
-        bheads = repo.branchheads(branch)
         if len(bheads) > 2:
             raise util.Abort(_("branch '%s' has %d heads - "
                                "please merge with an explicit rev")
diff --git a/tests/test-merge-default.t b/tests/test-merge-default.t
--- a/tests/test-merge-default.t
+++ b/tests/test-merge-default.t
@@ -79,6 +79,28 @@
   (use 'hg update' instead)
   [255]
 
+  $ hg bookmark bm0
+  $ hg merge
+  abort: nothing to merge
+  (use 'hg update -B' to move active bookmark)
+  [255]
+  $ hg merge tip
+  abort: nothing to merge
+  (use 'hg update -B' to move active bookmark)
+  [255]
+
+  $ hg bookmark -f -r tip bm0
+  $ hg merge
+  abort: nothing to merge
+  (use 'hg update bm0' to return to active bookmark)
+  [255]
+  $ hg merge tip
+  abort: nothing to merge
+  (use 'hg update bm0' to return to active bookmark)
+  [255]
+
+  $ hg bookmark -d bm0
+
   $ hg up 3
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 


More information about the Mercurial-devel mailing list