[PATCH 3 of 4 V2] resolve: move no-match hint into main resolve function
Siddharth Agarwal
sid0 at fb.com
Sun Mar 20 23:18:41 EDT 2016
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1458530026 25200
# Sun Mar 20 20:13:46 2016 -0700
# Node ID 9df7db49e7bc5f0e9a1630e048fdbe8191e04da0
# Parent 65d7aff92105e37a40d845d7dd95267cfb920299
resolve: move no-match hint into main resolve function
This hint is a little tricky to deal with because we need to pass the
information about whether we should print out the list of paths back up to the
caller. We can't make this determination outside because it requires access to
the wctx.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2883,7 +2883,7 @@ def commitstatus(repo, node, branch, bhe
def postcommitstatus(repo, pats, opts):
return repo.status(match=scmutil.match(repo[None], pats, opts))
-def resolve(ui, repo, ms, pats, opts, flaglist):
+def resolve(ui, repo, ms, pats, opts):
from . import merge as mergemod
mark = opts.get('mark')
unmark = opts.get('unmark')
@@ -2989,22 +2989,16 @@ def resolve(ui, repo, ms, pats, opts, fl
ms.recordactions()
if not didwork and pats:
- hint = None
+ hintpath = False
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))
+ hintpath = True
break
- ui.warn(_("arguments do not match paths that need resolving\n"))
- if hint:
- ui.warn(hint)
+ return ret, ('nomatch', hintpath)
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/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6025,10 +6025,18 @@ def resolve(ui, repo, *pats, **opts):
with repo.wlock():
ms = mergemod.mergestate.read(repo)
- ret, showhint = cmdutil.resolve(ui, repo, ms, pats, opts, flaglist)
+ ret, showhint = cmdutil.resolve(ui, repo, ms, pats, opts)
if showhint is None:
pass
+ elif showhint[0] == 'nomatch':
+ hintpath = showhint[1]
+ ui.warn(_("arguments do not match paths that need resolving\n"))
+ if hintpath:
+ pats = ['path:%s' % p for p in pats]
+ flags = ''.join(['-%s ' % o[0] for o in flaglist
+ if opts.get(o)])
+ ui.warn(_("(try: hg resolve %s%s)\n") % (flags, ' '.join(pats)))
elif showhint[0] == 'final':
# Nudge users into finishing an unfinished operation
unresolvedf = list(ms.unresolved())
More information about the Mercurial-devel
mailing list