Show More
@@ -13,30 +13,38 b' Test basic extension support' | |||||
13 |
|
13 | |||
14 | $ cat > foobar.py <<EOF |
|
14 | $ cat > foobar.py <<EOF | |
15 | > import os |
|
15 | > import os | |
16 | > from mercurial import commands, registrar |
|
16 | > from mercurial import commands, exthelper, registrar | |
17 | > cmdtable = {} |
|
17 | > | |
18 | > command = registrar.command(cmdtable) |
|
18 | > eh = exthelper.exthelper() | |
19 | > configtable = {} |
|
19 | > eh.configitem(b'tests', b'foo', default=b"Foo") | |
20 | > configitem = registrar.configitem(configtable) |
|
20 | > | |
21 | > configitem(b'tests', b'foo', default=b"Foo") |
|
21 | > uisetup = eh.finaluisetup | |
22 | > def uisetup(ui): |
|
22 | > uipopulate = eh.finaluipopulate | |
|
23 | > reposetup = eh.finalreposetup | |||
|
24 | > cmdtable = eh.cmdtable | |||
|
25 | > configtable = eh.configtable | |||
|
26 | > | |||
|
27 | > @eh.uisetup | |||
|
28 | > def _uisetup(ui): | |||
23 | > ui.debug(b"uisetup called [debug]\\n") |
|
29 | > ui.debug(b"uisetup called [debug]\\n") | |
24 | > ui.write(b"uisetup called\\n") |
|
30 | > ui.write(b"uisetup called\\n") | |
25 | > ui.status(b"uisetup called [status]\\n") |
|
31 | > ui.status(b"uisetup called [status]\\n") | |
26 | > ui.flush() |
|
32 | > ui.flush() | |
27 |
> |
|
33 | > @eh.uipopulate | |
|
34 | > def _uipopulate(ui): | |||
28 | > ui._populatecnt = getattr(ui, "_populatecnt", 0) + 1 |
|
35 | > ui._populatecnt = getattr(ui, "_populatecnt", 0) + 1 | |
29 | > ui.write(b"uipopulate called (%d times)\n" % ui._populatecnt) |
|
36 | > ui.write(b"uipopulate called (%d times)\n" % ui._populatecnt) | |
30 |
> |
|
37 | > @eh.reposetup | |
|
38 | > def _reposetup(ui, repo): | |||
31 | > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root)) |
|
39 | > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root)) | |
32 | > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!")) |
|
40 | > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!")) | |
33 | > ui.flush() |
|
41 | > ui.flush() | |
34 | > @command(b'foo', [], b'hg foo') |
|
42 | > @eh.command(b'foo', [], b'hg foo') | |
35 | > def foo(ui, *args, **kwargs): |
|
43 | > def foo(ui, *args, **kwargs): | |
36 | > foo = ui.config(b'tests', b'foo') |
|
44 | > foo = ui.config(b'tests', b'foo') | |
37 | > ui.write(foo) |
|
45 | > ui.write(foo) | |
38 | > ui.write(b"\\n") |
|
46 | > ui.write(b"\\n") | |
39 | > @command(b'bar', [], b'hg bar', norepo=True) |
|
47 | > @eh.command(b'bar', [], b'hg bar', norepo=True) | |
40 | > def bar(ui, *args, **kwargs): |
|
48 | > def bar(ui, *args, **kwargs): | |
41 | > ui.write(b"Bar\\n") |
|
49 | > ui.write(b"Bar\\n") | |
42 | > EOF |
|
50 | > EOF |
General Comments 0
You need to be logged in to leave comments.
Login now