[PATCH 1 of 8 py3] dispatch: consolidate formatting of arguments

Augie Fackler raf at durin42.com
Sun Mar 19 02:13:13 EDT 2017


> On Mar 19, 2017, at 2:11 AM, Augie Fackler <raf at durin42.com> wrote:
> 
> # HG changeset patch
> # User Augie Fackler <augie at 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 at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list