changeset 39754:c48738923dba

bookmarks: remove --active in favor of --list It's weird that we have both --active and --inactive options meaning completely different things. Instead of adding a one-off option, let's document the way to display the active bookmark by using -l/--list. No deprecated option is added since --active isn't released yet.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 15 Sep 2018 12:47:49 +0900
parents b05b4b91de3d
children e65697cce065
files mercurial/commands.py tests/test-bookmarks-current.t tests/test-completion.t
diffstat 3 files changed, 12 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Sep 15 12:44:23 2018 +0900
+++ b/mercurial/commands.py	Sat Sep 15 12:47:49 2018 +0900
@@ -904,7 +904,6 @@
     ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
     ('i', 'inactive', False, _('mark a bookmark inactive')),
     ('l', 'list', False, _('list existing bookmarks')),
-    ('', 'active', False, _('display the active bookmark')),
     ] + formatteropts,
     _('hg bookmarks [OPTIONS]... [NAME]...'))
 def bookmark(ui, repo, *names, **opts):
@@ -931,10 +930,6 @@
     A bookmark named '@' has the special property that :hg:`clone` will
     check it out by default if it exists.
 
-    The '--active' flag will display the current bookmark or return non-zero,
-    if combined with other action, they will be performed on the active
-    bookmark.
-
     .. container:: verbose
 
       Examples:
@@ -958,14 +953,17 @@
       - move the '@' bookmark from another branch::
 
           hg book -f @
+
+      - print only the active bookmark name::
+
+          hg book -ql .
     '''
     opts = pycompat.byteskwargs(opts)
     force = opts.get('force')
     rev = opts.get('rev')
     inactive = opts.get('inactive')  # meaning add/rename to inactive bookmark
 
-    selactions = [k for k in ['delete', 'rename', 'active', 'list']
-                  if opts.get(k)]
+    selactions = [k for k in ['delete', 'rename', 'list'] if opts.get(k)]
     if len(selactions) > 1:
         raise error.Abort(_('--%s and --%s are incompatible')
                           % tuple(selactions[:2]))
@@ -978,11 +976,9 @@
     else:
         action = 'list'
 
-    if rev and action in {'delete', 'rename', 'active', 'list'}:
+    if rev and action in {'delete', 'rename', 'list'}:
         raise error.Abort(_("--rev is incompatible with --%s") % action)
-    if names and action == 'active':
-        raise error.Abort(_("NAMES is incompatible with --active"))
-    if inactive and action in {'delete', 'active', 'list'}:
+    if inactive and action in {'delete', 'list'}:
         raise error.Abort(_("--inactive is incompatible with --%s") % action)
     if not names and action in {'add', 'delete'}:
         raise error.Abort(_("bookmark name required"))
@@ -1008,11 +1004,6 @@
                     ui.status(_("no active bookmark\n"))
                 else:
                     bookmarks.deactivate(repo)
-    elif action == 'active':
-        book = repo._activebookmark
-        if book is None:
-            return 1
-        ui.write("%s\n" % book, label=bookmarks.activebookmarklabel)
     elif action == 'list':
         names = pycompat.maplist(repo._bookmarks.expandname, names)
         with ui.formatter('bookmarks', opts) as fm:
--- a/tests/test-bookmarks-current.t	Sat Sep 15 12:44:23 2018 +0900
+++ b/tests/test-bookmarks-current.t	Sat Sep 15 12:47:49 2018 +0900
@@ -240,8 +240,9 @@
   - Y
   - 
 
-  $ hg bookmarks --active
+  $ hg bookmarks -ql .
   Y
   $ hg bookmarks --inactive
-  $ hg bookmarks --active
-  [1]
+  $ hg bookmarks -ql .
+  abort: no active bookmark!
+  [255]
--- a/tests/test-completion.t	Sat Sep 15 12:44:23 2018 +0900
+++ b/tests/test-completion.t	Sat Sep 15 12:47:49 2018 +0900
@@ -250,7 +250,7 @@
   archive: no-decode, prefix, rev, type, subrepos, include, exclude
   backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
   bisect: reset, good, bad, skip, extend, command, noupdate
-  bookmarks: force, rev, delete, rename, inactive, list, active, template
+  bookmarks: force, rev, delete, rename, inactive, list, template
   branch: force, clean, rev
   branches: active, closed, template
   bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure