diff mercurial/commands.py @ 28402:7f77e71e5d7e

resolve: when pats do not match, hint about path: Suggest a command that would probably work.
author timeless <timeless@mozdev.org>
date Thu, 24 Dec 2015 04:31:34 +0000
parents 73905484ef70
children 855d9b2eea67
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Mar 09 08:21:57 2016 +0100
+++ b/mercurial/commands.py	Thu Dec 24 04:31:34 2015 +0000
@@ -5991,8 +5991,9 @@
     Returns 0 on success, 1 if any files fail a resolve attempt.
     """
 
+    flaglist = 'all mark unmark list no_status'.split()
     all, mark, unmark, show, nostatus = \
-        [opts.get(o) for o in 'all mark unmark list no_status'.split()]
+        [opts.get(o) for o in flaglist]
 
     if (show and (mark or unmark)) or (mark and unmark):
         raise error.Abort(_("too many options specified"))
@@ -6121,7 +6122,22 @@
         ms.recordactions()
 
         if not didwork and pats:
+            hint = None
+            if not any([p for p in pats if p.find(':') >= 0]):
+                pats = ['path:%s' % p for p in pats]
+                m = scmutil.match(wctx, pats, opts)
+                for f in ms:
+                    if not m(f):
+                        continue
+                    flags = ''.join(['-%s ' % o[0] for o in flaglist
+                                                   if opts.get(o)])
+                    hint = _("(try: hg resolve %s%s)\n") % (
+                             flags,
+                             ' '.join(pats))
+                    break
             ui.warn(_("arguments do not match paths that need resolving\n"))
+            if hint:
+                ui.warn(hint)
         elif ms.mergedriver and ms.mdstate() != 's':
             # run conclude step when either a driver-resolved file is requested
             # or there are no driver-resolved files