| 1 |
#require no-chg |
| 2 |
|
| 3 |
Test basic extension support |
| 4 |
|
| 5 |
$ cat > foobar.py <<EOF |
| 6 |
> import os |
| 7 |
> from mercurial import commands, registrar |
| 8 |
> cmdtable = {} |
| 9 |
> command = registrar.command(cmdtable) |
| 10 |
> configtable = {} |
| 11 |
> configitem = registrar.configitem(configtable) |
| 12 |
> configitem(b'tests', b'foo', default=b"Foo") |
| 13 |
> def uisetup(ui): |
| 14 |
> ui.debug(b"uisetup called [debug]\\n") |
| 15 |
> ui.write(b"uisetup called\\n") |
| 16 |
> ui.status(b"uisetup called [status]\\n") |
| 17 |
> ui.flush() |
| 18 |
> def reposetup(ui, repo): |
| 19 |
> ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root)) |
| 20 |
> ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!")) |
| 21 |
> ui.flush() |
| 22 |
> @command(b'foo', [], b'hg foo') |
| 23 |
> def foo(ui, *args, **kwargs): |
| 24 |
> foo = ui.config(b'tests', b'foo') |
| 25 |
> ui.write(foo) |
| 26 |
> ui.write(b"\\n") |
| 27 |
> @command(b'bar', [], b'hg bar', norepo=True) |
| 28 |
> def bar(ui, *args, **kwargs): |
| 29 |
> ui.write(b"Bar\\n") |
| 30 |
> EOF |
| 31 |
$ abspath=`pwd`/foobar.py |
| 32 |
|
| 33 |
$ mkdir barfoo |
| 34 |
$ cp foobar.py barfoo/__init__.py |
| 35 |
$ barfoopath=`pwd`/barfoo |
| 36 |
|
| 37 |
$ hg init a |
| 38 |
$ cd a |
| 39 |
$ echo foo > file |
| 40 |
$ hg add file |
| 41 |
$ hg commit -m 'add file' |
| 42 |
|
| 43 |
$ echo '[extensions]' >> $HGRCPATH |
| 44 |
$ echo "foobar = $abspath" >> $HGRCPATH |
| 45 |
|
| 46 |
$ filterlog () { |
| 47 |
> sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' |
| 48 |
> } |
| 49 |
|
| 50 |
Test extension setup timings |
| 51 |
|
| 52 |
$ hg foo --traceback --config devel.debug.extensions=yes --debug 2>&1 | filterlog |
| 53 |
YYYY/MM/DD HH:MM:SS (PID)> loading extensions |
| 54 |
YYYY/MM/DD HH:MM:SS (PID)> - processing 1 entries |
| 55 |
YYYY/MM/DD HH:MM:SS (PID)> - loading extension: foobar |
| 56 |
YYYY/MM/DD HH:MM:SS (PID)> > foobar extension loaded in * (glob) |
| 57 |
YYYY/MM/DD HH:MM:SS (PID)> - validating extension tables: foobar |
| 58 |
YYYY/MM/DD HH:MM:SS (PID)> - invoking registered callbacks: foobar |
| 59 |
YYYY/MM/DD HH:MM:SS (PID)> > callbacks completed in * (glob) |
| 60 |
YYYY/MM/DD HH:MM:SS (PID)> > loaded 1 extensions, total time * (glob) |
| 61 |
YYYY/MM/DD HH:MM:SS (PID)> - loading configtable attributes |
| 62 |
YYYY/MM/DD HH:MM:SS (PID)> - executing uisetup hooks |
| 63 |
YYYY/MM/DD HH:MM:SS (PID)> - running uisetup for foobar |
| 64 |
uisetup called [debug] |
| 65 |
uisetup called |
| 66 |
uisetup called [status] |
| 67 |
YYYY/MM/DD HH:MM:SS (PID)> > uisetup for foobar took * (glob) |
| 68 |
YYYY/MM/DD HH:MM:SS (PID)> > all uisetup took * (glob) |
| 69 |
YYYY/MM/DD HH:MM:SS (PID)> - executing extsetup hooks |
| 70 |
YYYY/MM/DD HH:MM:SS (PID)> - running extsetup for foobar |
| 71 |
YYYY/MM/DD HH:MM:SS (PID)> > extsetup for foobar took * (glob) |
| 72 |
YYYY/MM/DD HH:MM:SS (PID)> > all extsetup took * (glob) |
| 73 |
YYYY/MM/DD HH:MM:SS (PID)> - executing remaining aftercallbacks |
| 74 |
YYYY/MM/DD HH:MM:SS (PID)> > remaining aftercallbacks completed in * (glob) |
| 75 |
YYYY/MM/DD HH:MM:SS (PID)> - loading extension registration objects |
| 76 |
YYYY/MM/DD HH:MM:SS (PID)> > extension registration object loading took * (glob) |
| 77 |
YYYY/MM/DD HH:MM:SS (PID)> > extension foobar take a total of * to load (glob) |
| 78 |
YYYY/MM/DD HH:MM:SS (PID)> extension loading complete |
| 79 |
YYYY/MM/DD HH:MM:SS (PID)> loading additional extensions |
| 80 |
YYYY/MM/DD HH:MM:SS (PID)> - processing 1 entries |
| 81 |
YYYY/MM/DD HH:MM:SS (PID)> > loaded 0 extensions, total time * (glob) |
| 82 |
YYYY/MM/DD HH:MM:SS (PID)> - loading configtable attributes |
| 83 |
YYYY/MM/DD HH:MM:SS (PID)> - executing uisetup hooks |
| 84 |
YYYY/MM/DD HH:MM:SS (PID)> > all uisetup took * (glob) |
| 85 |
YYYY/MM/DD HH:MM:SS (PID)> - executing extsetup hooks |
| 86 |
YYYY/MM/DD HH:MM:SS (PID)> > all extsetup took * (glob) |
| 87 |
YYYY/MM/DD HH:MM:SS (PID)> - executing remaining aftercallbacks |
| 88 |
YYYY/MM/DD HH:MM:SS (PID)> > remaining aftercallbacks completed in * (glob) |
| 89 |
YYYY/MM/DD HH:MM:SS (PID)> - loading extension registration objects |
| 90 |
YYYY/MM/DD HH:MM:SS (PID)> > extension registration object loading took * (glob) |
| 91 |
YYYY/MM/DD HH:MM:SS (PID)> extension loading complete |
| 92 |
YYYY/MM/DD HH:MM:SS (PID)> - executing reposetup hooks |
| 93 |
YYYY/MM/DD HH:MM:SS (PID)> - running reposetup for foobar |
| 94 |
reposetup called for a |
| 95 |
ui == repo.ui |
| 96 |
YYYY/MM/DD HH:MM:SS (PID)> > reposetup for foobar took * (glob) |
| 97 |
YYYY/MM/DD HH:MM:SS (PID)> > all reposetup took * (glob) |
| 98 |
Foo |
| 99 |
|
| 100 |
$ cd .. |
| 101 |
|
| 102 |
$ echo 'foobar = !' >> $HGRCPATH |