Patchwork [v2] bookmarks: allow renaming active bookmark using '.'

login
register
mail settings
Submitter David Demelier
Date Aug. 24, 2017, 7:07 a.m.
Message ID <546e72c2f4134145b4a9.1503558473@fedy>
Download mbox | patch
Permalink /patch/23291/
State Accepted
Headers show

Comments

David Demelier - Aug. 24, 2017, 7:07 a.m.
# HG changeset patch
# User David Demelier <markand@malikania.fr>
# Date 1503298366 -7200
#      Mon Aug 21 08:52:46 2017 +0200
# Node ID 546e72c2f4134145b4a91d6e03c1b0ff70b2bd9a
# Parent  4e8a46c25facaebca476634d52dd78431d3143e8
bookmarks: allow renaming active bookmark using '.'
Yuya Nishihara - Aug. 24, 2017, 12:36 p.m.
On Thu, 24 Aug 2017 09:07:53 +0200, David Demelier wrote:
> # HG changeset patch
> # User David Demelier <markand@malikania.fr>
> # Date 1503298366 -7200
> #      Mon Aug 21 08:52:46 2017 +0200
> # Node ID 546e72c2f4134145b4a91d6e03c1b0ff70b2bd9a
> # Parent  4e8a46c25facaebca476634d52dd78431d3143e8
> bookmarks: allow renaming active bookmark using '.'

Queued, thanks.

Patch

diff -r 4e8a46c25fac -r 546e72c2f413 mercurial/commands.py
--- a/mercurial/commands.py	Tue Aug 22 11:00:00 2017 +0200
+++ 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)
diff -r 4e8a46c25fac -r 546e72c2f413 tests/test-bookmarks.t
--- a/tests/test-bookmarks.t	Tue Aug 22 11:00:00 2017 +0200
+++ 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