Patchwork githelp: cleanup one more abort message

login
register
mail settings
Submitter Matt Harbison
Date May 23, 2018, 4 a.m.
Message ID <e951e2017229ef3e84be.1527048019@Envy>
Download mbox | patch
Permalink /patch/31818/
State Accepted
Headers show

Comments

Matt Harbison - May 23, 2018, 4 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1527047288 14400
#      Tue May 22 23:48:08 2018 -0400
# Node ID e951e2017229ef3e84bef144fb50546de058d93b
# Parent  a6bed2a6eafea7d89af7e12696169c754c9bf64a
githelp: cleanup one more abort message

This makes the string localizable, uses the more standard hint argument, quotes
the problem option so it stands out, and kills a stray apostrophe.
Yuya Nishihara - May 23, 2018, 12:14 p.m.
On Wed, 23 May 2018 00:00:19 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1527047288 14400
> #      Tue May 22 23:48:08 2018 -0400
> # Node ID e951e2017229ef3e84bef144fb50546de058d93b
> # Parent  a6bed2a6eafea7d89af7e12696169c754c9bf64a
> githelp: cleanup one more abort message

Queued, thanks.

> --- a/hgext/githelp.py
> +++ b/hgext/githelp.py
> @@ -94,10 +94,9 @@ def parseoptions(ui, cmdoptions, args):
>              try:
>                  args.remove(flag)
>              except Exception:
> -                raise error.Abort(
> -                    "unknown option {0} packed with other options\n"
> -                    "Please try passing the option as it's own flag: -{0}" \
> -                    .format(ex.opt))
> +                msg = _("unknown option '{0}' packed with other options")
> +                hint = _("please try passing the option as its own flag: -{0}")
> +                raise error.Abort(msg.format(ex.opt), hint=hint.format(ex.opt))

We'll have to replace s.format(x) with 's % x' for Py3 compatibility.

Patch

diff --git a/hgext/githelp.py b/hgext/githelp.py
--- a/hgext/githelp.py
+++ b/hgext/githelp.py
@@ -94,10 +94,9 @@  def parseoptions(ui, cmdoptions, args):
             try:
                 args.remove(flag)
             except Exception:
-                raise error.Abort(
-                    "unknown option {0} packed with other options\n"
-                    "Please try passing the option as it's own flag: -{0}" \
-                    .format(ex.opt))
+                msg = _("unknown option '{0}' packed with other options")
+                hint = _("please try passing the option as its own flag: -{0}")
+                raise error.Abort(msg.format(ex.opt), hint=hint.format(ex.opt))
 
             ui.warn(_("ignoring unknown option %s\n") % flag)
 
diff --git a/tests/test-githelp.t b/tests/test-githelp.t
--- a/tests/test-githelp.t
+++ b/tests/test-githelp.t
@@ -43,8 +43,8 @@  githelp on a command with standalone unr
 
 githelp on a command with unrecognized option packed with other options should fail with error
   $ hg githelp -- commit -pv
-  abort: unknown option v packed with other options
-  Please try passing the option as it's own flag: -v
+  abort: unknown option 'v' packed with other options
+  (please try passing the option as its own flag: -v)
   [255]
 
 githelp for git rebase --skip