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

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 5:47 a.m.
Message ID <5447ffe83a62313e5fe1.1399009660@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4490/
State Superseded
Headers show

Comments

Gregory Szorc - May 2, 2014, 5:47 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397872586 25200
#      Fri Apr 18 18:56:26 2014 -0700
# Branch stable
# Node ID 5447ffe83a62313e5fe18e2a70bd0ffeb9a31d74
# Parent  7b1284b4135e667af354274ba4193e5ae13cb113
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
@@ -4930,20 +4930,23 @@  def resolve(ui, repo, *pats, **opts):
 
     if not ms:
         raise util.Abort(_('no merge in progress; '
                            'resolve command not applicable'))
 
     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:
                 ui.write("%s %s\n" % (ms[f].upper(), f),
                          label='resolve.' +
                          {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
         elif mark:
@@ -4966,16 +4969,20 @@  def resolve(ui, repo, *pats, **opts):
             finally:
                 ui.setconfig('ui', 'forcemerge', '', 'resolve')
                 ms.commit()
 
             # replace filemerge's .orig file with our resolve file
             util.rename(a + ".resolve", a + ".orig")
 
     ms.commit()
+
+    if not didwork and pats:
+        ui.warn(_("no work performed. specified path(s) invalid?\n"))
+
     return ret
 
 @command('revert',
     [('a', 'all', None, _('revert all changes when no arguments given')),
     ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
     ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
     ('C', 'no-backup', None, _('do not save backup copies of files')),
     ] + walkopts + dryrunopts,
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -26,16 +26,20 @@  failing merge
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
 
 resolve -l should contain an unresolved entry
 
   $ hg resolve -l
   U file
 
+resolving an unknown path emits a warning
+  $ hg resolve -m does-not-exist
+  no work performed. specified path(s) invalid?
+
 resolve the failure
 
   $ echo resolved > file
   $ hg resolve -m file
   $ hg commit -m 'resolved'
 
 resolve -l should error since no merge in progress