resolve: print warning when no work performed (issue4208)
authorGregory Szorc <gregory.szorc@gmail.com>
Fri, 18 Apr 2014 18:56:26 -0700
changeset 21265 232de244ab6f
parent 21264 4e932dc5c113
child 21266 19d6fec60b81
resolve: print warning when no work performed (issue4208) Previously, if the paths specified as arguments to |hg resolve| were invalid, they were silently ignored and a no-op would ensue. This patch fixes that in some scenarios. If none of the paths specified to |hg resolve| match a path that is in mergestate, a warning will be emitted. Ideally, a warning would be emitted for every path/pattern specified that doesn't match anything. To achieve this would require significant refactoring of the matching subsystem. That work is beyond the scope of this patch series. Something is better than nothing and this patch gets us something.
mercurial/commands.py
tests/test-resolve.t
--- a/mercurial/commands.py	Fri Apr 18 19:08:32 2014 -0700
+++ b/mercurial/commands.py	Fri Apr 18 18:56:26 2014 -0700
@@ -4934,10 +4934,13 @@
     m = scmutil.match(repo[None], pats, opts)
     ret = 0
 
+    didwork = False
     for f in ms:
         if not m(f):
             continue
 
+        didwork = True
+
         if show:
             if nostatus:
                 ui.write("%s\n" % f)
@@ -4970,6 +4973,10 @@
             util.rename(a + ".resolve", a + ".orig")
 
     ms.commit()
+
+    if not didwork and pats:
+        ui.warn(_("arguments do not match paths that need resolved\n"))
+
     return ret
 
 @command('revert',
--- a/tests/test-resolve.t	Fri Apr 18 19:08:32 2014 -0700
+++ b/tests/test-resolve.t	Fri Apr 18 18:56:26 2014 -0700
@@ -31,6 +31,10 @@
   $ hg resolve -l
   U file
 
+resolving an unknown path emits a warning
+  $ hg resolve -m does-not-exist
+  arguments do not match paths that need resolved
+
 resolve the failure
 
   $ echo resolved > file