changeset 33918:10f1809ab98f

bookmarks: allow renaming active bookmark using '.'
author David Demelier <markand@malikania.fr>
date Mon, 21 Aug 2017 08:52:46 +0200
parents 078099304772
children f488223a87ab
files mercurial/commands.py tests/test-bookmarks.t
diffstat 2 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Aug 22 14:14:52 2017 -0400
+++ b/mercurial/commands.py	Mon Aug 21 08:52:46 2017 +0200
@@ -968,6 +968,7 @@
                     raise error.Abort(_("new bookmark name required"))
                 elif len(names) > 1:
                     raise error.Abort(_("only one new bookmark name allowed"))
+                rename = repo._bookmarks.expandname(rename)
                 bookmarks.rename(repo, tr, rename, names[0], force, inactive)
             elif names:
                 bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
--- a/tests/test-bookmarks.t	Tue Aug 22 14:14:52 2017 -0400
+++ 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
+  [255]
+  $ hg up -q Y
+  $ hg book -d rename-me
+
 list bookmarks
 
   $ hg bookmark