Show More
@@ -55,7 +55,6 | |||
|
55 | 55 | tests/test-atomictempfile.py not using absolute_import |
|
56 | 56 | tests/test-demandimport.py not using absolute_import |
|
57 | 57 | tests/test-demandimport.py requires print_function |
|
58 | tests/test-trusted.py requires print_function | |
|
59 | 58 | |
|
60 | 59 | #if py3exe |
|
61 | 60 | $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py |
@@ -188,6 +187,5 | |||
|
188 | 187 | mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob) |
|
189 | 188 | tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob) |
|
190 | 189 | tests/test-demandimport.py: invalid syntax: invalid syntax (<unknown>, line *) (glob) |
|
191 | tests/test-trusted.py: invalid syntax: invalid syntax (<unknown>, line *) (glob) | |
|
192 | 190 | |
|
193 | 191 | #endif |
@@ -2,7 +2,7 | |||
|
2 | 2 | # with files from different users/groups, we cheat a bit by |
|
3 | 3 | # monkey-patching some functions in the util module |
|
4 | 4 | |
|
5 | from __future__ import absolute_import | |
|
5 | from __future__ import absolute_import, print_function | |
|
6 | 6 | |
|
7 | 7 | import os |
|
8 | 8 | from mercurial import ( |
@@ -63,8 +63,8 def testui(user='foo', group='bar', tuse | |||
|
63 | 63 | trusted = who[(user in tusers) + 2*(group in tgroups)] |
|
64 | 64 | if trusted: |
|
65 | 65 | trusted = ', but we trust the ' + trusted |
|
66 |
print |
|
|
67 | trusted) | |
|
66 | print('# %s user, %s group%s' % (kind[user == cuser], kind[group == cgroup], | |
|
67 | trusted)) | |
|
68 | 68 | |
|
69 | 69 | u = uimod.ui() |
|
70 | 70 | u.setconfig('ui', 'debug', str(bool(debug))) |
@@ -72,17 +72,17 def testui(user='foo', group='bar', tuse | |||
|
72 | 72 | u.readconfig('.hg/hgrc') |
|
73 | 73 | if silent: |
|
74 | 74 | return u |
|
75 |
print |
|
|
75 | print('trusted') | |
|
76 | 76 | for name, path in u.configitems('paths'): |
|
77 |
print |
|
|
78 |
print |
|
|
77 | print(' ', name, '=', path) | |
|
78 | print('untrusted') | |
|
79 | 79 | for name, path in u.configitems('paths', untrusted=True): |
|
80 |
print |
|
|
80 | print('.', end=' ') | |
|
81 | 81 | u.config('paths', name) # warning with debug=True |
|
82 |
print |
|
|
82 | print('.', end=' ') | |
|
83 | 83 | u.config('paths', name, untrusted=True) # no warnings |
|
84 |
print |
|
|
85 | ||
|
84 | print(name, '=', path) | |
|
85 | print() | |
|
86 | 86 | |
|
87 | 87 | return u |
|
88 | 88 | |
@@ -113,49 +113,49 testui(user='abc', group='def', tgroups= | |||
|
113 | 113 | # ... but we trust the user and the group |
|
114 | 114 | testui(user='abc', group='def', tusers=['abc'], tgroups=['def']) |
|
115 | 115 | # ... but we trust all users |
|
116 |
print |
|
|
116 | print('# we trust all users') | |
|
117 | 117 | testui(user='abc', group='def', tusers=['*']) |
|
118 | 118 | # ... but we trust all groups |
|
119 |
print |
|
|
119 | print('# we trust all groups') | |
|
120 | 120 | testui(user='abc', group='def', tgroups=['*']) |
|
121 | 121 | # ... but we trust the whole universe |
|
122 |
print |
|
|
122 | print('# we trust all users and groups') | |
|
123 | 123 | testui(user='abc', group='def', tusers=['*'], tgroups=['*']) |
|
124 | 124 | # ... check that users and groups are in different namespaces |
|
125 |
print |
|
|
125 | print("# we don't get confused by users and groups with the same name") | |
|
126 | 126 | testui(user='abc', group='def', tusers=['def'], tgroups=['abc']) |
|
127 | 127 | # ... lists of user names work |
|
128 |
print |
|
|
128 | print("# list of user names") | |
|
129 | 129 | testui(user='abc', group='def', tusers=['foo', 'xyz', 'abc', 'bleh'], |
|
130 | 130 | tgroups=['bar', 'baz', 'qux']) |
|
131 | 131 | # ... lists of group names work |
|
132 |
print |
|
|
132 | print("# list of group names") | |
|
133 | 133 | testui(user='abc', group='def', tusers=['foo', 'xyz', 'bleh'], |
|
134 | 134 | tgroups=['bar', 'def', 'baz', 'qux']) |
|
135 | 135 | |
|
136 |
print |
|
|
136 | print("# Can't figure out the name of the user running this process") | |
|
137 | 137 | testui(user='abc', group='def', cuser=None) |
|
138 | 138 | |
|
139 |
print |
|
|
139 | print("# prints debug warnings") | |
|
140 | 140 | u = testui(user='abc', group='def', cuser='foo', debug=True) |
|
141 | 141 | |
|
142 |
print |
|
|
142 | print("# report_untrusted enabled without debug hides warnings") | |
|
143 | 143 | u = testui(user='abc', group='def', cuser='foo', report=False) |
|
144 | 144 | |
|
145 |
print |
|
|
145 | print("# report_untrusted enabled with debug shows warnings") | |
|
146 | 146 | u = testui(user='abc', group='def', cuser='foo', debug=True, report=False) |
|
147 | 147 | |
|
148 |
print |
|
|
148 | print("# ui.readconfig sections") | |
|
149 | 149 | filename = 'foobar' |
|
150 | 150 | f = open(filename, 'w') |
|
151 | 151 | f.write('[foobar]\n') |
|
152 | 152 | f.write('baz = quux\n') |
|
153 | 153 | f.close() |
|
154 | 154 | u.readconfig(filename, sections=['foobar']) |
|
155 |
print |
|
|
155 | print(u.config('foobar', 'baz')) | |
|
156 | 156 | |
|
157 | ||
|
158 |
print |
|
|
157 | print() | |
|
158 | print("# read trusted, untrusted, new ui, trusted") | |
|
159 | 159 | u = uimod.ui() |
|
160 | 160 | u.setconfig('ui', 'debug', 'on') |
|
161 | 161 | u.readconfig(filename) |
@@ -164,30 +164,30 def username(uid=None): | |||
|
164 | 164 | return 'foo' |
|
165 | 165 | util.username = username |
|
166 | 166 | u2.readconfig('.hg/hgrc') |
|
167 |
print |
|
|
168 |
print |
|
|
169 |
print |
|
|
170 |
print |
|
|
167 | print('trusted:') | |
|
168 | print(u2.config('foobar', 'baz')) | |
|
169 | print('untrusted:') | |
|
170 | print(u2.config('foobar', 'baz', untrusted=True)) | |
|
171 | 171 | |
|
172 | ||
|
173 |
print |
|
|
172 | print() | |
|
173 | print("# error handling") | |
|
174 | 174 | |
|
175 | 175 | def assertraises(f, exc=error.Abort): |
|
176 | 176 | try: |
|
177 | 177 | f() |
|
178 | 178 | except exc as inst: |
|
179 |
print |
|
|
179 | print('raised', inst.__class__.__name__) | |
|
180 | 180 | else: |
|
181 |
print |
|
|
181 | print('no exception?!') | |
|
182 | 182 | |
|
183 |
print |
|
|
183 | print("# file doesn't exist") | |
|
184 | 184 | os.unlink('.hg/hgrc') |
|
185 | 185 | assert not os.path.exists('.hg/hgrc') |
|
186 | 186 | testui(debug=True, silent=True) |
|
187 | 187 | testui(user='abc', group='def', debug=True, silent=True) |
|
188 | 188 | |
|
189 | ||
|
190 |
print |
|
|
189 | print() | |
|
190 | print("# parse error") | |
|
191 | 191 | f = open('.hg/hgrc', 'w') |
|
192 | 192 | f.write('foo') |
|
193 | 193 | f.close() |
@@ -195,9 +195,9 f.close() | |||
|
195 | 195 | try: |
|
196 | 196 | testui(user='abc', group='def', silent=True) |
|
197 | 197 | except error.ParseError as inst: |
|
198 |
print |
|
|
198 | print(inst) | |
|
199 | 199 | |
|
200 | 200 | try: |
|
201 | 201 | testui(debug=True, silent=True) |
|
202 | 202 | except error.ParseError as inst: |
|
203 |
print |
|
|
203 | print(inst) |
General Comments 0
You need to be logged in to leave comments.
Login now