resolve: when pats do not match, hint about path:
authortimeless <timeless@mozdev.org>
Thu, 24 Dec 2015 04:31:34 +0000
changeset 28402 7f77e71e5d7e
parent 28401 2565fe39a76c
child 28403 d2e154dddb6e
resolve: when pats do not match, hint about path: Suggest a command that would probably work.
mercurial/commands.py
tests/test-resolve.t
--- 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
--- a/tests/test-resolve.t	Wed Mar 09 08:21:57 2016 +0100
+++ b/tests/test-resolve.t	Thu Dec 24 04:31:34 2015 +0000
@@ -53,6 +53,34 @@
   arguments do not match paths that need resolving
   $ hg resolve -l does-not-exist
 
+tell users how they could have used resolve
+
+  $ mkdir nested
+  $ cd nested
+  $ hg resolve -m file1
+  arguments do not match paths that need resolving
+  (try: hg resolve -m path:file1)
+  $ hg resolve -m file1 filez
+  arguments do not match paths that need resolving
+  (try: hg resolve -m path:file1 path:filez)
+  $ hg resolve -m path:file1 path:filez
+  $ hg resolve -l
+  R file1
+  U file2
+  $ hg resolve -m filez file2
+  arguments do not match paths that need resolving
+  (try: hg resolve -m path:filez path:file2)
+  $ hg resolve -m path:filez path:file2
+  (no more unresolved files)
+  $ hg resolve -l
+  R file1
+  R file2
+
+cleanup
+  $ hg resolve -u
+  $ cd ..
+  $ rmdir nested
+
 don't allow marking or unmarking driver-resolved files
 
   $ cat > $TESTTMP/markdriver.py << EOF