[PATCH] dispatch: fix so that --help more reliably shows command help (issue4240)

Prabhu GS pprabhugs at gmail.com
Tue Jul 8 14:25:29 CDT 2014


Hi,

Waiting for the patch to be reviewed..


Cheers,
Prabhu


On Tue, Jul 1, 2014 at 10:35 PM, Prabhu Gnana Sundar <pprabhugs at gmail.com>
wrote:

> # HG changeset patch
> # User Prabhu Gnana Sundar <pprabhugs at gmail.com>
> # Date 1404234214 -19800
> #      Tue Jul 01 22:33:34 2014 +0530
> # Node ID 43e4cd31fae70005b4680ccb53b51f46b962e5b6
> # Parent  99db956b88ab699644c99095fecadbc4c83adbfc
> dispatch: fix so that --help more reliably shows command help (issue4240)
>
> After hg 3.0, "hg showconfig --help" was showing the configuration man page
> instead of the 'hg help -c showconfig' output.
>
> This patch fixes the 'hg showconfig --help' regression issue by removing an
> unwanted assignement of aliases[0] to cmd and shows the correct command
> in the first line of help description.
> Also, added a test case to test 'hg showconfig --help'.
>
> diff -r 99db956b88ab -r 43e4cd31fae7 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py      Sun Jun 01 16:01:01 2014 -0700
> +++ b/mercurial/cmdutil.py      Tue Jul 01 22:33:34 2014 +0530
> @@ -39,11 +39,13 @@
>          if cmd in aliases:
>              found = cmd
>          elif not strict:
> -            for a in aliases:
> -                if a.startswith(cmd):
> -                    found = a
> +            for alias in aliases:
> +                if alias.startswith(cmd):
> +                    found = alias
>                      break
>          if found is not None:
> +            aliases = [alias for alias in aliases if alias != cmd]
> +            aliases.insert(0, cmd)
>              if aliases[0].startswith("debug") or
> found.startswith("debug"):
>                  debugchoice[found] = (aliases, table[e])
>              else:
> diff -r 99db956b88ab -r 43e4cd31fae7 mercurial/dispatch.py
> --- a/mercurial/dispatch.py     Sun Jun 01 16:01:01 2014 -0700
> +++ b/mercurial/dispatch.py     Tue Jul 01 22:33:34 2014 +0530
> @@ -494,7 +494,6 @@
>          cmd, args = args[0], args[1:]
>          aliases, entry = cmdutil.findcmd(cmd, commands.table,
>                                           ui.configbool("ui", "strict"))
> -        cmd = aliases[0]
>          args = aliasargs(entry[0], args)
>          defaults = ui.config("defaults", cmd)
>          if defaults:
> diff -r 99db956b88ab -r 43e4cd31fae7 tests/test-help.t
> --- a/tests/test-help.t Sun Jun 01 16:01:01 2014 -0700
> +++ b/tests/test-help.t Tue Jul 01 22:33:34 2014 +0530
> @@ -2085,3 +2085,41 @@
>    $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
>
>  #endif
> +
> +
> +Test showconfig help
> +
> +  $ hg showconfig --help
> +  hg showconfig [-u] [NAME]...
> +
> +  aliases: config, debugconfig
> +
> +  show combined config settings from all hgrc files
> +
> +      With no arguments, print names and values of all config items.
> +
> +      With one argument of the form section.name, print just the value
> of that
> +      config item.
> +
> +      With multiple arguments, print names and values of all config items
> with
> +      matching section names.
> +
> +      With --edit, start an editor on the user-level config file. With
> --global,
> +      edit the system-wide config file. With --local, edit the
> repository-level
> +      config file.
> +
> +      With --debug, the source (filename and line number) is printed for
> each
> +      config item.
> +
> +      See "hg help config" for more information about config files.
> +
> +      Returns 0 on success.
> +
> +  options:
> +
> +   -u --untrusted show untrusted configuration options
> +   -e --edit      edit user config
> +   -l --local     edit repository config
> +   -g --global    edit global config
> +
> +  use "hg -v help showconfig" to show the global options
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20140709/1e903d25/attachment.html>


More information about the Mercurial-devel mailing list