[PATCH] pager: add 'help' to default attended commands

Brodie Rao brodie at bitheap.org
Mon May 16 18:07:18 CDT 2011


On Sat, Apr 30, 2011 at 10:03 AM, Idan Kamara <idankk86 at gmail.com> wrote:
> On Sat, Apr 30, 2011 at 7:48 PM, Brodie Rao <brodie at bitheap.org> wrote:
>>
>> On Apr 30, 2011, at 4:48 PM, Idan Kamara wrote:
>>
>>> I initially wanted `hg <cmd> --help` to open the pager too but apparently
>>> when dispatch:runcommand sees --help (and --version too it seems),
>>> it calls the help command directly rather than going through the possibly
>>> wrapped _runcommand, bypassing extensions.
>>>
>>> I couldn't think of an elegant solution to fix that, other than looking
>>> for --help in the args and modifying them in place which feels hackish to
>>> me.
>>
>> I don't think it's worth doing this if we can't get consistent behavior.
>>
>> If you make dispatch do another dispatch call to the help command when it
>> sees --help, that might solve this problem.
>
> That's what I wanted to do but it's a bit tricky: `hg <cmd> --help
> --someflag` shows you the help, but if we simply do this transformation:
> `hg <cmd> --help --someflag` --> `hg help <cmd> --someflag` then help will
> tell us it doesn't recognize --someflag.
> So we want to recognize --help (and --version), redirect it to the help
> command, but strip non-global options.
> Then we get `hg <cmd> --help --someflag --config x.y=z` --> `hg help <cmd>
> --config x.y=z`.

Seems reasonable to me, though I guess it might be a lot of work for a
small gain.

I'd imagine that --version would trigger the version command, not help.

It might be nice to be able to say in the specification for the --help
and --version global options that they trigger other commands (instead
of hardcoding the logic in dispatch).


More information about the Mercurial-devel mailing list