changeset 31499:3c77414a0f9c

dispatch: consolidate formatting of arguments This was getting done twice, and it's clever enough I'm about to split it apart and then fix it for Python 3.
author Augie Fackler <augie@google.com>
date Sun, 19 Mar 2017 00:18:53 -0400
parents 492c64afc54c
children 7e9c7d1d65cb
files mercurial/dispatch.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Fri Mar 17 05:10:58 2017 +0530
+++ b/mercurial/dispatch.py	Sun Mar 19 00:18:53 2017 -0400
@@ -92,6 +92,9 @@
     if inst.hint:
         write(_("(%s)\n") % inst.hint)
 
+def _formatargs(args):
+    return ' '.join(' ' in a and repr(a) or a for a in args)
+
 def dispatch(req):
     "run the command specified in req.args"
     if req.ferr:
@@ -123,7 +126,7 @@
         _formatparse(ferr.write, inst)
         return -1
 
-    msg = ' '.join(' ' in a and repr(a) or a for a in req.args)
+    msg = _formatargs(req.args)
     starttime = util.timer()
     ret = None
     try:
@@ -829,7 +832,7 @@
         elif rpath:
             ui.warn(_("warning: --repository ignored\n"))
 
-        msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
+        msg = _formatargs(fullargs)
         ui.log("command", '%s\n', msg)
         strcmdopt = pycompat.strkwargs(cmdoptions)
         d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)