Patchwork [5,of,6] resolve: print warning when no work performed (issue4208)

login
register
mail settings
Submitter Gregory Szorc
Date May 9, 2014, 1:46 a.m.
Message ID <e2544ef43ea835a292df.1399599983@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4694/
State Accepted
Headers show

Comments

Gregory Szorc - May 9, 2014, 1:46 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397872586 25200
#      Fri Apr 18 18:56:26 2014 -0700
# Node ID e2544ef43ea835a292df8544f5411fec8fff5a28
# Parent  a5e623de6557ea8854cefc108d5b069adb0f737a
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.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4933,12 +4933,15 @@  def resolve(ui, repo, *pats, **opts):
 
     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)
             else:
@@ -4969,8 +4972,12 @@  def resolve(ui, repo, *pats, **opts):
             # replace filemerge's .orig file with our resolve file
             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', 'all', None, _('revert all changes when no arguments given')),
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -30,8 +30,12 @@  resolve -l should contain an unresolved 
 
   $ 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
   $ hg resolve -m file