Defining extension "subcommands"

Augie Fackler raf at durin42.com
Sat Apr 5 00:33:12 UTC 2014


On Mar 31, 2014, at 4:46 PM, Angel Ezquerra <angel.ezquerra at gmail.com> wrote:

> On Mon, Mar 31, 2014 at 8:33 PM, Matt Mackall <mpm at selenic.com> wrote:
>> On Mon, 2014-03-31 at 12:53 +0200, Angel Ezquerra wrote:
>>> Hi,
>>> 
>>> is it possible to create an extension that has a command with several
>>> "subcommands"?
>> 
>> It is, but it's discouraged. The bisect extension used to work this way,
>> for instance, but I hid that when I moved it to core.
> 
> I googled for a solution before asking here and I found an old version
> of the bisect extension help text that did indeed have subcommands.
> Then I checked the current bisect command and I saw that it no longer
> uses them.
> 
> Would you mind giving me some details on why you think it is not a
> good idea to use subcommands? Each of the commands on my extension has
> its own set of parameters. It feels a bit off to use one of the
> parameters to choose the action that is going to be performed... I can
> of course prepend each command with "tf" but I don't like that too
> much either...

I can't speak to it generally, but for the "integration with another VCS" case I've found it's a little better to just make "hg pull" do the right thing and to encode any necessary metadata into the phony URL you pull from. hgsubversion does have an 'svn' command where we hang some random subsubcommands, but by now the only ones there *I* even remember are "hg svn info" (which emulates "svn info") and "hg svn rebuildmeta", both of which are seldom-used. In fact, I can see an argument for "hg svn info" being "hg summary --svn", but I'm not sure it's worth bothering.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20140404/1efc983f/attachment.asc>


More information about the Mercurial mailing list