changeset 7527:5a14a8f3b909

resolve: require -a switch to resolve all files Like revert -a, this should make this command slightly safer
author Matt Mackall <mpm@selenic.com>
date Fri, 19 Dec 2008 16:47:36 -0600
parents b7d4db95e95a
children eadcc075967e
files mercurial/commands.py tests/test-keyword tests/test-merge9 tests/test-merge9.out
diffstat 4 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Dec 19 21:38:01 2008 +0100
+++ b/mercurial/commands.py	Fri Dec 19 16:47:36 2008 -0600
@@ -2340,19 +2340,26 @@
     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 @@
          _('[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]...')),
--- a/tests/test-keyword	Fri Dec 19 21:38:01 2008 +0100
+++ b/tests/test-keyword	Fri Dec 19 16:47:36 2008 -0600
@@ -322,7 +322,7 @@
 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
 
--- a/tests/test-merge9	Fri Dec 19 21:38:01 2008 +0100
+++ b/tests/test-merge9	Fri Dec 19 16:47:36 2008 -0600
@@ -44,8 +44,11 @@
 echo % after
 hg resolve -l
 
+echo % resolve all warning
+hg resolve
+
 echo % resolve all
-hg resolve
+hg resolve -a
 
 echo % after
 hg resolve -l
--- a/tests/test-merge9.out	Fri Dec 19 21:38:01 2008 +0100
+++ b/tests/test-merge9.out	Fri Dec 19 16:47:36 2008 -0600
@@ -28,6 +28,8 @@
 % 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.