Patchwork [3,of,4,V2] resolve: move no-match hint into main resolve function

login
register
mail settings
Submitter Siddharth Agarwal
Date March 21, 2016, 3:18 a.m.
Message ID <9df7db49e7bc5f0e9a16.1458530321@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/14011/
State Changes Requested
Delegated to: Martin von Zweigbergk
Headers show

Comments

Siddharth Agarwal - March 21, 2016, 3:18 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.

Patch

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())