Show More
@@ -274,7 +274,7 b' def parseeol(ui, repo, nodes):' | |||||
274 | return eolfile(ui, repo.root, data) |
|
274 | return eolfile(ui, repo.root, data) | |
275 | except (IOError, LookupError): |
|
275 | except (IOError, LookupError): | |
276 | pass |
|
276 | pass | |
277 |
except errormod. |
|
277 | except errormod.ConfigError as inst: | |
278 | ui.warn( |
|
278 | ui.warn( | |
279 | _( |
|
279 | _( | |
280 | b"warning: ignoring .hgeol file due to parse error " |
|
280 | b"warning: ignoring .hgeol file due to parse error " |
@@ -165,7 +165,7 b' class config(object):' | |||||
165 | include(expanded, remap=remap, sections=sections) |
|
165 | include(expanded, remap=remap, sections=sections) | |
166 | except IOError as inst: |
|
166 | except IOError as inst: | |
167 | if inst.errno != errno.ENOENT: |
|
167 | if inst.errno != errno.ENOENT: | |
168 |
raise error. |
|
168 | raise error.ConfigError( | |
169 | _(b"cannot include %s (%s)") |
|
169 | _(b"cannot include %s (%s)") | |
170 | % (expanded, encoding.strtolocal(inst.strerror)), |
|
170 | % (expanded, encoding.strtolocal(inst.strerror)), | |
171 | b"%s:%d" % (src, line), |
|
171 | b"%s:%d" % (src, line), | |
@@ -203,7 +203,7 b' class config(object):' | |||||
203 | message = l.rstrip() |
|
203 | message = l.rstrip() | |
204 | if l.startswith(b' '): |
|
204 | if l.startswith(b' '): | |
205 | message = b"unexpected leading whitespace: %s" % message |
|
205 | message = b"unexpected leading whitespace: %s" % message | |
206 |
raise error. |
|
206 | raise error.ConfigError(message, (b"%s:%d" % (src, line))) | |
207 |
|
207 | |||
208 | def read(self, path, fp=None, sections=None, remap=None): |
|
208 | def read(self, path, fp=None, sections=None, remap=None): | |
209 | if not fp: |
|
209 | if not fp: |
@@ -227,6 +227,24 b' class HookAbort(Abort):' | |||||
227 | class ConfigError(Abort): |
|
227 | class ConfigError(Abort): | |
228 | """Exception raised when parsing config files""" |
|
228 | """Exception raised when parsing config files""" | |
229 |
|
229 | |||
|
230 | def __init__(self, message, location=None, hint=None): | |||
|
231 | super(ConfigError, self).__init__(message, hint=hint) | |||
|
232 | self.location = location | |||
|
233 | ||||
|
234 | def format(self): | |||
|
235 | from .i18n import _ | |||
|
236 | ||||
|
237 | if self.location is not None: | |||
|
238 | message = _(b"config error at %s: %s\n") % ( | |||
|
239 | pycompat.bytestr(self.location), | |||
|
240 | self.message, | |||
|
241 | ) | |||
|
242 | else: | |||
|
243 | message = _(b"config error: %s\n") % self.message | |||
|
244 | if self.hint: | |||
|
245 | message += _(b"(%s)\n") % self.hint | |||
|
246 | return message | |||
|
247 | ||||
230 |
|
248 | |||
231 | class UpdateAbort(Abort): |
|
249 | class UpdateAbort(Abort): | |
232 | """Raised when an update is aborted for destination issue""" |
|
250 | """Raised when an update is aborted for destination issue""" |
@@ -466,7 +466,7 b' class ui(object):' | |||||
466 |
|
466 | |||
467 | try: |
|
467 | try: | |
468 | cfg.read(filename, fp, sections=sections, remap=remap) |
|
468 | cfg.read(filename, fp, sections=sections, remap=remap) | |
469 |
except error. |
|
469 | except error.ConfigError as inst: | |
470 | if trusted: |
|
470 | if trusted: | |
471 | raise |
|
471 | raise | |
472 | self.warn( |
|
472 | self.warn( |
@@ -44,7 +44,7 b' should fail' | |||||
44 | #if no-windows |
|
44 | #if no-windows | |
45 | $ echo foo > con.xml |
|
45 | $ echo foo > con.xml | |
46 | $ hg --config ui.portablefilenames=jump add con.xml |
|
46 | $ hg --config ui.portablefilenames=jump add con.xml | |
47 |
|
|
47 | config error: ui.portablefilenames value is invalid ('jump') | |
48 | [30] |
|
48 | [30] | |
49 | $ hg --config ui.portablefilenames=abort add con.xml |
|
49 | $ hg --config ui.portablefilenames=abort add con.xml | |
50 | abort: filename contains 'con', which is reserved on Windows: con.xml |
|
50 | abort: filename contains 'con', which is reserved on Windows: con.xml |
@@ -120,8 +120,8 b' on commit:' | |||||
120 | $ hg init sub |
|
120 | $ hg init sub | |
121 | $ echo '= sub' >> .hgsub |
|
121 | $ echo '= sub' >> .hgsub | |
122 | $ hg ci -qAm 'add subrepo ""' |
|
122 | $ hg ci -qAm 'add subrepo ""' | |
123 |
|
|
123 | config error at .hgsub:1: = sub | |
124 |
[ |
|
124 | [30] | |
125 |
|
125 | |||
126 | prepare tampered repo (including the commit above): |
|
126 | prepare tampered repo (including the commit above): | |
127 |
|
127 | |||
@@ -144,8 +144,8 b' prepare tampered repo (including the com' | |||||
144 | on clone (and update): |
|
144 | on clone (and update): | |
145 |
|
145 | |||
146 | $ hg clone -q emptypath emptypath2 |
|
146 | $ hg clone -q emptypath emptypath2 | |
147 |
|
|
147 | config error at .hgsub:1: = sub | |
148 |
[ |
|
148 | [30] | |
149 |
|
149 | |||
150 | Test current path |
|
150 | Test current path | |
151 | ----------------- |
|
151 | ----------------- |
@@ -7,8 +7,8 b' Invalid syntax: no value' | |||||
7 | > novaluekey |
|
7 | > novaluekey | |
8 | > EOF |
|
8 | > EOF | |
9 | $ hg showconfig |
|
9 | $ hg showconfig | |
10 |
|
|
10 | config error at $TESTTMP/.hg/hgrc:1: novaluekey | |
11 |
[ |
|
11 | [30] | |
12 |
|
12 | |||
13 | Invalid syntax: no key |
|
13 | Invalid syntax: no key | |
14 |
|
14 | |||
@@ -16,8 +16,8 b' Invalid syntax: no key' | |||||
16 | > =nokeyvalue |
|
16 | > =nokeyvalue | |
17 | > EOF |
|
17 | > EOF | |
18 | $ hg showconfig |
|
18 | $ hg showconfig | |
19 |
|
|
19 | config error at $TESTTMP/.hg/hgrc:1: =nokeyvalue | |
20 |
[ |
|
20 | [30] | |
21 |
|
21 | |||
22 | Test hint about invalid syntax from leading white space |
|
22 | Test hint about invalid syntax from leading white space | |
23 |
|
23 | |||
@@ -25,16 +25,16 b' Test hint about invalid syntax from lead' | |||||
25 | > key=value |
|
25 | > key=value | |
26 | > EOF |
|
26 | > EOF | |
27 | $ hg showconfig |
|
27 | $ hg showconfig | |
28 |
|
|
28 | config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: key=value | |
29 |
[ |
|
29 | [30] | |
30 |
|
30 | |||
31 | $ cat > .hg/hgrc << EOF |
|
31 | $ cat > .hg/hgrc << EOF | |
32 | > [section] |
|
32 | > [section] | |
33 | > key=value |
|
33 | > key=value | |
34 | > EOF |
|
34 | > EOF | |
35 | $ hg showconfig |
|
35 | $ hg showconfig | |
36 |
|
|
36 | config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: [section] | |
37 |
[ |
|
37 | [30] | |
38 |
|
38 | |||
39 | Reset hgrc |
|
39 | Reset hgrc | |
40 |
|
40 |
@@ -332,7 +332,7 b' since bar is not touched in this commit,' | |||||
332 |
|
332 | |||
333 | input validation |
|
333 | input validation | |
334 | $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo |
|
334 | $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo | |
335 |
|
|
335 | config error: convert.git.similarity is not a valid integer ('foo') | |
336 | [30] |
|
336 | [30] | |
337 | $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo |
|
337 | $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo | |
338 | abort: similarity must be between 0 and 100 |
|
338 | abort: similarity must be between 0 and 100 |
@@ -18,7 +18,7 b'' | |||||
18 | Push should provide a hint when both 'default' and 'default-push' not set: |
|
18 | Push should provide a hint when both 'default' and 'default-push' not set: | |
19 | $ cd c |
|
19 | $ cd c | |
20 | $ hg push --config paths.default= |
|
20 | $ hg push --config paths.default= | |
21 |
|
|
21 | config error: default repository not configured! | |
22 | (see 'hg help config.paths') |
|
22 | (see 'hg help config.paths') | |
23 | [30] |
|
23 | [30] | |
24 |
|
24 |
@@ -91,8 +91,8 b" However, we can't prevent it from loadin" | |||||
91 | $ mkdir -p badrepo/.hg |
|
91 | $ mkdir -p badrepo/.hg | |
92 | $ echo 'invalid-syntax' > badrepo/.hg/hgrc |
|
92 | $ echo 'invalid-syntax' > badrepo/.hg/hgrc | |
93 | $ hg log -b -Rbadrepo default |
|
93 | $ hg log -b -Rbadrepo default | |
94 |
|
|
94 | config error at badrepo/.hg/hgrc:1: invalid-syntax | |
95 |
[ |
|
95 | [30] | |
96 |
|
96 | |||
97 | $ hg log -b --cwd=inexistent default |
|
97 | $ hg log -b --cwd=inexistent default | |
98 | abort: $ENOENT$: 'inexistent' |
|
98 | abort: $ENOENT$: 'inexistent' |
@@ -16,7 +16,7 b' Basic syntax error' | |||||
16 |
|
16 | |||
17 | $ echo "invalid" > $HGRC |
|
17 | $ echo "invalid" > $HGRC | |
18 | $ hg version |
|
18 | $ hg version | |
19 |
|
|
19 | config error at $TESTTMP/hgrc:1: invalid | |
20 | [255] |
|
20 | [255] | |
21 | $ echo "" > $HGRC |
|
21 | $ echo "" > $HGRC | |
22 |
|
22 | |||
@@ -59,7 +59,7 b' Check %include' | |||||
59 | #if unix-permissions no-root |
|
59 | #if unix-permissions no-root | |
60 | $ chmod u-r $TESTTMP/included |
|
60 | $ chmod u-r $TESTTMP/included | |
61 | $ hg showconfig section |
|
61 | $ hg showconfig section | |
62 |
|
|
62 | config error at $TESTTMP/hgrc:2: cannot include $TESTTMP/included (Permission denied) | |
63 | [255] |
|
63 | [255] | |
64 | #endif |
|
64 | #endif | |
65 |
|
65 | |||
@@ -68,7 +68,7 b' issue1829: wrong indentation' | |||||
68 | $ echo '[foo]' > $HGRC |
|
68 | $ echo '[foo]' > $HGRC | |
69 | $ echo ' x = y' >> $HGRC |
|
69 | $ echo ' x = y' >> $HGRC | |
70 | $ hg version |
|
70 | $ hg version | |
71 |
|
|
71 | config error at $TESTTMP/hgrc:2: unexpected leading whitespace: x = y | |
72 | [255] |
|
72 | [255] | |
73 |
|
73 | |||
74 | $ "$PYTHON" -c "from __future__ import print_function; print('[foo]\nbar = a\n b\n c \n de\n fg \nbaz = bif cb \n')" \ |
|
74 | $ "$PYTHON" -c "from __future__ import print_function; print('[foo]\nbar = a\n b\n c \n de\n fg \nbaz = bif cb \n')" \ | |
@@ -275,7 +275,7 b' Test we can skip the user configuration' | |||||
275 | > EOF |
|
275 | > EOF | |
276 |
|
276 | |||
277 | $ hg path |
|
277 | $ hg path | |
278 |
|
|
278 | config error at $TESTTMP/.hg/hgrc:3: [broken | |
279 | [255] |
|
279 | [255] | |
280 | $ HGRCSKIPREPO=1 hg path |
|
280 | $ HGRCSKIPREPO=1 hg path | |
281 | foo = $TESTTMP/bar |
|
281 | foo = $TESTTMP/bar | |
@@ -283,7 +283,7 b' Test we can skip the user configuration' | |||||
283 | Check that hgweb respect HGRCSKIPREPO=1 |
|
283 | Check that hgweb respect HGRCSKIPREPO=1 | |
284 |
|
284 | |||
285 | $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log |
|
285 | $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log | |
286 |
|
|
286 | config error at $TESTTMP/.hg/hgrc:3: [broken | |
287 | [255] |
|
287 | [255] | |
288 | $ test -f hg.pid && (cat hg.pid >> $DAEMON_PIDS) |
|
288 | $ test -f hg.pid && (cat hg.pid >> $DAEMON_PIDS) | |
289 | [1] |
|
289 | [1] | |
@@ -302,7 +302,7 b' Check that hgweb respect HGRCSKIPREPO=1' | |||||
302 | Check that zeroconf respect HGRCSKIPREPO=1 |
|
302 | Check that zeroconf respect HGRCSKIPREPO=1 | |
303 |
|
303 | |||
304 | $ hg paths --config extensions.zeroconf= |
|
304 | $ hg paths --config extensions.zeroconf= | |
305 |
|
|
305 | config error at $TESTTMP/.hg/hgrc:3: [broken | |
306 | [255] |
|
306 | [255] | |
307 | $ HGRCSKIPREPO=1 hg paths --config extensions.zeroconf= |
|
307 | $ HGRCSKIPREPO=1 hg paths --config extensions.zeroconf= | |
308 | foo = $TESTTMP/bar |
|
308 | foo = $TESTTMP/bar |
@@ -126,7 +126,7 b' Test invalid config default' | |||||
126 | --------------------------- |
|
126 | --------------------------- | |
127 |
|
127 | |||
128 | $ hg histedit --config "histedit.defaultrev=" |
|
128 | $ hg histedit --config "histedit.defaultrev=" | |
129 |
|
|
129 | config error: config option histedit.defaultrev can't be empty | |
130 | [30] |
|
130 | [30] | |
131 |
|
131 | |||
132 | Run on a revision not descendants of the initial parent |
|
132 | Run on a revision not descendants of the initial parent |
@@ -1118,8 +1118,8 b' Bad .hglfs files will block the commit w' | |||||
1118 |
|
1118 | |||
1119 | $ echo x > file.txt |
|
1119 | $ echo x > file.txt | |
1120 | $ hg ci -Aqm 'should fail' |
|
1120 | $ hg ci -Aqm 'should fail' | |
1121 |
|
|
1121 | config error at .hglfs:3: bad file ... no commit | |
1122 |
[ |
|
1122 | [30] | |
1123 |
|
1123 | |||
1124 | $ cat > .hglfs << EOF |
|
1124 | $ cat > .hglfs << EOF | |
1125 | > [track] |
|
1125 | > [track] |
@@ -138,7 +138,7 b" symlinks shouldn't be followed" | |||||
138 |
|
138 | |||
139 | bad config |
|
139 | bad config | |
140 | $ hg merge 1 --config merge.checkunknown=x |
|
140 | $ hg merge 1 --config merge.checkunknown=x | |
141 |
|
|
141 | config error: merge.checkunknown not valid ('x' is none of 'abort', 'ignore', 'warn') | |
142 | [30] |
|
142 | [30] | |
143 | this merge should fail |
|
143 | this merge should fail | |
144 | $ hg merge 1 --config merge.checkunknown=abort |
|
144 | $ hg merge 1 --config merge.checkunknown=abort |
@@ -512,7 +512,7 b' test invalid phase name' | |||||
512 | $ mkcommit I --config phases.new-commit='babar' |
|
512 | $ mkcommit I --config phases.new-commit='babar' | |
513 | transaction abort! |
|
513 | transaction abort! | |
514 | rollback completed |
|
514 | rollback completed | |
515 |
|
|
515 | config error: phases.new-commit: not a valid phase name ('babar') | |
516 | [30] |
|
516 | [30] | |
517 | Test phase command |
|
517 | Test phase command | |
518 | =================== |
|
518 | =================== |
@@ -129,8 +129,8 b' Test error cases' | |||||
129 | > revlog.zlib.level=foobar |
|
129 | > revlog.zlib.level=foobar | |
130 | > EOF |
|
130 | > EOF | |
131 | $ commitone zlib-level-invalid |
|
131 | $ commitone zlib-level-invalid | |
132 |
|
|
132 | config error: storage.revlog.zlib.level is not a valid integer ('foobar') | |
133 |
|
|
133 | config error: storage.revlog.zlib.level is not a valid integer ('foobar') | |
134 | [30] |
|
134 | [30] | |
135 |
|
135 | |||
136 | $ hg init zlib-level-out-of-range |
|
136 | $ hg init zlib-level-out-of-range | |
@@ -186,8 +186,8 b' Test error cases' | |||||
186 | > revlog.zstd.level=foobar |
|
186 | > revlog.zstd.level=foobar | |
187 | > EOF |
|
187 | > EOF | |
188 | $ commitone zstd-level-invalid |
|
188 | $ commitone zstd-level-invalid | |
189 |
|
|
189 | config error: storage.revlog.zstd.level is not a valid integer ('foobar') | |
190 |
|
|
190 | config error: storage.revlog.zstd.level is not a valid integer ('foobar') | |
191 | [30] |
|
191 | [30] | |
192 |
|
192 | |||
193 | $ hg init zstd-level-out-of-range --config format.revlog-compression=zstd |
|
193 | $ hg init zstd-level-out-of-range --config format.revlog-compression=zstd |
@@ -256,12 +256,12 b' f.close()' | |||||
256 |
|
256 | |||
257 | try: |
|
257 | try: | |
258 | testui(user=b'abc', group=b'def', silent=True) |
|
258 | testui(user=b'abc', group=b'def', silent=True) | |
259 |
except error. |
|
259 | except error.ConfigError as inst: | |
260 | bprint(inst.format()) |
|
260 | bprint(inst.format()) | |
261 |
|
261 | |||
262 | try: |
|
262 | try: | |
263 | testui(debug=True, silent=True) |
|
263 | testui(debug=True, silent=True) | |
264 |
except error. |
|
264 | except error.ConfigError as inst: | |
265 | bprint(inst.format()) |
|
265 | bprint(inst.format()) | |
266 |
|
266 | |||
267 | print() |
|
267 | print() |
@@ -176,7 +176,7 b' quux' | |||||
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 | ignored .hg/hgrc:1: foo |
|
177 | ignored .hg/hgrc:1: foo | |
178 | # same user, same group |
|
178 | # same user, same group | |
179 |
|
|
179 | config error at .hg/hgrc:1: foo | |
180 |
|
180 | |||
181 |
|
181 | |||
182 | # access typed information |
|
182 | # access typed information |
General Comments 0
You need to be logged in to leave comments.
Login now