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

login
register
mail settings
Submitter Gregory Szorc
Date May 3, 2014, 9:27 p.m.
Message ID <e6e8c42fe1c8d6bb7177.1399152460@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4589/
State Superseded
Commit 232de244ab6f8d80368f2f9d0a6277e60fc497bc
Headers show

Comments

Gregory Szorc - May 3, 2014, 9:27 p.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 e6e8c42fe1c8d6bb71779466ae633771e046ac69
# Parent  df175a8704f7ab51eed349d5e166b40a1b414227
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.
Mads Kiilerich - May 4, 2014, 8:48 p.m.
On 05/03/2014 11:27 PM, Gregory Szorc wrote:
> +
> +    if not didwork and pats:
> +        ui.warn(_("no work performed. specified path(s) invalid?\n"))

I think this message will need some bike shedding to be consistent with 
other message. Some thoughts:

* "work" is unclear, better say what you know "patterns did not match 
any files that need resolving" (which however is too long)
* it is better to use one sentence with no period - we seem to often use 
, or ;.
* make it more of a full sentence (or two)
* Mercurial do not try to get the plural s right in messages - just use 
'paths'

/Mads

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.active():
         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