Mercurial > hg
comparison tests/test-extension.t @ 38162:bdf344aea0ee
extensions: peek command table of disabled extensions without importing
With chg where demandimport disabled, and if disk cache not warm, it took
more than 5 seconds to get "unknown command" error when you typo a command
name. This is horrible UX.
The new implementation is less accurate than the original one as Python
can do anything at import time and cmdtable may be imported from another
module, but I think it's good enough.
Note that the new implementation has to parse .py files, which is slightly
slower than executing .pyc if demandimport is enabled.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 03 May 2018 18:38:02 +0900 |
parents | a9ffb4a577d0 |
children | b86664c81833 |
comparison
equal
deleted
inserted
replaced
38161:aa10675c5dd6 | 38162:bdf344aea0ee |
---|---|
1227 (use 'hg help extensions' for information on enabling extensions) | 1227 (use 'hg help extensions' for information on enabling extensions) |
1228 | 1228 |
1229 | 1229 |
1230 $ cat > hgext/forest.py <<EOF | 1230 $ cat > hgext/forest.py <<EOF |
1231 > cmdtable = None | 1231 > cmdtable = None |
1232 > @command() | |
1233 > def f(): | |
1234 > pass | |
1235 > @command(123) | |
1236 > def g(): | |
1237 > pass | |
1232 > EOF | 1238 > EOF |
1233 $ hg --config extensions.path=./path.py help foo > /dev/null | 1239 $ hg --config extensions.path=./path.py help foo > /dev/null |
1234 warning: error finding commands in $TESTTMP/hgext/forest.py | |
1235 abort: no such help topic: foo | 1240 abort: no such help topic: foo |
1236 (try 'hg help --keyword foo') | 1241 (try 'hg help --keyword foo') |
1237 [255] | 1242 [255] |
1238 | 1243 |
1239 $ cat > throw.py <<EOF | 1244 $ cat > throw.py <<EOF |