[PATCH] bashcompletion: show available command-line switches for aliases

Martijn Pieters mj at zopatista.com
Tue Jun 21 17:33:16 EDT 2016


On 21 Jun 2016, at 17:36, Anton Shestakov <engored at ya.ru> wrote:
> 22.06.2016, 00:18, "Martijn Pieters" <mj at zopatista.com>:
>> # HG changeset patch
>> # User Martijn Pieters <mjpieters at fb.com>
>> # Date 1466525751 -3600
>> # Tue Jun 21 17:15:51 2016 +0100
>> # Node ID 5931a36ea0d7bbc14d6e68eb69b4fc81b2e00e97
>> # Parent fcaf20175b1b05aa753e1b9f65f10d35a86224df
>> bashcompletion: show available command-line switches for aliases
>> 
>> When auto-completing hg commands, aliases are listed, but not the available
>> switches for an alias, because `HGPLAIN=1` filters these out. Add a
>> `HGPLAINEXCEPT=alias` exception to resolve this.
>> 
>> We make heavy use of aliases that drive hg log with custom revsets, sorting and
>> the -G switch, but want our users to be able to auto-complete any additional
>> command-line switches.
>> 
>> diff --git a/contrib/bash_completion b/contrib/bash_completion
>> --- a/contrib/bash_completion
>> +++ b/contrib/bash_completion
>> @@ -184,7 +184,7 @@
>>              return
>>          fi
>> 
>> - opts=$(_hg_cmd debugcomplete --options "$cmd")
>> + opts=$(HGPLAINEXCEPT=alias _hg_cmd debugcomplete --options "$cmd")
> 
> Looks good, since another instance of "_hg_cmd debugcomplete" already has HGPLAINEXCEPT=alias.
> 
> JFYI, I've tried this with my "crecord = !$HG commit --interactive --config ui.interface=curses $@" alias and since `hg debugcomplete --options crecord` only lists global options, it still couldn't complete --amend or --secret...

Unfortunately, that's a shell alias you have there, which can't be expanded to the original hg command as hg can't be expected to run the shell script you specify to try and extract it. That use-case will have to remain out of reach (as it is now).

It's a pity `--config` is not supported in straight-up aliases, otherwise you could've dropped the !$HG prefix.

Martijn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 204 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160621/ce49435d/attachment.sig>


More information about the Mercurial-devel mailing list