[PATCH 0 of 2 RFC] Shell alias support

Martin Geisler mg at aragost.com
Fri Jul 9 07:54:42 CDT 2010


Mads Kiilerich <mads at kiilerich.com> writes:

>  Steve Losh wrote, On 07/09/2010 04:23 AM:
>> This is a second version of a patch I sent a day or two ago to add shell
>> aliases to Mercurial, like so:
>>
>>      [alias]
>>      qempty = !hg qrefresh -X "`hg root`"
>>
>> This would help get rid of hacky "alias hgsomething='hg something'" aliases in
>> people's .whateverrc files.
>
> But why? Why are shell aliases so bad?

I've never used them, except for my mq='hg -R $(hg root)' alias.

Having a command as 'hg foo' is quite different from 'hgfoo' -- the
latter will shadow the 'hg' binary and therefore mess up tab completion.
I can also not get help with 'hg help foo' for the shell alias and it
just isn't as smooth, especially on Windows (I assume).

> Shells and scripting is very useful for composing custom commands from
> existing commands, but why should such general functionality be built
> into Mercurial? I think it is a bit out of scope.
>
> If you really want arbitrary shell commands to appear as Mercurial
> commands then I would prefer to do that with something like this
> extension combined with aliases:
>
> import os
> def system(ui, repo, command):
>     os.system(command)
> cmdtable = {'system': (system, [], 'hg system COMMAND')}

Ah, yeah, that's certainly another option. I'm obviously okay with
having it builtin, but we can still change our mind for my sake.

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://aragost.com/mercurial/


More information about the Mercurial-devel mailing list