Mercurial > hg
changeset 39750:ec723284d07a
bookmarks: parse out implicit "add" action early
This prepares for adding -l/--list option, which can be combined with the
positional arguments.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 15 Sep 2018 12:25:19 +0900 |
parents | 2b91805e34c7 |
children | 5dfc0ca02aa0 |
files | mercurial/commands.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sat Sep 15 12:07:38 2018 +0900 +++ b/mercurial/commands.py Sat Sep 15 12:25:19 2018 +0900 @@ -969,6 +969,8 @@ % tuple(selactions[:2])) if selactions: action = selactions[0] + elif names or rev: + action = 'add' else: action = None @@ -978,10 +980,10 @@ 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 @@ 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: