[PATCH v2] resolve: when pats do not match, hint about path:
timeless
timeless at mozdev.org
Wed Mar 2 23:24:00 UTC 2016
# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1450931494 0
# Thu Dec 24 04:31:34 2015 +0000
# Node ID ca46c80b3a467484a951ee6c0bf9ae3063e91d8a
# Parent c7f89ad87baef87f00c507545dfd4cc824bc3131
resolve: when pats do not match, hint about path:
Suggest a command that would probably work.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5939,8 +5939,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"))
@@ -6069,7 +6070,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
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -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
More information about the Mercurial-devel
mailing list