##// END OF EJS Templates
tests: skip non-readable check for root...
Joerg Sonnenberger -
r45217:28aacddf default
parent child Browse files
Show More
@@ -1,309 +1,309 b''
1 1 Use hgrc within $TESTTMP
2 2
3 3 $ HGRCPATH=`pwd`/hgrc
4 4 $ export HGRCPATH
5 5
6 6 hide outer repo
7 7 $ hg init
8 8
9 9 Use an alternate var for scribbling on hgrc to keep check-code from
10 10 complaining about the important settings we may be overwriting:
11 11
12 12 $ HGRC=`pwd`/hgrc
13 13 $ export HGRC
14 14
15 15 Basic syntax error
16 16
17 17 $ echo "invalid" > $HGRC
18 18 $ hg version
19 19 hg: parse error at $TESTTMP/hgrc:1: invalid
20 20 [255]
21 21 $ echo "" > $HGRC
22 22
23 23 Issue1199: Can't use '%' in hgrc (eg url encoded username)
24 24
25 25 $ hg init "foo%bar"
26 26 $ hg clone "foo%bar" foobar
27 27 updating to branch default
28 28 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
29 29 $ cd foobar
30 30 $ cat .hg/hgrc
31 31 # example repository config (see 'hg help config' for more info)
32 32 [paths]
33 33 default = $TESTTMP/foo%bar
34 34
35 35 # path aliases to other clones of this repo in URLs or filesystem paths
36 36 # (see 'hg help config.paths' for more info)
37 37 #
38 38 # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork
39 39 # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
40 40 # my-clone = /home/jdoe/jdoes-clone
41 41
42 42 [ui]
43 43 # name and email (local to this repository, optional), e.g.
44 44 # username = Jane Doe <jdoe@example.com>
45 45 $ hg paths
46 46 default = $TESTTMP/foo%bar
47 47 $ hg showconfig
48 48 bundle.mainreporoot=$TESTTMP/foobar
49 49 paths.default=$TESTTMP/foo%bar
50 50 $ cd ..
51 51
52 52 Check %include
53 53
54 54 $ echo '[section]' > $TESTTMP/included
55 55 $ echo 'option = value' >> $TESTTMP/included
56 56 $ echo '%include $TESTTMP/included' >> $HGRC
57 57 $ hg showconfig section
58 58 section.option=value
59 #if no-windows
59 #if unix-permissions no-root
60 60 $ chmod u-r $TESTTMP/included
61 61 $ hg showconfig section
62 62 hg: parse error at $TESTTMP/hgrc:2: cannot include $TESTTMP/included (Permission denied)
63 63 [255]
64 64 #endif
65 65
66 66 issue1829: wrong indentation
67 67
68 68 $ echo '[foo]' > $HGRC
69 69 $ echo ' x = y' >> $HGRC
70 70 $ hg version
71 71 hg: parse error at $TESTTMP/hgrc:2: x = y
72 72 unexpected leading whitespace
73 73 [255]
74 74
75 75 $ "$PYTHON" -c "from __future__ import print_function; print('[foo]\nbar = a\n b\n c \n de\n fg \nbaz = bif cb \n')" \
76 76 > > $HGRC
77 77 $ hg showconfig foo
78 78 foo.bar=a\nb\nc\nde\nfg
79 79 foo.baz=bif cb
80 80
81 81 $ FAKEPATH=/path/to/nowhere
82 82 $ export FAKEPATH
83 83 $ echo '%include $FAKEPATH/no-such-file' > $HGRC
84 84 $ hg version
85 85 Mercurial Distributed SCM (version *) (glob)
86 86 (see https://mercurial-scm.org for more information)
87 87
88 88 Copyright (C) 2005-* Matt Mackall and others (glob)
89 89 This is free software; see the source for copying conditions. There is NO
90 90 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
91 91 $ unset FAKEPATH
92 92
93 93 make sure global options given on the cmdline take precedence
94 94
95 95 $ hg showconfig --config ui.verbose=True --quiet
96 96 bundle.mainreporoot=$TESTTMP
97 97 ui.verbose=False
98 98 ui.debug=False
99 99 ui.quiet=True
100 100
101 101 $ touch foobar/untracked
102 102 $ cat >> foobar/.hg/hgrc <<EOF
103 103 > [ui]
104 104 > verbose=True
105 105 > EOF
106 106 $ hg -R foobar st -q
107 107
108 108 username expansion
109 109
110 110 $ olduser=$HGUSER
111 111 $ unset HGUSER
112 112
113 113 $ FAKEUSER='John Doe'
114 114 $ export FAKEUSER
115 115 $ echo '[ui]' > $HGRC
116 116 $ echo 'username = $FAKEUSER' >> $HGRC
117 117
118 118 $ hg init usertest
119 119 $ cd usertest
120 120 $ touch bar
121 121 $ hg commit --addremove --quiet -m "added bar"
122 122 $ hg log --template "{author}\n"
123 123 John Doe
124 124 $ cd ..
125 125
126 126 $ hg showconfig
127 127 bundle.mainreporoot=$TESTTMP
128 128 ui.username=$FAKEUSER
129 129
130 130 $ unset FAKEUSER
131 131 $ HGUSER=$olduser
132 132 $ export HGUSER
133 133
134 134 showconfig with multiple arguments
135 135
136 136 $ echo "[alias]" > $HGRC
137 137 $ echo "log = log -g" >> $HGRC
138 138 $ echo "[defaults]" >> $HGRC
139 139 $ echo "identify = -n" >> $HGRC
140 140 $ hg showconfig alias defaults
141 141 alias.log=log -g
142 142 defaults.identify=-n
143 143 $ hg showconfig alias alias
144 144 alias.log=log -g
145 145 $ hg showconfig alias.log alias.log
146 146 alias.log=log -g
147 147 $ hg showconfig alias defaults.identify
148 148 alias.log=log -g
149 149 defaults.identify=-n
150 150 $ hg showconfig alias.log defaults.identify
151 151 alias.log=log -g
152 152 defaults.identify=-n
153 153
154 154 HGPLAIN
155 155
156 156 $ echo "[ui]" > $HGRC
157 157 $ echo "debug=true" >> $HGRC
158 158 $ echo "fallbackencoding=ASCII" >> $HGRC
159 159 $ echo "quiet=true" >> $HGRC
160 160 $ echo "slash=true" >> $HGRC
161 161 $ echo "traceback=true" >> $HGRC
162 162 $ echo "verbose=true" >> $HGRC
163 163 $ echo "style=~/.hgstyle" >> $HGRC
164 164 $ echo "logtemplate={node}" >> $HGRC
165 165 $ echo "[defaults]" >> $HGRC
166 166 $ echo "identify=-n" >> $HGRC
167 167 $ echo "[alias]" >> $HGRC
168 168 $ echo "log=log -g" >> $HGRC
169 169
170 170 customized hgrc
171 171
172 172 $ hg showconfig
173 173 read config from: $TESTTMP/hgrc
174 174 $TESTTMP/hgrc:13: alias.log=log -g
175 175 repo: bundle.mainreporoot=$TESTTMP
176 176 $TESTTMP/hgrc:11: defaults.identify=-n
177 177 $TESTTMP/hgrc:2: ui.debug=true
178 178 $TESTTMP/hgrc:3: ui.fallbackencoding=ASCII
179 179 $TESTTMP/hgrc:4: ui.quiet=true
180 180 $TESTTMP/hgrc:5: ui.slash=true
181 181 $TESTTMP/hgrc:6: ui.traceback=true
182 182 $TESTTMP/hgrc:7: ui.verbose=true
183 183 $TESTTMP/hgrc:8: ui.style=~/.hgstyle
184 184 $TESTTMP/hgrc:9: ui.logtemplate={node}
185 185
186 186 plain hgrc
187 187
188 188 $ HGPLAIN=; export HGPLAIN
189 189 $ hg showconfig --config ui.traceback=True --debug
190 190 read config from: $TESTTMP/hgrc
191 191 repo: bundle.mainreporoot=$TESTTMP
192 192 --config: ui.traceback=True
193 193 --verbose: ui.verbose=False
194 194 --debug: ui.debug=True
195 195 --quiet: ui.quiet=False
196 196
197 197 with environment variables
198 198
199 199 $ PAGER=p1 EDITOR=e1 VISUAL=e2 hg showconfig --debug
200 200 read config from: $TESTTMP/hgrc
201 201 repo: bundle.mainreporoot=$TESTTMP
202 202 $PAGER: pager.pager=p1
203 203 $VISUAL: ui.editor=e2
204 204 --verbose: ui.verbose=False
205 205 --debug: ui.debug=True
206 206 --quiet: ui.quiet=False
207 207
208 208 plain mode with exceptions
209 209
210 210 $ cat > plain.py <<EOF
211 211 > from mercurial import commands, extensions
212 212 > def _config(orig, ui, repo, *values, **opts):
213 213 > ui.write(b'plain: %r\n' % ui.plain())
214 214 > return orig(ui, repo, *values, **opts)
215 215 > def uisetup(ui):
216 216 > extensions.wrapcommand(commands.table, b'config', _config)
217 217 > EOF
218 218 $ echo "[extensions]" >> $HGRC
219 219 $ echo "plain=./plain.py" >> $HGRC
220 220 $ HGPLAINEXCEPT=; export HGPLAINEXCEPT
221 221 $ hg showconfig --config ui.traceback=True --debug
222 222 plain: True
223 223 read config from: $TESTTMP/hgrc
224 224 repo: bundle.mainreporoot=$TESTTMP
225 225 $TESTTMP/hgrc:15: extensions.plain=./plain.py
226 226 --config: ui.traceback=True
227 227 --verbose: ui.verbose=False
228 228 --debug: ui.debug=True
229 229 --quiet: ui.quiet=False
230 230 $ unset HGPLAIN
231 231 $ hg showconfig --config ui.traceback=True --debug
232 232 plain: True
233 233 read config from: $TESTTMP/hgrc
234 234 repo: bundle.mainreporoot=$TESTTMP
235 235 $TESTTMP/hgrc:15: extensions.plain=./plain.py
236 236 --config: ui.traceback=True
237 237 --verbose: ui.verbose=False
238 238 --debug: ui.debug=True
239 239 --quiet: ui.quiet=False
240 240 $ HGPLAINEXCEPT=i18n; export HGPLAINEXCEPT
241 241 $ hg showconfig --config ui.traceback=True --debug
242 242 plain: True
243 243 read config from: $TESTTMP/hgrc
244 244 repo: bundle.mainreporoot=$TESTTMP
245 245 $TESTTMP/hgrc:15: extensions.plain=./plain.py
246 246 --config: ui.traceback=True
247 247 --verbose: ui.verbose=False
248 248 --debug: ui.debug=True
249 249 --quiet: ui.quiet=False
250 250
251 251 source of paths is not mangled
252 252
253 253 $ cat >> $HGRCPATH <<EOF
254 254 > [paths]
255 255 > foo = bar
256 256 > EOF
257 257 $ hg showconfig --debug paths
258 258 plain: True
259 259 read config from: $TESTTMP/hgrc
260 260 $TESTTMP/hgrc:17: paths.foo=$TESTTMP/bar
261 261
262 262 Test we can skip the user configuration
263 263
264 264 $ cat >> .hg/hgrc <<EOF
265 265 > [paths]
266 266 > elephant = babar
267 267 > EOF
268 268 $ hg path
269 269 elephant = $TESTTMP/babar
270 270 foo = $TESTTMP/bar
271 271 $ HGRCSKIPREPO=1 hg path
272 272 foo = $TESTTMP/bar
273 273
274 274 $ cat >> .hg/hgrc <<EOF
275 275 > [broken
276 276 > EOF
277 277
278 278 $ hg path
279 279 hg: parse error at $TESTTMP/.hg/hgrc:3: [broken
280 280 [255]
281 281 $ HGRCSKIPREPO=1 hg path
282 282 foo = $TESTTMP/bar
283 283
284 284 Check that hgweb respect HGRCSKIPREPO=1
285 285
286 286 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
287 287 hg: parse error at $TESTTMP/.hg/hgrc:3: [broken
288 288 [255]
289 289 $ test -f hg.pid && (cat hg.pid >> $DAEMON_PIDS)
290 290 [1]
291 291 $ killdaemons.py
292 292 $ test -f access.log && cat access.log
293 293 [1]
294 294 $ test -f errors.log && cat errors.log
295 295 [1]
296 296
297 297 $ HGRCSKIPREPO=1 hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
298 298 $ cat hg.pid >> $DAEMON_PIDS
299 299 $ killdaemons.py
300 300 $ cat access.log
301 301 $ cat errors.log
302 302
303 303 Check that zeroconf respect HGRCSKIPREPO=1
304 304
305 305 $ hg paths --config extensions.zeroconf=
306 306 hg: parse error at $TESTTMP/.hg/hgrc:3: [broken
307 307 [255]
308 308 $ HGRCSKIPREPO=1 hg paths --config extensions.zeroconf=
309 309 foo = $TESTTMP/bar
General Comments 0
You need to be logged in to leave comments. Login now