Patchwork [1,of,8,py3] dispatch: consolidate formatting of arguments

login
register
mail settings
Submitter Augie Fackler
Date March 19, 2017, 6:11 a.m.
Message ID <ea399732bc91813286b8.1489903892@imladris.local>
Download mbox | patch
Permalink /patch/19440/
State Accepted
Headers show

Comments

Augie Fackler - March 19, 2017, 6:11 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1489897133 14400
#      Sun Mar 19 00:18:53 2017 -0400
# Node ID ea399732bc91813286b8f40082ec33a6a16b3558
# Parent  291951ad070b3fa39dd1d83503aa1011a20d9a21
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.
Augie Fackler - March 19, 2017, 6:13 a.m.
> On Mar 19, 2017, at 2:11 AM, Augie Fackler <raf@durin42.com> wrote:
> 
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1489897133 14400
> #      Sun Mar 19 00:18:53 2017 -0400
> # Node ID ea399732bc91813286b8f40082ec33a6a16b3558
> # Parent  291951ad070b3fa39dd1d83503aa1011a20d9a21
> dispatch: consolidate formatting of arguments

These 8 are the first round of almost 30 patches that get `hg commit` working as long as it doesn’t need to compute a delta (bdiff.py appears to be sad on Python 3, but I’m up waaaay later than I meant to be already...)

> 
> This was getting done twice, and it's clever enough I'm about to split
> it apart and then fix it for Python 3.
> 
> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -92,6 +92,9 @@ def _formatparse(write, inst):
>     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 @@ def dispatch(req):
>         _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 @@ def _dispatch(req):
>         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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - March 19, 2017, 2:36 p.m.
On Sun, 19 Mar 2017 02:11:32 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1489897133 14400
> #      Sun Mar 19 00:18:53 2017 -0400
> # Node ID ea399732bc91813286b8f40082ec33a6a16b3558
> # Parent  291951ad070b3fa39dd1d83503aa1011a20d9a21
> dispatch: consolidate formatting of arguments

Queued these except for 4 and 5, thanks!

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -92,6 +92,9 @@  def _formatparse(write, inst):
     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 @@  def dispatch(req):
         _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 @@  def _dispatch(req):
         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)