Patchwork bookmarks: allow deleting active bookmark using '.'

login
register
mail settings
Submitter David Demelier
Date Aug. 25, 2017, 6:19 a.m.
Message ID <2c11d8e1d6c442e14d1b.1503641990@fedy>
Download mbox | patch
Permalink /patch/23325/
State Accepted
Headers show

Comments

David Demelier - Aug. 25, 2017, 6:19 a.m.
# HG changeset patch
# User David Demelier <markand@malikania.fr>
# Date 1503559386 -7200
#      Thu Aug 24 09:23:06 2017 +0200
# Node ID 2c11d8e1d6c442e14d1b31ed5d6ce325717c8531
# Parent  546e72c2f4134145b4a91d6e03c1b0ff70b2bd9a
bookmarks: allow deleting active bookmark using '.'
Yuya Nishihara - Aug. 25, 2017, 2:21 p.m.
On Fri, 25 Aug 2017 08:19:50 +0200, David Demelier wrote:
> # HG changeset patch
> # User David Demelier <markand@malikania.fr>
> # Date 1503559386 -7200
> #      Thu Aug 24 09:23:06 2017 +0200
> # Node ID 2c11d8e1d6c442e14d1b31ed5d6ce325717c8531
> # Parent  546e72c2f4134145b4a91d6e03c1b0ff70b2bd9a
> bookmarks: allow deleting active bookmark using '.'

Queued, thanks.

>              if delete:
> +                names = map(repo._bookmarks.expandname, names)

I did s/map/pycompat.maplist/.

Patch

diff -r 546e72c2f413 -r 2c11d8e1d6c4 mercurial/commands.py
--- a/mercurial/commands.py	Mon Aug 21 08:52:46 2017 +0200
+++ b/mercurial/commands.py	Thu Aug 24 09:23:06 2017 +0200
@@ -917,6 +917,9 @@ 
     diverged, a new 'divergent bookmark' of the form 'name@path' will
     be created. Using :hg:`merge` will resolve the divergence.
 
+    Specifying bookmark as '.' to -m or -d options is equivalent to specifying
+    the active bookmark's name.
+
     A bookmark named '@' has the special property that :hg:`clone` will
     check it out by default if it exists.
 
@@ -962,6 +965,7 @@ 
     if delete or rename or names or inactive:
         with repo.wlock(), repo.lock(), repo.transaction('bookmark') as tr:
             if delete:
+                names = map(repo._bookmarks.expandname, names)
                 bookmarks.delete(repo, tr, names)
             elif rename:
                 if not names:
diff -r 546e72c2f413 -r 2c11d8e1d6c4 tests/test-bookmarks.t
--- a/tests/test-bookmarks.t	Mon Aug 21 08:52:46 2017 +0200
+++ b/tests/test-bookmarks.t	Thu Aug 24 09:23:06 2017 +0200
@@ -213,6 +213,26 @@ 
   $ hg up -q Y
   $ hg book -d rename-me
 
+delete bookmark using .
+
+  $ hg book delete-me
+  $ hg book -d .
+  $ hg bookmark
+     X2                        1:925d80f479bb
+     Y                         2:db815d6d32e6
+     Z                         0:f7b1eb17ad24
+  $ hg up -q Y
+
+delete bookmark using . with no active bookmark
+
+  $ hg book delete-me
+  $ hg book -i delete-me
+  $ hg book -d .
+  abort: no active bookmark
+  [255]
+  $ hg up -q Y
+  $ hg book -d delete-me
+
 list bookmarks
 
   $ hg bookmark