[PATCH 2 of 2] dispatch: provide help for disabled extensions and commands
Brodie Rao
dackze at gmail.com
Sat Dec 5 22:59:49 CST 2009
On Dec 5, 2009, at 9:24 PM, Nicolas Dumazet wrote:
> Hey Brodie!
>
> 2009/12/6 Brodie Rao <dackze at gmail.com>:
>
>> Before a command is declared unknown, the cmdtable of each extension in
>> hgext is searched, starting with hgext.<cmdname>, and then every other
>> extension. If there's a match, a help message suggesting the appropriate
>> extension and how to enable them is printed.
>>
>> Every extension could potentially be imported, but for cases like rebase,
>> relink, etc. only one extension is imported.
>>
>
> I'm not sure. I really like the idea, it's a good feature.
> But... well, "hg nonexisting" will import all extensions in the path,
> right? I'm not sure that we want this.
> Is it significantly slower?
Here are times on OS X with HGRCPATH=''.
Pre-patch:
./hg foo 0.10s user 0.04s system 93% cpu 0.142 total
./hg foo 0.04s user 0.03s system 90% cpu 0.075 total
./hg foo 0.04s user 0.03s system 90% cpu 0.073 total
./hg foo 0.04s user 0.03s system 90% cpu 0.074 total
Post-patch:
./hg foo 0.13s user 0.05s system 94% cpu 0.188 total
./hg foo 0.07s user 0.04s system 93% cpu 0.116 total
./hg foo 0.07s user 0.04s system 92% cpu 0.116 total
./hg foo 0.07s user 0.04s system 81% cpu 0.138 total
I don't think that's really a perceptible difference. Having a helpful error message is more useful than making sure invalid commands perform as fast as possible.
> I'm not sure of what is happening here, but the test fails here :
> ERROR: test-extension output changed
> --- Expected output
> +++ Test output
> @@ -104,13 +104,13 @@
> use "hg help extensions" for information on enabling extensions
> 'qdelete' is provided by the following extension:
>
> - mq manage a stack of patches
> + inotify manage a stack of patches
>
> use "hg help extensions" for information on enabling extensions
> hg: unknown command 'qdel'
> 'qdelete' is provided by the following extension:
>
> - mq manage a stack of patches
> + inotify manage a stack of patches
>
> use "hg help extensions" for information on enabling extensions
> % disabled extension
> !
> Failed test-extension: output changed
>
>
> Also, I tried "hg help inserve" with inotify extension disabled, and I
> get the generic help text, meaning that the command is not found. I
> guess it's because you have to import inotify/__init__.py ?
> Could you make sure this case is added to the test too?
Looks like extensions._disabledpaths(init=False) in my current patch doesn't behave quite right. It's supposed to return extension paths, with packages not having /__init__.py appended to the end, but after encountering a package it builds the rest of the list incorrectly. I'll resend a corrected series.
>
> Thanks!
>
> --
> Nicolas Dumazet — NicDumZ
More information about the Mercurial-devel
mailing list