# HG changeset patch # User Matt Mackall # Date 2008-12-19 22:47:36 # Node ID 5a14a8f3b909aa3b5eb96986d4d7ab607777dff5 # Parent b7d4db95e95a296326437deef207d2ddb4828919 resolve: require -a switch to resolve all files Like revert -a, this should make this command slightly safer diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2340,19 +2340,26 @@ def resolve(ui, repo, *pats, **opts): R = resolved """ - if len([x for x in opts if opts[x]]) > 1: + all, mark, unmark, show = [opts.get(o) for o in 'all mark unmark list'.split()] + + if (show and (mark or unmark)) or (mark and unmark): raise util.Abort(_("too many options specified")) + if pats and all: + raise util.Abort(_("can't specify --all and patterns")) + if not (all or pats or show or mark or unmark): + raise util.Abort(_('no files or directories specified; ' + 'use --all to remerge all files')) ms = merge_.mergestate(repo) m = cmdutil.match(repo, pats, opts) for f in ms: if m(f): - if opts.get("list"): + if show: ui.write("%s %s\n" % (ms[f].upper(), f)) - elif opts.get("mark"): + elif mark: ms.mark(f, "r") - elif opts.get("unmark"): + elif unmark: ms.mark(f, "u") else: wctx = repo[None] @@ -3312,7 +3319,8 @@ table = { _('[OPTION]... SOURCE... DEST')), "resolve": (resolve, - [('l', 'list', None, _('list state of files needing merge')), + [('a', 'all', None, _('remerge all unresolved files')), + ('l', 'list', None, _('list state of files needing merge')), ('m', 'mark', None, _('mark files as resolved')), ('u', 'unmark', None, _('unmark files as resolved'))], _('[OPTION]... [FILE]...')), diff --git a/tests/test-keyword b/tests/test-keyword --- a/tests/test-keyword +++ b/tests/test-keyword @@ -322,7 +322,7 @@ hg merge echo % keyword stays outside conflict zone cat m echo % resolve to local -HGMERGE=internal:local hg resolve +HGMERGE=internal:local hg resolve -a hg commit -m localresolve cat m diff --git a/tests/test-merge9 b/tests/test-merge9 --- a/tests/test-merge9 +++ b/tests/test-merge9 @@ -44,8 +44,11 @@ hg resolve baz echo % after hg resolve -l +echo % resolve all warning +hg resolve + echo % resolve all -hg resolve +hg resolve -a echo % after hg resolve -l diff --git a/tests/test-merge9.out b/tests/test-merge9.out --- a/tests/test-merge9.out +++ b/tests/test-merge9.out @@ -28,6 +28,8 @@ merging baz and foo to baz % after U bar R baz +% resolve all warning +abort: no files or directories specified; use --all to remerge all files % resolve all merging bar warning: conflicts during merge.