| 1 |
Test the extensions.afterloaded() function |
| 2 |
|
| 3 |
$ cat > foo.py <<EOF |
| 4 |
> from mercurial import extensions |
| 5 |
> def uisetup(ui): |
| 6 |
> ui.write(b"foo.uisetup\\n") |
| 7 |
> ui.flush() |
| 8 |
> def bar_loaded(loaded): |
| 9 |
> ui.write(b"foo: bar loaded: %r\\n" % (loaded,)) |
| 10 |
> ui.flush() |
| 11 |
> extensions.afterloaded(b'bar', bar_loaded) |
| 12 |
> EOF |
| 13 |
$ cat > bar.py <<EOF |
| 14 |
> def uisetup(ui): |
| 15 |
> ui.write(b"bar.uisetup\\n") |
| 16 |
> ui.flush() |
| 17 |
> EOF |
| 18 |
$ basepath=`pwd` |
| 19 |
|
| 20 |
$ hg init basic |
| 21 |
$ cd basic |
| 22 |
$ echo foo > file |
| 23 |
$ hg add file |
| 24 |
$ hg commit -m 'add file' |
| 25 |
|
| 26 |
$ echo '[extensions]' >> .hg/hgrc |
| 27 |
$ echo "foo = $basepath/foo.py" >> .hg/hgrc |
| 28 |
$ echo "bar = $basepath/bar.py" >> .hg/hgrc |
| 29 |
$ hg log -r. -T'{rev}\n' |
| 30 |
foo.uisetup |
| 31 |
foo: bar loaded: True |
| 32 |
bar.uisetup |
| 33 |
0 |
| 34 |
|
| 35 |
Test afterloaded with the opposite extension load order |
| 36 |
|
| 37 |
$ cd .. |
| 38 |
$ hg init basic_reverse |
| 39 |
$ cd basic_reverse |
| 40 |
$ echo foo > file |
| 41 |
$ hg add file |
| 42 |
$ hg commit -m 'add file' |
| 43 |
|
| 44 |
$ echo '[extensions]' >> .hg/hgrc |
| 45 |
$ echo "bar = $basepath/bar.py" >> .hg/hgrc |
| 46 |
$ echo "foo = $basepath/foo.py" >> .hg/hgrc |
| 47 |
$ hg log -r. -T'{rev}\n' |
| 48 |
bar.uisetup |
| 49 |
foo.uisetup |
| 50 |
foo: bar loaded: True |
| 51 |
0 |
| 52 |
|
| 53 |
Test the extensions.afterloaded() function when the requested extension is not |
| 54 |
loaded |
| 55 |
|
| 56 |
$ cd .. |
| 57 |
$ hg init notloaded |
| 58 |
$ cd notloaded |
| 59 |
$ echo foo > file |
| 60 |
$ hg add file |
| 61 |
$ hg commit -m 'add file' |
| 62 |
|
| 63 |
$ echo '[extensions]' >> .hg/hgrc |
| 64 |
$ echo "foo = $basepath/foo.py" >> .hg/hgrc |
| 65 |
$ hg log -r. -T'{rev}\n' |
| 66 |
foo.uisetup |
| 67 |
foo: bar loaded: False |
| 68 |
0 |
| 69 |
|
| 70 |
Test the extensions.afterloaded() function when the requested extension is not |
| 71 |
configured but fails the minimum version check |
| 72 |
|
| 73 |
$ cd .. |
| 74 |
$ cat > minvers.py <<EOF |
| 75 |
> minimumhgversion = b'9999.9999' |
| 76 |
> def uisetup(ui): |
| 77 |
> ui.write(b"minvers.uisetup\\n") |
| 78 |
> ui.flush() |
| 79 |
> EOF |
| 80 |
$ hg init minversion |
| 81 |
$ cd minversion |
| 82 |
$ echo foo > file |
| 83 |
$ hg add file |
| 84 |
$ hg commit -m 'add file' |
| 85 |
|
| 86 |
$ echo '[extensions]' >> .hg/hgrc |
| 87 |
$ echo "foo = $basepath/foo.py" >> .hg/hgrc |
| 88 |
$ echo "bar = $basepath/minvers.py" >> .hg/hgrc |
| 89 |
$ hg log -r. -T'{rev}\n' |
| 90 |
(third party extension bar requires version 9999.9999 or newer of Mercurial (current: *); disabling) (glob) |
| 91 |
foo.uisetup |
| 92 |
foo: bar loaded: False |
| 93 |
0 |
| 94 |
|
| 95 |
Test the extensions.afterloaded() function when the requested extension is not |
| 96 |
configured but fails the minimum version check, using the opposite load order |
| 97 |
for the two extensions. |
| 98 |
|
| 99 |
$ cd .. |
| 100 |
$ hg init minversion_reverse |
| 101 |
$ cd minversion_reverse |
| 102 |
$ echo foo > file |
| 103 |
$ hg add file |
| 104 |
$ hg commit -m 'add file' |
| 105 |
|
| 106 |
$ echo '[extensions]' >> .hg/hgrc |
| 107 |
$ echo "bar = $basepath/minvers.py" >> .hg/hgrc |
| 108 |
$ echo "foo = $basepath/foo.py" >> .hg/hgrc |
| 109 |
$ hg log -r. -T'{rev}\n' |
| 110 |
(third party extension bar requires version 9999.9999 or newer of Mercurial (current: *); disabling) (glob) |
| 111 |
foo.uisetup |
| 112 |
foo: bar loaded: False |
| 113 |
0 |