[PATCH] bookmarks: allow renaming active bookmark using '.'

David Demelier markand at malikania.fr
Mon Aug 21 07:06:50 UTC 2017


# HG changeset patch
# User David Demelier <markand at malikania.fr>
# Date 1503298366 -7200
#      Mon Aug 21 08:52:46 2017 +0200
# Node ID f6ee280ea6afef475c3d158c4c4964a05be6ef15
# Parent  1e71a27dee970ec9ef02c004f662b5a99182f69b
bookmarks: allow renaming active bookmark using '.'

diff -r 1e71a27dee97 -r f6ee280ea6af mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Sun Aug 13 00:17:13 2017 -0700
+++ b/mercurial/bookmarks.py	Mon Aug 21 08:52:46 2017 +0200
@@ -763,7 +763,11 @@
     """
     marks = repo._bookmarks
     mark = checkformat(repo, new)
-    if old not in marks:
+    if old == ".":
+        if not repo._activebookmark:
+            raise error.Abort(_("no active bookmark to rename"))
+        old = repo._activebookmark
+    elif old not in marks:
         raise error.Abort(_("bookmark '%s' does not exist") % old)
     changes = []
     for bm in marks.checkconflict(mark, force):
diff -r 1e71a27dee97 -r f6ee280ea6af tests/test-bookmarks.t
--- a/tests/test-bookmarks.t	Sun Aug 13 00:17:13 2017 -0700
+++ b/tests/test-bookmarks.t	Mon Aug 21 08:52:46 2017 +0200
@@ -191,6 +191,28 @@
 
   $ hg bookmark -f -m X Y
 
+rename bookmark using .
+
+  $ hg book rename-me
+  $ hg book -m . renamed
+  $ hg bookmark
+     X2                        1:925d80f479bb
+     Y                         2:db815d6d32e6
+     Z                         0:f7b1eb17ad24
+   * renamed                   2:db815d6d32e6
+  $ hg up -q Y
+  $ hg book -d renamed
+
+rename bookmark using . with no active bookmark
+
+  $ hg book rename-me
+  $ hg book -i rename-me
+  $ hg book -m . renamed
+  abort: no active bookmark to rename
+  [255]
+  $ hg up -q Y
+  $ hg book -d rename-me
+
 list bookmarks
 
   $ hg bookmark


More information about the Mercurial-devel mailing list