Patchwork bookmarks: allow (re-)activating a bookmark on the current changeset

login
register
mail settings
Submitter Kevin Bullock
Date March 17, 2013, 2:43 a.m.
Message ID <16fc6c1a87d90297871f.1363488190@slower-than-infinity.lan>
Download mbox | patch
Permalink /patch/1133/
State Superseded
Headers show

Comments

Kevin Bullock - March 17, 2013, 2:43 a.m.
# HG changeset patch
# User Kevin Bullock <kbullock@ringworld.org>
# Date 1363487804 18000
# Node ID 16fc6c1a87d90297871fcc0b9451ea5e00290582
# Parent  b616c9b8001d8377c39bc6bc1fd595de56f263f2
bookmarks: allow (re-)activating a bookmark on the current changeset

Allow a bookmark that points to the current changeset to be made the
active bookmark without requiring --force. Previously, this would've
aborted with:

  abort: bookmark 'Z' already exists (use -f to force)

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -811,6 +811,9 @@  def bookmark(ui, repo, mark=None, rev=No
     def checkconflict(repo, mark, force=False, target=None):
         if mark in marks and not force:
             if target:
+                if marks[mark] == target and target == cur:
+                    # re-activating a bookmark
+                    return
                 anc = repo.changelog.ancestors([repo[target].rev()])
                 bmctx = repo[marks[mark]]
                 if bmctx.rev() in anc:
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -287,6 +287,11 @@  forward bookmark to descendant without -
   $ hg bookmark Z
   moving bookmark 'Z' forward from f7b1eb17ad24
 
+activate bookmark on working dir parent without --force
+
+  $ hg bookmark --inactive Z
+  $ hg bookmark Z
+
 list bookmarks
 
   $ hg bookmark