Show More
@@ -1,261 +1,278 b'' | |||||
1 | # Since it's not easy to write a test that portably deals |
|
1 | # Since it's not easy to write a test that portably deals | |
2 | # with files from different users/groups, we cheat a bit by |
|
2 | # with files from different users/groups, we cheat a bit by | |
3 | # monkey-patching some functions in the util module |
|
3 | # monkey-patching some functions in the util module | |
4 |
|
4 | |||
5 | from __future__ import absolute_import, print_function |
|
5 | from __future__ import absolute_import, print_function | |
6 |
|
6 | |||
7 | import os |
|
7 | import os | |
|
8 | import sys | |||
|
9 | ||||
8 | from mercurial import ( |
|
10 | from mercurial import ( | |
9 | error, |
|
11 | error, | |
|
12 | pycompat, | |||
10 | ui as uimod, |
|
13 | ui as uimod, | |
11 | util, |
|
14 | util, | |
12 | ) |
|
15 | ) | |
|
16 | from mercurial.utils import stringutil | |||
13 |
|
17 | |||
14 | hgrc = os.environ['HGRCPATH'] |
|
18 | hgrc = os.environ['HGRCPATH'] | |
15 | f = open(hgrc) |
|
19 | f = open(hgrc, 'rb') | |
16 | basehgrc = f.read() |
|
20 | basehgrc = f.read() | |
17 | f.close() |
|
21 | f.close() | |
18 |
|
22 | |||
19 | def testui(user='foo', group='bar', tusers=(), tgroups=(), |
|
23 | def _maybesysstr(v): | |
20 | cuser='foo', cgroup='bar', debug=False, silent=False, |
|
24 | if isinstance(v, bytes): | |
|
25 | return pycompat.sysstr(v) | |||
|
26 | return pycompat.sysstr(stringutil.pprint(v)) | |||
|
27 | ||||
|
28 | def bprint(*args, **kwargs): | |||
|
29 | print(*[_maybesysstr(a) for a in args], | |||
|
30 | **{k: _maybesysstr(v) for k, v in kwargs.items()}) | |||
|
31 | # avoid awkward interleaving with ui object's output | |||
|
32 | sys.stdout.flush() | |||
|
33 | ||||
|
34 | def testui(user=b'foo', group=b'bar', tusers=(), tgroups=(), | |||
|
35 | cuser=b'foo', cgroup=b'bar', debug=False, silent=False, | |||
21 | report=True): |
|
36 | report=True): | |
22 | # user, group => owners of the file |
|
37 | # user, group => owners of the file | |
23 | # tusers, tgroups => trusted users/groups |
|
38 | # tusers, tgroups => trusted users/groups | |
24 | # cuser, cgroup => user/group of the current process |
|
39 | # cuser, cgroup => user/group of the current process | |
25 |
|
40 | |||
26 | # write a global hgrc with the list of trusted users/groups and |
|
41 | # write a global hgrc with the list of trusted users/groups and | |
27 | # some setting so that we can be sure it was read |
|
42 | # some setting so that we can be sure it was read | |
28 | f = open(hgrc, 'w') |
|
43 | f = open(hgrc, 'wb') | |
29 | f.write(basehgrc) |
|
44 | f.write(basehgrc) | |
30 | f.write('\n[paths]\n') |
|
45 | f.write(b'\n[paths]\n') | |
31 | f.write('global = /some/path\n\n') |
|
46 | f.write(b'global = /some/path\n\n') | |
32 |
|
47 | |||
33 | if tusers or tgroups: |
|
48 | if tusers or tgroups: | |
34 | f.write('[trusted]\n') |
|
49 | f.write(b'[trusted]\n') | |
35 | if tusers: |
|
50 | if tusers: | |
36 | f.write('users = %s\n' % ', '.join(tusers)) |
|
51 | f.write(b'users = %s\n' % b', '.join(tusers)) | |
37 | if tgroups: |
|
52 | if tgroups: | |
38 | f.write('groups = %s\n' % ', '.join(tgroups)) |
|
53 | f.write(b'groups = %s\n' % b', '.join(tgroups)) | |
39 | f.close() |
|
54 | f.close() | |
40 |
|
55 | |||
41 | # override the functions that give names to uids and gids |
|
56 | # override the functions that give names to uids and gids | |
42 | def username(uid=None): |
|
57 | def username(uid=None): | |
43 | if uid is None: |
|
58 | if uid is None: | |
44 | return cuser |
|
59 | return cuser | |
45 | return user |
|
60 | return user | |
46 | util.username = username |
|
61 | util.username = username | |
47 |
|
62 | |||
48 | def groupname(gid=None): |
|
63 | def groupname(gid=None): | |
49 | if gid is None: |
|
64 | if gid is None: | |
50 | return 'bar' |
|
65 | return b'bar' | |
51 | return group |
|
66 | return group | |
52 | util.groupname = groupname |
|
67 | util.groupname = groupname | |
53 |
|
68 | |||
54 | def isowner(st): |
|
69 | def isowner(st): | |
55 | return user == cuser |
|
70 | return user == cuser | |
56 | util.isowner = isowner |
|
71 | util.isowner = isowner | |
57 |
|
72 | |||
58 | # try to read everything |
|
73 | # try to read everything | |
59 | #print '# File belongs to user %s, group %s' % (user, group) |
|
74 | #print '# File belongs to user %s, group %s' % (user, group) | |
60 | #print '# trusted users = %s; trusted groups = %s' % (tusers, tgroups) |
|
75 | #print '# trusted users = %s; trusted groups = %s' % (tusers, tgroups) | |
61 | kind = ('different', 'same') |
|
76 | kind = (b'different', b'same') | |
62 | who = ('', 'user', 'group', 'user and the group') |
|
77 | who = (b'', b'user', b'group', b'user and the group') | |
63 | trusted = who[(user in tusers) + 2*(group in tgroups)] |
|
78 | trusted = who[(user in tusers) + 2*(group in tgroups)] | |
64 | if trusted: |
|
79 | if trusted: | |
65 | trusted = ', but we trust the ' + trusted |
|
80 | trusted = b', but we trust the ' + trusted | |
66 |
print('# %s user, %s group%s' % (kind[user == cuser], |
|
81 | bprint(b'# %s user, %s group%s' % (kind[user == cuser], | |
67 |
|
|
82 | kind[group == cgroup], | |
|
83 | trusted)) | |||
68 |
|
84 | |||
69 | u = uimod.ui.load() |
|
85 | u = uimod.ui.load() | |
70 | # disable the configuration registration warning |
|
86 | # disable the configuration registration warning | |
71 | # |
|
87 | # | |
72 | # the purpose of this test is to check the old behavior, not to validate the |
|
88 | # the purpose of this test is to check the old behavior, not to validate the | |
73 | # behavior from registered item. so we silent warning related to unregisted |
|
89 | # behavior from registered item. so we silent warning related to unregisted | |
74 | # config. |
|
90 | # config. | |
75 | u.setconfig('devel', 'warn-config-unknown', False, 'test') |
|
91 | u.setconfig(b'devel', b'warn-config-unknown', False, b'test') | |
76 | u.setconfig('devel', 'all-warnings', False, 'test') |
|
92 | u.setconfig(b'devel', b'all-warnings', False, b'test') | |
77 | u.setconfig('ui', 'debug', str(bool(debug))) |
|
93 | u.setconfig(b'ui', b'debug', pycompat.bytestr(bool(debug))) | |
78 | u.setconfig('ui', 'report_untrusted', str(bool(report))) |
|
94 | u.setconfig(b'ui', b'report_untrusted', pycompat.bytestr(bool(report))) | |
79 | u.readconfig('.hg/hgrc') |
|
95 | u.readconfig(b'.hg/hgrc') | |
80 | if silent: |
|
96 | if silent: | |
81 | return u |
|
97 | return u | |
82 | print('trusted') |
|
98 | bprint(b'trusted') | |
83 | for name, path in u.configitems('paths'): |
|
99 | for name, path in u.configitems(b'paths'): | |
84 | print(' ', name, '=', util.pconvert(path)) |
|
100 | bprint(b' ', name, b'=', util.pconvert(path)) | |
85 | print('untrusted') |
|
101 | bprint(b'untrusted') | |
86 | for name, path in u.configitems('paths', untrusted=True): |
|
102 | for name, path in u.configitems(b'paths', untrusted=True): | |
87 | print('.', end=' ') |
|
103 | bprint(b'.', end=b' ') | |
88 | u.config('paths', name) # warning with debug=True |
|
104 | u.config(b'paths', name) # warning with debug=True | |
89 | print('.', end=' ') |
|
105 | bprint(b'.', end=b' ') | |
90 | u.config('paths', name, untrusted=True) # no warnings |
|
106 | u.config(b'paths', name, untrusted=True) # no warnings | |
91 | print(name, '=', util.pconvert(path)) |
|
107 | bprint(name, b'=', util.pconvert(path)) | |
92 | print() |
|
108 | print() | |
93 |
|
109 | |||
94 | return u |
|
110 | return u | |
95 |
|
111 | |||
96 | os.mkdir('repo') |
|
112 | os.mkdir(b'repo') | |
97 | os.chdir('repo') |
|
113 | os.chdir(b'repo') | |
98 | os.mkdir('.hg') |
|
114 | os.mkdir(b'.hg') | |
99 | f = open('.hg/hgrc', 'w') |
|
115 | f = open(b'.hg/hgrc', 'wb') | |
100 | f.write('[paths]\n') |
|
116 | f.write(b'[paths]\n') | |
101 | f.write('local = /another/path\n\n') |
|
117 | f.write(b'local = /another/path\n\n') | |
102 | f.close() |
|
118 | f.close() | |
103 |
|
119 | |||
104 | #print '# Everything is run by user foo, group bar\n' |
|
120 | #print '# Everything is run by user foo, group bar\n' | |
105 |
|
121 | |||
106 | # same user, same group |
|
122 | # same user, same group | |
107 | testui() |
|
123 | testui() | |
108 | # same user, different group |
|
124 | # same user, different group | |
109 | testui(group='def') |
|
125 | testui(group=b'def') | |
110 | # different user, same group |
|
126 | # different user, same group | |
111 | testui(user='abc') |
|
127 | testui(user=b'abc') | |
112 | # ... but we trust the group |
|
128 | # ... but we trust the group | |
113 | testui(user='abc', tgroups=['bar']) |
|
129 | testui(user=b'abc', tgroups=[b'bar']) | |
114 | # different user, different group |
|
130 | # different user, different group | |
115 | testui(user='abc', group='def') |
|
131 | testui(user=b'abc', group=b'def') | |
116 | # ... but we trust the user |
|
132 | # ... but we trust the user | |
117 | testui(user='abc', group='def', tusers=['abc']) |
|
133 | testui(user=b'abc', group=b'def', tusers=[b'abc']) | |
118 | # ... but we trust the group |
|
134 | # ... but we trust the group | |
119 | testui(user='abc', group='def', tgroups=['def']) |
|
135 | testui(user=b'abc', group=b'def', tgroups=[b'def']) | |
120 | # ... but we trust the user and the group |
|
136 | # ... but we trust the user and the group | |
121 | testui(user='abc', group='def', tusers=['abc'], tgroups=['def']) |
|
137 | testui(user=b'abc', group=b'def', tusers=[b'abc'], tgroups=[b'def']) | |
122 | # ... but we trust all users |
|
138 | # ... but we trust all users | |
123 | print('# we trust all users') |
|
139 | bprint(b'# we trust all users') | |
124 | testui(user='abc', group='def', tusers=['*']) |
|
140 | testui(user=b'abc', group=b'def', tusers=[b'*']) | |
125 | # ... but we trust all groups |
|
141 | # ... but we trust all groups | |
126 | print('# we trust all groups') |
|
142 | bprint(b'# we trust all groups') | |
127 | testui(user='abc', group='def', tgroups=['*']) |
|
143 | testui(user=b'abc', group=b'def', tgroups=[b'*']) | |
128 | # ... but we trust the whole universe |
|
144 | # ... but we trust the whole universe | |
129 | print('# we trust all users and groups') |
|
145 | bprint(b'# we trust all users and groups') | |
130 | testui(user='abc', group='def', tusers=['*'], tgroups=['*']) |
|
146 | testui(user=b'abc', group=b'def', tusers=[b'*'], tgroups=[b'*']) | |
131 | # ... check that users and groups are in different namespaces |
|
147 | # ... check that users and groups are in different namespaces | |
132 | print("# we don't get confused by users and groups with the same name") |
|
148 | bprint(b"# we don't get confused by users and groups with the same name") | |
133 | testui(user='abc', group='def', tusers=['def'], tgroups=['abc']) |
|
149 | testui(user=b'abc', group=b'def', tusers=[b'def'], tgroups=[b'abc']) | |
134 | # ... lists of user names work |
|
150 | # ... lists of user names work | |
135 | print("# list of user names") |
|
151 | bprint(b"# list of user names") | |
136 | testui(user='abc', group='def', tusers=['foo', 'xyz', 'abc', 'bleh'], |
|
152 | testui(user=b'abc', group=b'def', tusers=[b'foo', b'xyz', b'abc', b'bleh'], | |
137 | tgroups=['bar', 'baz', 'qux']) |
|
153 | tgroups=[b'bar', b'baz', b'qux']) | |
138 | # ... lists of group names work |
|
154 | # ... lists of group names work | |
139 | print("# list of group names") |
|
155 | bprint(b"# list of group names") | |
140 | testui(user='abc', group='def', tusers=['foo', 'xyz', 'bleh'], |
|
156 | testui(user=b'abc', group=b'def', tusers=[b'foo', b'xyz', b'bleh'], | |
141 | tgroups=['bar', 'def', 'baz', 'qux']) |
|
157 | tgroups=[b'bar', b'def', b'baz', b'qux']) | |
142 |
|
158 | |||
143 | print("# Can't figure out the name of the user running this process") |
|
159 | bprint(b"# Can't figure out the name of the user running this process") | |
144 | testui(user='abc', group='def', cuser=None) |
|
160 | testui(user=b'abc', group=b'def', cuser=None) | |
145 |
|
161 | |||
146 | print("# prints debug warnings") |
|
162 | bprint(b"# prints debug warnings") | |
147 | u = testui(user='abc', group='def', cuser='foo', debug=True) |
|
163 | u = testui(user=b'abc', group=b'def', cuser=b'foo', debug=True) | |
148 |
|
164 | |||
149 | print("# report_untrusted enabled without debug hides warnings") |
|
165 | bprint(b"# report_untrusted enabled without debug hides warnings") | |
150 | u = testui(user='abc', group='def', cuser='foo', report=False) |
|
166 | u = testui(user=b'abc', group=b'def', cuser=b'foo', report=False) | |
151 |
|
167 | |||
152 | print("# report_untrusted enabled with debug shows warnings") |
|
168 | bprint(b"# report_untrusted enabled with debug shows warnings") | |
153 | u = testui(user='abc', group='def', cuser='foo', debug=True, report=False) |
|
169 | u = testui(user=b'abc', group=b'def', cuser=b'foo', debug=True, report=False) | |
154 |
|
170 | |||
155 | print("# ui.readconfig sections") |
|
171 | bprint(b"# ui.readconfig sections") | |
156 | filename = 'foobar' |
|
172 | filename = b'foobar' | |
157 | f = open(filename, 'w') |
|
173 | f = open(filename, 'wb') | |
158 | f.write('[foobar]\n') |
|
174 | f.write(b'[foobar]\n') | |
159 | f.write('baz = quux\n') |
|
175 | f.write(b'baz = quux\n') | |
160 | f.close() |
|
176 | f.close() | |
161 | u.readconfig(filename, sections=['foobar']) |
|
177 | u.readconfig(filename, sections=[b'foobar']) | |
162 | print(u.config('foobar', 'baz')) |
|
178 | bprint(u.config(b'foobar', b'baz')) | |
163 |
|
179 | |||
164 | print() |
|
180 | print() | |
165 | print("# read trusted, untrusted, new ui, trusted") |
|
181 | bprint(b"# read trusted, untrusted, new ui, trusted") | |
166 | u = uimod.ui.load() |
|
182 | u = uimod.ui.load() | |
167 | # disable the configuration registration warning |
|
183 | # disable the configuration registration warning | |
168 | # |
|
184 | # | |
169 | # the purpose of this test is to check the old behavior, not to validate the |
|
185 | # the purpose of this test is to check the old behavior, not to validate the | |
170 | # behavior from registered item. so we silent warning related to unregisted |
|
186 | # behavior from registered item. so we silent warning related to unregisted | |
171 | # config. |
|
187 | # config. | |
172 | u.setconfig('devel', 'warn-config-unknown', False, 'test') |
|
188 | u.setconfig(b'devel', b'warn-config-unknown', False, b'test') | |
173 | u.setconfig('devel', 'all-warnings', False, 'test') |
|
189 | u.setconfig(b'devel', b'all-warnings', False, b'test') | |
174 | u.setconfig('ui', 'debug', 'on') |
|
190 | u.setconfig(b'ui', b'debug', b'on') | |
175 | u.readconfig(filename) |
|
191 | u.readconfig(filename) | |
176 | u2 = u.copy() |
|
192 | u2 = u.copy() | |
177 | def username(uid=None): |
|
193 | def username(uid=None): | |
178 | return 'foo' |
|
194 | return b'foo' | |
179 | util.username = username |
|
195 | util.username = username | |
180 | u2.readconfig('.hg/hgrc') |
|
196 | u2.readconfig(b'.hg/hgrc') | |
181 | print('trusted:') |
|
197 | bprint(b'trusted:') | |
182 | print(u2.config('foobar', 'baz')) |
|
198 | bprint(u2.config(b'foobar', b'baz')) | |
183 | print('untrusted:') |
|
199 | bprint(b'untrusted:') | |
184 | print(u2.config('foobar', 'baz', untrusted=True)) |
|
200 | bprint(u2.config(b'foobar', b'baz', untrusted=True)) | |
185 |
|
201 | |||
186 | print() |
|
202 | print() | |
187 | print("# error handling") |
|
203 | bprint(b"# error handling") | |
188 |
|
204 | |||
189 | def assertraises(f, exc=error.Abort): |
|
205 | def assertraises(f, exc=error.Abort): | |
190 | try: |
|
206 | try: | |
191 | f() |
|
207 | f() | |
192 | except exc as inst: |
|
208 | except exc as inst: | |
193 | print('raised', inst.__class__.__name__) |
|
209 | bprint(b'raised', inst.__class__.__name__) | |
194 | else: |
|
210 | else: | |
195 | print('no exception?!') |
|
211 | bprint(b'no exception?!') | |
196 |
|
212 | |||
197 | print("# file doesn't exist") |
|
213 | bprint(b"# file doesn't exist") | |
198 | os.unlink('.hg/hgrc') |
|
214 | os.unlink(b'.hg/hgrc') | |
199 | assert not os.path.exists('.hg/hgrc') |
|
215 | assert not os.path.exists(b'.hg/hgrc') | |
200 | testui(debug=True, silent=True) |
|
216 | testui(debug=True, silent=True) | |
201 | testui(user='abc', group='def', debug=True, silent=True) |
|
217 | testui(user=b'abc', group=b'def', debug=True, silent=True) | |
202 |
|
218 | |||
203 | print() |
|
219 | print() | |
204 | print("# parse error") |
|
220 | bprint(b"# parse error") | |
205 | f = open('.hg/hgrc', 'w') |
|
221 | f = open(b'.hg/hgrc', 'wb') | |
206 | f.write('foo') |
|
222 | f.write(b'foo') | |
207 | f.close() |
|
223 | f.close() | |
208 |
|
224 | |||
209 | try: |
|
225 | try: | |
210 | testui(user='abc', group='def', silent=True) |
|
226 | testui(user=b'abc', group=b'def', silent=True) | |
211 | except error.ParseError as inst: |
|
227 | except error.ParseError as inst: | |
212 | print(inst) |
|
228 | bprint(inst) | |
213 |
|
229 | |||
214 | try: |
|
230 | try: | |
215 | testui(debug=True, silent=True) |
|
231 | testui(debug=True, silent=True) | |
216 | except error.ParseError as inst: |
|
232 | except error.ParseError as inst: | |
217 | print(inst) |
|
233 | bprint(inst) | |
218 |
|
234 | |||
219 | print() |
|
235 | print() | |
220 | print('# access typed information') |
|
236 | bprint(b'# access typed information') | |
221 | with open('.hg/hgrc', 'w') as f: |
|
237 | with open(b'.hg/hgrc', 'wb') as f: | |
222 | f.write('''\ |
|
238 | f.write(b'''\ | |
223 | [foo] |
|
239 | [foo] | |
224 | sub=main |
|
240 | sub=main | |
225 | sub:one=one |
|
241 | sub:one=one | |
226 | sub:two=two |
|
242 | sub:two=two | |
227 | path=monty/python |
|
243 | path=monty/python | |
228 | bool=true |
|
244 | bool=true | |
229 | int=42 |
|
245 | int=42 | |
230 | bytes=81mb |
|
246 | bytes=81mb | |
231 | list=spam,ham,eggs |
|
247 | list=spam,ham,eggs | |
232 | ''') |
|
248 | ''') | |
233 | u = testui(user='abc', group='def', cuser='foo', silent=True) |
|
249 | u = testui(user=b'abc', group=b'def', cuser=b'foo', silent=True) | |
234 | def configpath(section, name, default=None, untrusted=False): |
|
250 | def configpath(section, name, default=None, untrusted=False): | |
235 | path = u.configpath(section, name, default, untrusted) |
|
251 | path = u.configpath(section, name, default, untrusted) | |
236 | if path is None: |
|
252 | if path is None: | |
237 | return None |
|
253 | return None | |
238 | return util.pconvert(path) |
|
254 | return util.pconvert(path) | |
239 |
|
255 | |||
240 | print('# suboptions, trusted and untrusted') |
|
256 | bprint(b'# suboptions, trusted and untrusted') | |
241 | trusted = u.configsuboptions('foo', 'sub') |
|
257 | trusted = u.configsuboptions(b'foo', b'sub') | |
242 | untrusted = u.configsuboptions('foo', 'sub', untrusted=True) |
|
258 | untrusted = u.configsuboptions(b'foo', b'sub', untrusted=True) | |
243 | print( |
|
259 | bprint( | |
244 | (trusted[0], sorted(trusted[1].items())), |
|
260 | (trusted[0], sorted(trusted[1].items())), | |
245 | (untrusted[0], sorted(untrusted[1].items()))) |
|
261 | (untrusted[0], sorted(untrusted[1].items()))) | |
246 | print('# path, trusted and untrusted') |
|
262 | bprint(b'# path, trusted and untrusted') | |
247 | print(configpath('foo', 'path'), configpath('foo', 'path', untrusted=True)) |
|
263 | bprint(configpath(b'foo', b'path'), configpath(b'foo', b'path', untrusted=True)) | |
248 | print('# bool, trusted and untrusted') |
|
264 | bprint(b'# bool, trusted and untrusted') | |
249 | print(u.configbool('foo', 'bool'), u.configbool('foo', 'bool', untrusted=True)) |
|
265 | bprint(u.configbool(b'foo', b'bool'), | |
250 | print('# int, trusted and untrusted') |
|
266 | u.configbool(b'foo', b'bool', untrusted=True)) | |
251 | print( |
|
267 | bprint(b'# int, trusted and untrusted') | |
252 | u.configint('foo', 'int', 0), |
|
268 | bprint( | |
253 |
u.configint('foo', 'int', 0, |
|
269 | u.configint(b'foo', b'int', 0), | |
254 | print('# bytes, trusted and untrusted') |
|
270 | u.configint(b'foo', b'int', 0, untrusted=True)) | |
255 | print( |
|
271 | bprint(b'# bytes, trusted and untrusted') | |
256 | u.configbytes('foo', 'bytes', 0), |
|
272 | bprint( | |
257 |
u.configbytes('foo', 'bytes', 0, |
|
273 | u.configbytes(b'foo', b'bytes', 0), | |
258 | print('# list, trusted and untrusted') |
|
274 | u.configbytes(b'foo', b'bytes', 0, untrusted=True)) | |
259 | print( |
|
275 | bprint(b'# list, trusted and untrusted') | |
260 | u.configlist('foo', 'list', []), |
|
276 | bprint( | |
261 |
u.configlist('foo', 'list', [], |
|
277 | u.configlist(b'foo', b'list', []), | |
|
278 | u.configlist(b'foo', b'list', [], untrusted=True)) |
@@ -1,195 +1,195 b'' | |||||
1 | # same user, same group |
|
1 | # same user, same group | |
2 | trusted |
|
2 | trusted | |
3 | global = /some/path |
|
3 | global = /some/path | |
4 | local = /another/path |
|
4 | local = /another/path | |
5 | untrusted |
|
5 | untrusted | |
6 | . . global = /some/path |
|
6 | . . global = /some/path | |
7 | . . local = /another/path |
|
7 | . . local = /another/path | |
8 |
|
8 | |||
9 | # same user, different group |
|
9 | # same user, different group | |
10 | trusted |
|
10 | trusted | |
11 | global = /some/path |
|
11 | global = /some/path | |
12 | local = /another/path |
|
12 | local = /another/path | |
13 | untrusted |
|
13 | untrusted | |
14 | . . global = /some/path |
|
14 | . . global = /some/path | |
15 | . . local = /another/path |
|
15 | . . local = /another/path | |
16 |
|
16 | |||
17 | # different user, same group |
|
17 | # different user, same group | |
18 | not trusting file .hg/hgrc from untrusted user abc, group bar |
|
18 | not trusting file .hg/hgrc from untrusted user abc, group bar | |
19 | trusted |
|
19 | trusted | |
20 | global = /some/path |
|
20 | global = /some/path | |
21 | untrusted |
|
21 | untrusted | |
22 | . . global = /some/path |
|
22 | . . global = /some/path | |
23 | . . local = /another/path |
|
23 | . . local = /another/path | |
24 |
|
24 | |||
25 | # different user, same group, but we trust the group |
|
25 | # different user, same group, but we trust the group | |
26 | trusted |
|
26 | trusted | |
27 | global = /some/path |
|
27 | global = /some/path | |
28 | local = /another/path |
|
28 | local = /another/path | |
29 | untrusted |
|
29 | untrusted | |
30 | . . global = /some/path |
|
30 | . . global = /some/path | |
31 | . . local = /another/path |
|
31 | . . local = /another/path | |
32 |
|
32 | |||
33 | # different user, different group |
|
33 | # different user, different group | |
34 | not trusting file .hg/hgrc from untrusted user abc, group def |
|
34 | not trusting file .hg/hgrc from untrusted user abc, group def | |
35 | trusted |
|
35 | trusted | |
36 | global = /some/path |
|
36 | global = /some/path | |
37 | untrusted |
|
37 | untrusted | |
38 | . . global = /some/path |
|
38 | . . global = /some/path | |
39 | . . local = /another/path |
|
39 | . . local = /another/path | |
40 |
|
40 | |||
41 | # different user, different group, but we trust the user |
|
41 | # different user, different group, but we trust the user | |
42 | trusted |
|
42 | trusted | |
43 | global = /some/path |
|
43 | global = /some/path | |
44 | local = /another/path |
|
44 | local = /another/path | |
45 | untrusted |
|
45 | untrusted | |
46 | . . global = /some/path |
|
46 | . . global = /some/path | |
47 | . . local = /another/path |
|
47 | . . local = /another/path | |
48 |
|
48 | |||
49 | # different user, different group, but we trust the group |
|
49 | # different user, different group, but we trust the group | |
50 | trusted |
|
50 | trusted | |
51 | global = /some/path |
|
51 | global = /some/path | |
52 | local = /another/path |
|
52 | local = /another/path | |
53 | untrusted |
|
53 | untrusted | |
54 | . . global = /some/path |
|
54 | . . global = /some/path | |
55 | . . local = /another/path |
|
55 | . . local = /another/path | |
56 |
|
56 | |||
57 | # different user, different group, but we trust the user and the group |
|
57 | # different user, different group, but we trust the user and the group | |
58 | trusted |
|
58 | trusted | |
59 | global = /some/path |
|
59 | global = /some/path | |
60 | local = /another/path |
|
60 | local = /another/path | |
61 | untrusted |
|
61 | untrusted | |
62 | . . global = /some/path |
|
62 | . . global = /some/path | |
63 | . . local = /another/path |
|
63 | . . local = /another/path | |
64 |
|
64 | |||
65 | # we trust all users |
|
65 | # we trust all users | |
66 | # different user, different group |
|
66 | # different user, different group | |
67 | trusted |
|
67 | trusted | |
68 | global = /some/path |
|
68 | global = /some/path | |
69 | local = /another/path |
|
69 | local = /another/path | |
70 | untrusted |
|
70 | untrusted | |
71 | . . global = /some/path |
|
71 | . . global = /some/path | |
72 | . . local = /another/path |
|
72 | . . local = /another/path | |
73 |
|
73 | |||
74 | # we trust all groups |
|
74 | # we trust all groups | |
75 | # different user, different group |
|
75 | # different user, different group | |
76 | trusted |
|
76 | trusted | |
77 | global = /some/path |
|
77 | global = /some/path | |
78 | local = /another/path |
|
78 | local = /another/path | |
79 | untrusted |
|
79 | untrusted | |
80 | . . global = /some/path |
|
80 | . . global = /some/path | |
81 | . . local = /another/path |
|
81 | . . local = /another/path | |
82 |
|
82 | |||
83 | # we trust all users and groups |
|
83 | # we trust all users and groups | |
84 | # different user, different group |
|
84 | # different user, different group | |
85 | trusted |
|
85 | trusted | |
86 | global = /some/path |
|
86 | global = /some/path | |
87 | local = /another/path |
|
87 | local = /another/path | |
88 | untrusted |
|
88 | untrusted | |
89 | . . global = /some/path |
|
89 | . . global = /some/path | |
90 | . . local = /another/path |
|
90 | . . local = /another/path | |
91 |
|
91 | |||
92 | # we don't get confused by users and groups with the same name |
|
92 | # we don't get confused by users and groups with the same name | |
93 | # different user, different group |
|
93 | # different user, different group | |
94 | not trusting file .hg/hgrc from untrusted user abc, group def |
|
94 | not trusting file .hg/hgrc from untrusted user abc, group def | |
95 | trusted |
|
95 | trusted | |
96 | global = /some/path |
|
96 | global = /some/path | |
97 | untrusted |
|
97 | untrusted | |
98 | . . global = /some/path |
|
98 | . . global = /some/path | |
99 | . . local = /another/path |
|
99 | . . local = /another/path | |
100 |
|
100 | |||
101 | # list of user names |
|
101 | # list of user names | |
102 | # different user, different group, but we trust the user |
|
102 | # different user, different group, but we trust the user | |
103 | trusted |
|
103 | trusted | |
104 | global = /some/path |
|
104 | global = /some/path | |
105 | local = /another/path |
|
105 | local = /another/path | |
106 | untrusted |
|
106 | untrusted | |
107 | . . global = /some/path |
|
107 | . . global = /some/path | |
108 | . . local = /another/path |
|
108 | . . local = /another/path | |
109 |
|
109 | |||
110 | # list of group names |
|
110 | # list of group names | |
111 | # different user, different group, but we trust the group |
|
111 | # different user, different group, but we trust the group | |
112 | trusted |
|
112 | trusted | |
113 | global = /some/path |
|
113 | global = /some/path | |
114 | local = /another/path |
|
114 | local = /another/path | |
115 | untrusted |
|
115 | untrusted | |
116 | . . global = /some/path |
|
116 | . . global = /some/path | |
117 | . . local = /another/path |
|
117 | . . local = /another/path | |
118 |
|
118 | |||
119 | # Can't figure out the name of the user running this process |
|
119 | # Can't figure out the name of the user running this process | |
120 | # different user, different group |
|
120 | # different user, different group | |
121 | not trusting file .hg/hgrc from untrusted user abc, group def |
|
121 | not trusting file .hg/hgrc from untrusted user abc, group def | |
122 | trusted |
|
122 | trusted | |
123 | global = /some/path |
|
123 | global = /some/path | |
124 | untrusted |
|
124 | untrusted | |
125 | . . global = /some/path |
|
125 | . . global = /some/path | |
126 | . . local = /another/path |
|
126 | . . local = /another/path | |
127 |
|
127 | |||
128 | # prints debug warnings |
|
128 | # prints debug warnings | |
129 | # different user, different group |
|
129 | # different user, different group | |
130 | not trusting file .hg/hgrc from untrusted user abc, group def |
|
130 | not trusting file .hg/hgrc from untrusted user abc, group def | |
131 | trusted |
|
131 | trusted | |
132 | ignoring untrusted configuration option paths.local = /another/path |
|
132 | ignoring untrusted configuration option paths.local = /another/path | |
133 | global = /some/path |
|
133 | global = /some/path | |
134 | untrusted |
|
134 | untrusted | |
135 | . . global = /some/path |
|
135 | . . global = /some/path | |
136 | . ignoring untrusted configuration option paths.local = /another/path |
|
136 | . ignoring untrusted configuration option paths.local = /another/path | |
137 | . local = /another/path |
|
137 | . local = /another/path | |
138 |
|
138 | |||
139 | # report_untrusted enabled without debug hides warnings |
|
139 | # report_untrusted enabled without debug hides warnings | |
140 | # different user, different group |
|
140 | # different user, different group | |
141 | trusted |
|
141 | trusted | |
142 | global = /some/path |
|
142 | global = /some/path | |
143 | untrusted |
|
143 | untrusted | |
144 | . . global = /some/path |
|
144 | . . global = /some/path | |
145 | . . local = /another/path |
|
145 | . . local = /another/path | |
146 |
|
146 | |||
147 | # report_untrusted enabled with debug shows warnings |
|
147 | # report_untrusted enabled with debug shows warnings | |
148 | # different user, different group |
|
148 | # different user, different group | |
149 | not trusting file .hg/hgrc from untrusted user abc, group def |
|
149 | not trusting file .hg/hgrc from untrusted user abc, group def | |
150 | trusted |
|
150 | trusted | |
151 | ignoring untrusted configuration option paths.local = /another/path |
|
151 | ignoring untrusted configuration option paths.local = /another/path | |
152 | global = /some/path |
|
152 | global = /some/path | |
153 | untrusted |
|
153 | untrusted | |
154 | . . global = /some/path |
|
154 | . . global = /some/path | |
155 | . ignoring untrusted configuration option paths.local = /another/path |
|
155 | . ignoring untrusted configuration option paths.local = /another/path | |
156 | . local = /another/path |
|
156 | . local = /another/path | |
157 |
|
157 | |||
158 | # ui.readconfig sections |
|
158 | # ui.readconfig sections | |
159 | quux |
|
159 | quux | |
160 |
|
160 | |||
161 | # read trusted, untrusted, new ui, trusted |
|
161 | # read trusted, untrusted, new ui, trusted | |
162 | not trusting file foobar from untrusted user abc, group def |
|
162 | not trusting file foobar from untrusted user abc, group def | |
163 | trusted: |
|
163 | trusted: | |
164 | ignoring untrusted configuration option foobar.baz = quux |
|
164 | ignoring untrusted configuration option foobar.baz = quux | |
165 | None |
|
165 | None | |
166 | untrusted: |
|
166 | untrusted: | |
167 | quux |
|
167 | quux | |
168 |
|
168 | |||
169 | # error handling |
|
169 | # error handling | |
170 | # file doesn't exist |
|
170 | # file doesn't exist | |
171 | # same user, same group |
|
171 | # same user, same group | |
172 | # different user, different group |
|
172 | # different user, different group | |
173 |
|
173 | |||
174 | # parse error |
|
174 | # parse error | |
175 | # different user, different group |
|
175 | # different user, different group | |
176 | not trusting file .hg/hgrc from untrusted user abc, group def |
|
176 | not trusting file .hg/hgrc from untrusted user abc, group def | |
177 | ('foo', '.hg/hgrc:1') |
|
177 | ParseError('foo', '.hg/hgrc:1') | |
178 | # same user, same group |
|
178 | # same user, same group | |
179 | ('foo', '.hg/hgrc:1') |
|
179 | ParseError('foo', '.hg/hgrc:1') | |
180 |
|
180 | |||
181 | # access typed information |
|
181 | # access typed information | |
182 | # different user, different group |
|
182 | # different user, different group | |
183 | not trusting file .hg/hgrc from untrusted user abc, group def |
|
183 | not trusting file .hg/hgrc from untrusted user abc, group def | |
184 | # suboptions, trusted and untrusted |
|
184 | # suboptions, trusted and untrusted | |
185 | (None, []) ('main', [('one', 'one'), ('two', 'two')]) |
|
185 | (None, []) ('main', [('one', 'one'), ('two', 'two')]) | |
186 | # path, trusted and untrusted |
|
186 | # path, trusted and untrusted | |
187 | None .hg/monty/python |
|
187 | None .hg/monty/python | |
188 | # bool, trusted and untrusted |
|
188 | # bool, trusted and untrusted | |
189 | False True |
|
189 | False True | |
190 | # int, trusted and untrusted |
|
190 | # int, trusted and untrusted | |
191 | 0 42 |
|
191 | 0 42 | |
192 | # bytes, trusted and untrusted |
|
192 | # bytes, trusted and untrusted | |
193 | 0 84934656 |
|
193 | 0 84934656 | |
194 | # list, trusted and untrusted |
|
194 | # list, trusted and untrusted | |
195 | [] ['spam', 'ham', 'eggs'] |
|
195 | [] ['spam', 'ham', 'eggs'] |
General Comments 0
You need to be logged in to leave comments.
Login now