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