Show More
@@ -1,4 +1,15 b'' | |||||
1 | Test basic extension support |
|
1 | Test basic extension support | |
|
2 | $ cat > unflush.py <<EOF | |||
|
3 | > import sys | |||
|
4 | > from mercurial import pycompat | |||
|
5 | > if pycompat.ispy3: | |||
|
6 | > # no changes required | |||
|
7 | > sys.exit(0) | |||
|
8 | > with open(sys.argv[1], 'rb') as f: | |||
|
9 | > data = f.read() | |||
|
10 | > with open(sys.argv[1], 'wb') as f: | |||
|
11 | > f.write(data.replace(b', flush=True', b'')) | |||
|
12 | > EOF | |||
2 |
|
13 | |||
3 | $ cat > foobar.py <<EOF |
|
14 | $ cat > foobar.py <<EOF | |
4 | > import os |
|
15 | > import os | |
@@ -95,15 +106,16 b' module/__init__.py-style' | |||||
95 | Check that extensions are loaded in phases: |
|
106 | Check that extensions are loaded in phases: | |
96 |
|
107 | |||
97 | $ cat > foo.py <<EOF |
|
108 | $ cat > foo.py <<EOF | |
|
109 | > from __future__ import print_function | |||
98 | > import os |
|
110 | > import os | |
99 | > name = os.path.basename(__file__).rsplit('.', 1)[0] |
|
111 | > name = os.path.basename(__file__).rsplit('.', 1)[0] | |
100 | > print("1) %s imported" % name) |
|
112 | > print("1) %s imported" % name, flush=True) | |
101 | > def uisetup(ui): |
|
113 | > def uisetup(ui): | |
102 | > print("2) %s uisetup" % name) |
|
114 | > print("2) %s uisetup" % name, flush=True) | |
103 | > def extsetup(): |
|
115 | > def extsetup(): | |
104 | > print("3) %s extsetup" % name) |
|
116 | > print("3) %s extsetup" % name, flush=True) | |
105 | > def reposetup(ui, repo): |
|
117 | > def reposetup(ui, repo): | |
106 | > print("4) %s reposetup" % name) |
|
118 | > print("4) %s reposetup" % name, flush=True) | |
107 | > |
|
119 | > | |
108 | > bytesname = name.encode('utf-8') |
|
120 | > bytesname = name.encode('utf-8') | |
109 | > # custom predicate to check registration of functions at loading |
|
121 | > # custom predicate to check registration of functions at loading | |
@@ -116,6 +128,7 b' Check that extensions are loaded in phas' | |||||
116 | > def custompredicate(repo, subset, x): |
|
128 | > def custompredicate(repo, subset, x): | |
117 | > return smartset.baseset([r for r in subset if r in {0}]) |
|
129 | > return smartset.baseset([r for r in subset if r in {0}]) | |
118 | > EOF |
|
130 | > EOF | |
|
131 | $ $PYTHON $TESTTMP/unflush.py foo.py | |||
119 |
|
132 | |||
120 | $ cp foo.py bar.py |
|
133 | $ cp foo.py bar.py | |
121 | $ echo 'foo = foo.py' >> $HGRCPATH |
|
134 | $ echo 'foo = foo.py' >> $HGRCPATH | |
@@ -188,29 +201,32 b' Check "from __future__ import absolute_i' | |||||
188 | $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py |
|
201 | $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py | |
189 |
|
202 | |||
190 | $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF |
|
203 | $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF | |
191 | > from __future__ import absolute_import |
|
204 | > from __future__ import absolute_import, print_function | |
192 | > import ambig # should load "libroot/ambig.py" |
|
205 | > import ambig # should load "libroot/ambig.py" | |
193 | > s = ambig.s |
|
206 | > s = ambig.s | |
194 | > EOF |
|
207 | > EOF | |
195 | $ cat > loadabs.py <<EOF |
|
208 | $ cat > loadabs.py <<EOF | |
196 | > import mod.ambigabs as ambigabs |
|
209 | > import mod.ambigabs as ambigabs | |
197 | > def extsetup(): |
|
210 | > def extsetup(): | |
198 | > print('ambigabs.s=%s' % ambigabs.s) |
|
211 | > print('ambigabs.s=%s' % ambigabs.s, flush=True) | |
199 | > EOF |
|
212 | > EOF | |
|
213 | $ $PYTHON $TESTTMP/unflush.py loadabs.py | |||
200 |
$ |
|
214 | $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root) | |
201 | ambigabs.s=libroot/ambig.py |
|
215 | ambigabs.s=libroot/ambig.py | |
202 | $TESTTMP/a |
|
216 | $TESTTMP/a | |
203 |
|
217 | |||
204 | #if no-py3k |
|
218 | #if no-py3k | |
205 | $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF |
|
219 | $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF | |
|
220 | > from __future__ import print_function | |||
206 | > import ambig # should load "libroot/mod/ambig.py" |
|
221 | > import ambig # should load "libroot/mod/ambig.py" | |
207 | > s = ambig.s |
|
222 | > s = ambig.s | |
208 | > EOF |
|
223 | > EOF | |
209 | $ cat > loadrel.py <<EOF |
|
224 | $ cat > loadrel.py <<EOF | |
210 | > import mod.ambigrel as ambigrel |
|
225 | > import mod.ambigrel as ambigrel | |
211 | > def extsetup(): |
|
226 | > def extsetup(): | |
212 | > print('ambigrel.s=%s' % ambigrel.s) |
|
227 | > print('ambigrel.s=%s' % ambigrel.s, flush=True) | |
213 | > EOF |
|
228 | > EOF | |
|
229 | $ $PYTHON $TESTTMP/unflush.py loadrel.py | |||
214 |
$ |
|
230 | $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root) | |
215 | ambigrel.s=libroot/mod/ambig.py |
|
231 | ambigrel.s=libroot/mod/ambig.py | |
216 | $TESTTMP/a |
|
232 | $TESTTMP/a | |
@@ -1739,13 +1755,15 b' Prohibit the use of unicode strings as t' | |||||
1739 | $ hg init $TESTTMP/opt-unicode-default |
|
1755 | $ hg init $TESTTMP/opt-unicode-default | |
1740 |
|
1756 | |||
1741 | $ cat > $TESTTMP/test_unicode_default_value.py << EOF |
|
1757 | $ cat > $TESTTMP/test_unicode_default_value.py << EOF | |
|
1758 | > from __future__ import print_function | |||
1742 | > from mercurial import registrar |
|
1759 | > from mercurial import registrar | |
1743 | > cmdtable = {} |
|
1760 | > cmdtable = {} | |
1744 | > command = registrar.command(cmdtable) |
|
1761 | > command = registrar.command(cmdtable) | |
1745 | > @command(b'dummy', [(b'', b'opt', u'value', u'help')], 'ext [OPTIONS]') |
|
1762 | > @command(b'dummy', [(b'', b'opt', u'value', u'help')], 'ext [OPTIONS]') | |
1746 | > def ext(*args, **opts): |
|
1763 | > def ext(*args, **opts): | |
1747 | > print(opts[b'opt']) |
|
1764 | > print(opts[b'opt'], flush=True) | |
1748 | > EOF |
|
1765 | > EOF | |
|
1766 | $ $PYTHON $TESTTMP/unflush.py $TESTTMP/test_unicode_default_value.py | |||
1749 | $ cat > $TESTTMP/opt-unicode-default/.hg/hgrc << EOF |
|
1767 | $ cat > $TESTTMP/opt-unicode-default/.hg/hgrc << EOF | |
1750 | > [extensions] |
|
1768 | > [extensions] | |
1751 | > test_unicode_default_value = $TESTTMP/test_unicode_default_value.py |
|
1769 | > test_unicode_default_value = $TESTTMP/test_unicode_default_value.py |
General Comments 0
You need to be logged in to leave comments.
Login now