# HG changeset patch # User Yuya Nishihara # Date 2018-09-15 03:25:19 # Node ID ec723284d07ad225fa29e0ebe031bfefc52a05d8 # Parent 2b91805e34c7c4c650a82144eee53b80b0238840 bookmarks: parse out implicit "add" action early This prepares for adding -l/--list option, which can be combined with the positional arguments. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -969,6 +969,8 @@ def bookmark(ui, repo, *names, **opts): % tuple(selactions[:2])) if selactions: action = selactions[0] + elif names or rev: + action = 'add' else: action = None @@ -978,10 +980,10 @@ def bookmark(ui, repo, *names, **opts): raise error.Abort(_("NAMES is incompatible with --active")) if inactive and action == 'active': raise error.Abort(_("--inactive is incompatible with --active")) - if not names and (action == 'delete' or rev): + if not names and action in {'add', 'delete'}: raise error.Abort(_("bookmark name required")) - if action in {'delete', 'rename'} or names or inactive: + if action in {'add', 'delete', 'rename'} or inactive: with repo.wlock(), repo.lock(), repo.transaction('bookmark') as tr: if action == 'delete': names = pycompat.maplist(repo._bookmarks.expandname, names) @@ -993,7 +995,7 @@ def bookmark(ui, repo, *names, **opts): raise error.Abort(_("only one new bookmark name allowed")) oldname = repo._bookmarks.expandname(opts['rename']) bookmarks.rename(repo, tr, oldname, names[0], force, inactive) - elif names: + elif action == 'add': bookmarks.addbookmarks(repo, tr, names, rev, force, inactive) elif inactive: if len(repo._bookmarks) == 0: