[PATCH STABLE] bookmarks: deactivate current bookmark if no name is given

Kevin Bullock kbullock+mercurial at ringworld.org
Mon Oct 8 12:26:09 CDT 2012


# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1349648370 -7200
# Branch stable
# Node ID 8c692056b69396351176816c673054d9c442bc33
# Parent  6647ac9b9044023b4947e890b07d6dfef30ea9b3
bookmarks: deactivate current bookmark if no name is given

f57f891eb88e added this help text to hg bookmark:

  If no NAME is given, the current active bookmark will be marked inactive.

But that was never actually the case.

Originally spotted by Idan Kamara <idankk86 at gmail.com>.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -846,6 +846,12 @@ def bookmark(ui, repo, mark=None, rev=No
             raise util.Abort(_("bookmark name required"))
         if len(marks) == 0:
             ui.status(_("no bookmarks set\n"))
+        if inactive:
+            if not repo._bookmarkcurrent:
+                ui.status(_("no active bookmark\n"))
+            else:
+                bookmarks.setcurrent(repo, None)
+            return
         else:
             for bmark, n in sorted(marks.iteritems()):
                 current = repo._bookmarkcurrent
diff --git a/tests/test-bookmarks-current.t b/tests/test-bookmarks-current.t
--- a/tests/test-bookmarks-current.t
+++ b/tests/test-bookmarks-current.t
@@ -115,6 +115,13 @@ deactivate current bookmark using -i
      Z                         0:719295282060
 
   $ hg up -q Y
+  $ hg bookmark -i
+  $ hg bookmarks
+     Y                         0:719295282060
+     Z                         0:719295282060
+  $ hg bookmark -i
+  no active bookmark
+  $ hg up -q Y
   $ hg bookmarks
    * Y                         0:719295282060
      Z                         0:719295282060


More information about the Mercurial-devel mailing list