Show More
@@ -1,189 +1,190 b'' | |||||
1 | # config.py - configuration parsing for Mercurial |
|
1 | # config.py - configuration parsing for Mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2009 Matt Mackall <mpm@selenic.com> and others |
|
3 | # Copyright 2009 Matt Mackall <mpm@selenic.com> and others | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 | import error, util |
|
9 | import error, util | |
10 | import os, errno |
|
10 | import os, errno | |
11 |
|
11 | |||
12 | class sortdict(dict): |
|
12 | class sortdict(dict): | |
13 | 'a simple sorted dictionary' |
|
13 | 'a simple sorted dictionary' | |
14 | def __init__(self, data=None): |
|
14 | def __init__(self, data=None): | |
15 | self._list = [] |
|
15 | self._list = [] | |
16 | if data: |
|
16 | if data: | |
17 | self.update(data) |
|
17 | self.update(data) | |
18 | def copy(self): |
|
18 | def copy(self): | |
19 | return sortdict(self) |
|
19 | return sortdict(self) | |
20 | def __setitem__(self, key, val): |
|
20 | def __setitem__(self, key, val): | |
21 | if key in self: |
|
21 | if key in self: | |
22 | self._list.remove(key) |
|
22 | self._list.remove(key) | |
23 | self._list.append(key) |
|
23 | self._list.append(key) | |
24 | dict.__setitem__(self, key, val) |
|
24 | dict.__setitem__(self, key, val) | |
25 | def __iter__(self): |
|
25 | def __iter__(self): | |
26 | return self._list.__iter__() |
|
26 | return self._list.__iter__() | |
27 | def update(self, src): |
|
27 | def update(self, src): | |
28 | for k in src: |
|
28 | for k in src: | |
29 | self[k] = src[k] |
|
29 | self[k] = src[k] | |
30 | def clear(self): |
|
30 | def clear(self): | |
31 | dict.clear(self) |
|
31 | dict.clear(self) | |
32 | self._list = [] |
|
32 | self._list = [] | |
33 | def items(self): |
|
33 | def items(self): | |
34 | return [(k, self[k]) for k in self._list] |
|
34 | return [(k, self[k]) for k in self._list] | |
35 | def __delitem__(self, key): |
|
35 | def __delitem__(self, key): | |
36 | dict.__delitem__(self, key) |
|
36 | dict.__delitem__(self, key) | |
37 | self._list.remove(key) |
|
37 | self._list.remove(key) | |
38 | def keys(self): |
|
38 | def keys(self): | |
39 | return self._list |
|
39 | return self._list | |
40 | def iterkeys(self): |
|
40 | def iterkeys(self): | |
41 | return self._list.__iter__() |
|
41 | return self._list.__iter__() | |
42 |
|
42 | |||
43 | class config(object): |
|
43 | class config(object): | |
44 | def __init__(self, data=None): |
|
44 | def __init__(self, data=None): | |
45 | self._data = {} |
|
45 | self._data = {} | |
46 | self._source = {} |
|
46 | self._source = {} | |
47 | self._unset = [] |
|
47 | self._unset = [] | |
48 | if data: |
|
48 | if data: | |
49 | for k in data._data: |
|
49 | for k in data._data: | |
50 | self._data[k] = data[k].copy() |
|
50 | self._data[k] = data[k].copy() | |
51 | self._source = data._source.copy() |
|
51 | self._source = data._source.copy() | |
52 | def copy(self): |
|
52 | def copy(self): | |
53 | return config(self) |
|
53 | return config(self) | |
54 | def __contains__(self, section): |
|
54 | def __contains__(self, section): | |
55 | return section in self._data |
|
55 | return section in self._data | |
56 | def __getitem__(self, section): |
|
56 | def __getitem__(self, section): | |
57 | return self._data.get(section, {}) |
|
57 | return self._data.get(section, {}) | |
58 | def __iter__(self): |
|
58 | def __iter__(self): | |
59 | for d in self.sections(): |
|
59 | for d in self.sections(): | |
60 | yield d |
|
60 | yield d | |
61 | def update(self, src): |
|
61 | def update(self, src): | |
62 | for s, n in src._unset: |
|
62 | for s, n in src._unset: | |
63 | if s in self and n in self._data[s]: |
|
63 | if s in self and n in self._data[s]: | |
64 | del self._data[s][n] |
|
64 | del self._data[s][n] | |
65 | del self._source[(s, n)] |
|
65 | del self._source[(s, n)] | |
66 | for s in src: |
|
66 | for s in src: | |
67 | if s not in self: |
|
67 | if s not in self: | |
68 | self._data[s] = sortdict() |
|
68 | self._data[s] = sortdict() | |
69 | self._data[s].update(src._data[s]) |
|
69 | self._data[s].update(src._data[s]) | |
70 | self._source.update(src._source) |
|
70 | self._source.update(src._source) | |
71 | def get(self, section, item, default=None): |
|
71 | def get(self, section, item, default=None): | |
72 | return self._data.get(section, {}).get(item, default) |
|
72 | return self._data.get(section, {}).get(item, default) | |
73 |
|
73 | |||
74 | def backup(self, section, item): |
|
74 | def backup(self, section, item): | |
75 | """return a tuple allowing restore to reinstall a previous value |
|
75 | """return a tuple allowing restore to reinstall a previous value | |
76 |
|
76 | |||
77 | The main reason we need it is because it handles the "no data" case. |
|
77 | The main reason we need it is because it handles the "no data" case. | |
78 | """ |
|
78 | """ | |
79 | try: |
|
79 | try: | |
80 | value = self._data[section][item] |
|
80 | value = self._data[section][item] | |
81 | source = self.source(section, item) |
|
81 | source = self.source(section, item) | |
82 | return (section, item, value, source) |
|
82 | return (section, item, value, source) | |
83 | except KeyError: |
|
83 | except KeyError: | |
84 | return (section, item) |
|
84 | return (section, item) | |
85 |
|
85 | |||
86 | def source(self, section, item): |
|
86 | def source(self, section, item): | |
87 | return self._source.get((section, item), "") |
|
87 | return self._source.get((section, item), "") | |
88 | def sections(self): |
|
88 | def sections(self): | |
89 | return sorted(self._data.keys()) |
|
89 | return sorted(self._data.keys()) | |
90 | def items(self, section): |
|
90 | def items(self, section): | |
91 | return self._data.get(section, {}).items() |
|
91 | return self._data.get(section, {}).items() | |
92 | def set(self, section, item, value, source=""): |
|
92 | def set(self, section, item, value, source=""): | |
93 | if section not in self: |
|
93 | if section not in self: | |
94 | self._data[section] = sortdict() |
|
94 | self._data[section] = sortdict() | |
95 | self._data[section][item] = value |
|
95 | self._data[section][item] = value | |
96 | self._source[(section, item)] = source |
|
96 | if source: | |
|
97 | self._source[(section, item)] = source | |||
97 |
|
98 | |||
98 | def restore(self, data): |
|
99 | def restore(self, data): | |
99 | """restore data returned by self.backup""" |
|
100 | """restore data returned by self.backup""" | |
100 | if len(data) == 4: |
|
101 | if len(data) == 4: | |
101 | # restore old data |
|
102 | # restore old data | |
102 | section, item, value, source = data |
|
103 | section, item, value, source = data | |
103 | self._data[section][item] = value |
|
104 | self._data[section][item] = value | |
104 | self._source[(section, item)] = source |
|
105 | self._source[(section, item)] = source | |
105 | else: |
|
106 | else: | |
106 | # no data before, remove everything |
|
107 | # no data before, remove everything | |
107 | section, item = data |
|
108 | section, item = data | |
108 | if section in self._data: |
|
109 | if section in self._data: | |
109 | del self._data[section][item] |
|
110 | del self._data[section][item] | |
110 | self._source.pop((section, item), None) |
|
111 | self._source.pop((section, item), None) | |
111 |
|
112 | |||
112 | def parse(self, src, data, sections=None, remap=None, include=None): |
|
113 | def parse(self, src, data, sections=None, remap=None, include=None): | |
113 | sectionre = util.compilere(r'\[([^\[]+)\]') |
|
114 | sectionre = util.compilere(r'\[([^\[]+)\]') | |
114 | itemre = util.compilere(r'([^=\s][^=]*?)\s*=\s*(.*\S|)') |
|
115 | itemre = util.compilere(r'([^=\s][^=]*?)\s*=\s*(.*\S|)') | |
115 | contre = util.compilere(r'\s+(\S|\S.*\S)\s*$') |
|
116 | contre = util.compilere(r'\s+(\S|\S.*\S)\s*$') | |
116 | emptyre = util.compilere(r'(;|#|\s*$)') |
|
117 | emptyre = util.compilere(r'(;|#|\s*$)') | |
117 | commentre = util.compilere(r'(;|#)') |
|
118 | commentre = util.compilere(r'(;|#)') | |
118 | unsetre = util.compilere(r'%unset\s+(\S+)') |
|
119 | unsetre = util.compilere(r'%unset\s+(\S+)') | |
119 | includere = util.compilere(r'%include\s+(\S|\S.*\S)\s*$') |
|
120 | includere = util.compilere(r'%include\s+(\S|\S.*\S)\s*$') | |
120 | section = "" |
|
121 | section = "" | |
121 | item = None |
|
122 | item = None | |
122 | line = 0 |
|
123 | line = 0 | |
123 | cont = False |
|
124 | cont = False | |
124 |
|
125 | |||
125 | for l in data.splitlines(True): |
|
126 | for l in data.splitlines(True): | |
126 | line += 1 |
|
127 | line += 1 | |
127 | if line == 1 and l.startswith('\xef\xbb\xbf'): |
|
128 | if line == 1 and l.startswith('\xef\xbb\xbf'): | |
128 | # Someone set us up the BOM |
|
129 | # Someone set us up the BOM | |
129 | l = l[3:] |
|
130 | l = l[3:] | |
130 | if cont: |
|
131 | if cont: | |
131 | if commentre.match(l): |
|
132 | if commentre.match(l): | |
132 | continue |
|
133 | continue | |
133 | m = contre.match(l) |
|
134 | m = contre.match(l) | |
134 | if m: |
|
135 | if m: | |
135 | if sections and section not in sections: |
|
136 | if sections and section not in sections: | |
136 | continue |
|
137 | continue | |
137 | v = self.get(section, item) + "\n" + m.group(1) |
|
138 | v = self.get(section, item) + "\n" + m.group(1) | |
138 | self.set(section, item, v, "%s:%d" % (src, line)) |
|
139 | self.set(section, item, v, "%s:%d" % (src, line)) | |
139 | continue |
|
140 | continue | |
140 | item = None |
|
141 | item = None | |
141 | cont = False |
|
142 | cont = False | |
142 | m = includere.match(l) |
|
143 | m = includere.match(l) | |
143 | if m: |
|
144 | if m: | |
144 | inc = util.expandpath(m.group(1)) |
|
145 | inc = util.expandpath(m.group(1)) | |
145 | base = os.path.dirname(src) |
|
146 | base = os.path.dirname(src) | |
146 | inc = os.path.normpath(os.path.join(base, inc)) |
|
147 | inc = os.path.normpath(os.path.join(base, inc)) | |
147 | if include: |
|
148 | if include: | |
148 | try: |
|
149 | try: | |
149 | include(inc, remap=remap, sections=sections) |
|
150 | include(inc, remap=remap, sections=sections) | |
150 | except IOError, inst: |
|
151 | except IOError, inst: | |
151 | if inst.errno != errno.ENOENT: |
|
152 | if inst.errno != errno.ENOENT: | |
152 | raise error.ParseError(_("cannot include %s (%s)") |
|
153 | raise error.ParseError(_("cannot include %s (%s)") | |
153 | % (inc, inst.strerror), |
|
154 | % (inc, inst.strerror), | |
154 | "%s:%s" % (src, line)) |
|
155 | "%s:%s" % (src, line)) | |
155 | continue |
|
156 | continue | |
156 | if emptyre.match(l): |
|
157 | if emptyre.match(l): | |
157 | continue |
|
158 | continue | |
158 | m = sectionre.match(l) |
|
159 | m = sectionre.match(l) | |
159 | if m: |
|
160 | if m: | |
160 | section = m.group(1) |
|
161 | section = m.group(1) | |
161 | if remap: |
|
162 | if remap: | |
162 | section = remap.get(section, section) |
|
163 | section = remap.get(section, section) | |
163 | if section not in self: |
|
164 | if section not in self: | |
164 | self._data[section] = sortdict() |
|
165 | self._data[section] = sortdict() | |
165 | continue |
|
166 | continue | |
166 | m = itemre.match(l) |
|
167 | m = itemre.match(l) | |
167 | if m: |
|
168 | if m: | |
168 | item = m.group(1) |
|
169 | item = m.group(1) | |
169 | cont = True |
|
170 | cont = True | |
170 | if sections and section not in sections: |
|
171 | if sections and section not in sections: | |
171 | continue |
|
172 | continue | |
172 | self.set(section, item, m.group(2), "%s:%d" % (src, line)) |
|
173 | self.set(section, item, m.group(2), "%s:%d" % (src, line)) | |
173 | continue |
|
174 | continue | |
174 | m = unsetre.match(l) |
|
175 | m = unsetre.match(l) | |
175 | if m: |
|
176 | if m: | |
176 | name = m.group(1) |
|
177 | name = m.group(1) | |
177 | if sections and section not in sections: |
|
178 | if sections and section not in sections: | |
178 | continue |
|
179 | continue | |
179 | if self.get(section, name) is not None: |
|
180 | if self.get(section, name) is not None: | |
180 | del self._data[section][name] |
|
181 | del self._data[section][name] | |
181 | self._unset.append((section, name)) |
|
182 | self._unset.append((section, name)) | |
182 | continue |
|
183 | continue | |
183 |
|
184 | |||
184 | raise error.ParseError(l.rstrip(), ("%s:%s" % (src, line))) |
|
185 | raise error.ParseError(l.rstrip(), ("%s:%s" % (src, line))) | |
185 |
|
186 | |||
186 | def read(self, path, fp=None, sections=None, remap=None): |
|
187 | def read(self, path, fp=None, sections=None, remap=None): | |
187 | if not fp: |
|
188 | if not fp: | |
188 | fp = util.posixfile(path) |
|
189 | fp = util.posixfile(path) | |
189 | self.parse(path, fp.read(), sections, remap, self.read) |
|
190 | self.parse(path, fp.read(), sections, remap, self.read) |
@@ -1,203 +1,214 b'' | |||||
1 | hide outer repo |
|
1 | hide outer repo | |
2 | $ hg init |
|
2 | $ hg init | |
3 |
|
3 | |||
4 | Use hgrc within $TESTTMP |
|
4 | Use hgrc within $TESTTMP | |
5 |
|
5 | |||
6 | $ HGRCPATH=`pwd`/hgrc |
|
6 | $ HGRCPATH=`pwd`/hgrc | |
7 | $ export HGRCPATH |
|
7 | $ export HGRCPATH | |
8 |
|
8 | |||
9 | Use an alternate var for scribbling on hgrc to keep check-code from |
|
9 | Use an alternate var for scribbling on hgrc to keep check-code from | |
10 | complaining about the important settings we may be overwriting: |
|
10 | complaining about the important settings we may be overwriting: | |
11 |
|
11 | |||
12 | $ HGRC=`pwd`/hgrc |
|
12 | $ HGRC=`pwd`/hgrc | |
13 | $ export HGRC |
|
13 | $ export HGRC | |
14 |
|
14 | |||
15 | Basic syntax error |
|
15 | Basic syntax error | |
16 |
|
16 | |||
17 | $ echo "invalid" > $HGRC |
|
17 | $ echo "invalid" > $HGRC | |
18 | $ hg version |
|
18 | $ hg version | |
19 | hg: parse error at $TESTTMP/hgrc:1: invalid |
|
19 | hg: parse error at $TESTTMP/hgrc:1: invalid | |
20 | [255] |
|
20 | [255] | |
21 | $ echo "" > $HGRC |
|
21 | $ echo "" > $HGRC | |
22 |
|
22 | |||
23 | Issue1199: Can't use '%' in hgrc (eg url encoded username) |
|
23 | Issue1199: Can't use '%' in hgrc (eg url encoded username) | |
24 |
|
24 | |||
25 | $ hg init "foo%bar" |
|
25 | $ hg init "foo%bar" | |
26 | $ hg clone "foo%bar" foobar |
|
26 | $ hg clone "foo%bar" foobar | |
27 | updating to branch default |
|
27 | updating to branch default | |
28 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
28 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
29 | $ cd foobar |
|
29 | $ cd foobar | |
30 | $ cat .hg/hgrc |
|
30 | $ cat .hg/hgrc | |
31 | [paths] |
|
31 | [paths] | |
32 | default = $TESTTMP/foo%bar (glob) |
|
32 | default = $TESTTMP/foo%bar (glob) | |
33 | $ hg paths |
|
33 | $ hg paths | |
34 | default = $TESTTMP/foo%bar (glob) |
|
34 | default = $TESTTMP/foo%bar (glob) | |
35 | $ hg showconfig |
|
35 | $ hg showconfig | |
36 | bundle.mainreporoot=$TESTTMP/foobar (glob) |
|
36 | bundle.mainreporoot=$TESTTMP/foobar (glob) | |
37 | paths.default=$TESTTMP/foo%bar (glob) |
|
37 | paths.default=$TESTTMP/foo%bar (glob) | |
38 | $ cd .. |
|
38 | $ cd .. | |
39 |
|
39 | |||
40 | issue1829: wrong indentation |
|
40 | issue1829: wrong indentation | |
41 |
|
41 | |||
42 | $ echo '[foo]' > $HGRC |
|
42 | $ echo '[foo]' > $HGRC | |
43 | $ echo ' x = y' >> $HGRC |
|
43 | $ echo ' x = y' >> $HGRC | |
44 | $ hg version |
|
44 | $ hg version | |
45 | hg: parse error at $TESTTMP/hgrc:2: x = y |
|
45 | hg: parse error at $TESTTMP/hgrc:2: x = y | |
46 | [255] |
|
46 | [255] | |
47 |
|
47 | |||
48 | $ python -c "print '[foo]\nbar = a\n b\n c \n de\n fg \nbaz = bif cb \n'" \ |
|
48 | $ python -c "print '[foo]\nbar = a\n b\n c \n de\n fg \nbaz = bif cb \n'" \ | |
49 | > > $HGRC |
|
49 | > > $HGRC | |
50 | $ hg showconfig foo |
|
50 | $ hg showconfig foo | |
51 | foo.bar=a\nb\nc\nde\nfg |
|
51 | foo.bar=a\nb\nc\nde\nfg | |
52 | foo.baz=bif cb |
|
52 | foo.baz=bif cb | |
53 |
|
53 | |||
54 | $ FAKEPATH=/path/to/nowhere |
|
54 | $ FAKEPATH=/path/to/nowhere | |
55 | $ export FAKEPATH |
|
55 | $ export FAKEPATH | |
56 | $ echo '%include $FAKEPATH/no-such-file' > $HGRC |
|
56 | $ echo '%include $FAKEPATH/no-such-file' > $HGRC | |
57 | $ hg version |
|
57 | $ hg version | |
58 | Mercurial Distributed SCM (version *) (glob) |
|
58 | Mercurial Distributed SCM (version *) (glob) | |
59 | (see http://mercurial.selenic.com for more information) |
|
59 | (see http://mercurial.selenic.com for more information) | |
60 |
|
60 | |||
61 | Copyright (C) 2005-2014 Matt Mackall and others |
|
61 | Copyright (C) 2005-2014 Matt Mackall and others | |
62 | This is free software; see the source for copying conditions. There is NO |
|
62 | This is free software; see the source for copying conditions. There is NO | |
63 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
63 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
64 | $ unset FAKEPATH |
|
64 | $ unset FAKEPATH | |
65 |
|
65 | |||
66 | make sure global options given on the cmdline take precedence |
|
66 | make sure global options given on the cmdline take precedence | |
67 |
|
67 | |||
68 | $ hg showconfig --config ui.verbose=True --quiet |
|
68 | $ hg showconfig --config ui.verbose=True --quiet | |
69 | bundle.mainreporoot=$TESTTMP |
|
69 | bundle.mainreporoot=$TESTTMP | |
70 | ui.verbose=False |
|
70 | ui.verbose=False | |
71 | ui.debug=False |
|
71 | ui.debug=False | |
72 | ui.quiet=True |
|
72 | ui.quiet=True | |
73 |
|
73 | |||
74 | $ touch foobar/untracked |
|
74 | $ touch foobar/untracked | |
75 | $ cat >> foobar/.hg/hgrc <<EOF |
|
75 | $ cat >> foobar/.hg/hgrc <<EOF | |
76 | > [ui] |
|
76 | > [ui] | |
77 | > verbose=True |
|
77 | > verbose=True | |
78 | > EOF |
|
78 | > EOF | |
79 | $ hg -R foobar st -q |
|
79 | $ hg -R foobar st -q | |
80 |
|
80 | |||
81 | username expansion |
|
81 | username expansion | |
82 |
|
82 | |||
83 | $ olduser=$HGUSER |
|
83 | $ olduser=$HGUSER | |
84 | $ unset HGUSER |
|
84 | $ unset HGUSER | |
85 |
|
85 | |||
86 | $ FAKEUSER='John Doe' |
|
86 | $ FAKEUSER='John Doe' | |
87 | $ export FAKEUSER |
|
87 | $ export FAKEUSER | |
88 | $ echo '[ui]' > $HGRC |
|
88 | $ echo '[ui]' > $HGRC | |
89 | $ echo 'username = $FAKEUSER' >> $HGRC |
|
89 | $ echo 'username = $FAKEUSER' >> $HGRC | |
90 |
|
90 | |||
91 | $ hg init usertest |
|
91 | $ hg init usertest | |
92 | $ cd usertest |
|
92 | $ cd usertest | |
93 | $ touch bar |
|
93 | $ touch bar | |
94 | $ hg commit --addremove --quiet -m "added bar" |
|
94 | $ hg commit --addremove --quiet -m "added bar" | |
95 | $ hg log --template "{author}\n" |
|
95 | $ hg log --template "{author}\n" | |
96 | John Doe |
|
96 | John Doe | |
97 | $ cd .. |
|
97 | $ cd .. | |
98 |
|
98 | |||
99 | $ hg showconfig |
|
99 | $ hg showconfig | |
100 | bundle.mainreporoot=$TESTTMP |
|
100 | bundle.mainreporoot=$TESTTMP | |
101 | ui.username=$FAKEUSER |
|
101 | ui.username=$FAKEUSER | |
102 |
|
102 | |||
103 | $ unset FAKEUSER |
|
103 | $ unset FAKEUSER | |
104 | $ HGUSER=$olduser |
|
104 | $ HGUSER=$olduser | |
105 | $ export HGUSER |
|
105 | $ export HGUSER | |
106 |
|
106 | |||
107 | showconfig with multiple arguments |
|
107 | showconfig with multiple arguments | |
108 |
|
108 | |||
109 | $ echo "[alias]" > $HGRC |
|
109 | $ echo "[alias]" > $HGRC | |
110 | $ echo "log = log -g" >> $HGRC |
|
110 | $ echo "log = log -g" >> $HGRC | |
111 | $ echo "[defaults]" >> $HGRC |
|
111 | $ echo "[defaults]" >> $HGRC | |
112 | $ echo "identify = -n" >> $HGRC |
|
112 | $ echo "identify = -n" >> $HGRC | |
113 | $ hg showconfig alias defaults |
|
113 | $ hg showconfig alias defaults | |
114 | alias.log=log -g |
|
114 | alias.log=log -g | |
115 | defaults.identify=-n |
|
115 | defaults.identify=-n | |
116 | $ hg showconfig alias defaults.identify |
|
116 | $ hg showconfig alias defaults.identify | |
117 | abort: only one config item permitted |
|
117 | abort: only one config item permitted | |
118 | [255] |
|
118 | [255] | |
119 | $ hg showconfig alias.log defaults.identify |
|
119 | $ hg showconfig alias.log defaults.identify | |
120 | abort: only one config item permitted |
|
120 | abort: only one config item permitted | |
121 | [255] |
|
121 | [255] | |
122 |
|
122 | |||
123 | HGPLAIN |
|
123 | HGPLAIN | |
124 |
|
124 | |||
125 | $ echo "[ui]" > $HGRC |
|
125 | $ echo "[ui]" > $HGRC | |
126 | $ echo "debug=true" >> $HGRC |
|
126 | $ echo "debug=true" >> $HGRC | |
127 | $ echo "fallbackencoding=ASCII" >> $HGRC |
|
127 | $ echo "fallbackencoding=ASCII" >> $HGRC | |
128 | $ echo "quiet=true" >> $HGRC |
|
128 | $ echo "quiet=true" >> $HGRC | |
129 | $ echo "slash=true" >> $HGRC |
|
129 | $ echo "slash=true" >> $HGRC | |
130 | $ echo "traceback=true" >> $HGRC |
|
130 | $ echo "traceback=true" >> $HGRC | |
131 | $ echo "verbose=true" >> $HGRC |
|
131 | $ echo "verbose=true" >> $HGRC | |
132 | $ echo "style=~/.hgstyle" >> $HGRC |
|
132 | $ echo "style=~/.hgstyle" >> $HGRC | |
133 | $ echo "logtemplate={node}" >> $HGRC |
|
133 | $ echo "logtemplate={node}" >> $HGRC | |
134 | $ echo "[defaults]" >> $HGRC |
|
134 | $ echo "[defaults]" >> $HGRC | |
135 | $ echo "identify=-n" >> $HGRC |
|
135 | $ echo "identify=-n" >> $HGRC | |
136 | $ echo "[alias]" >> $HGRC |
|
136 | $ echo "[alias]" >> $HGRC | |
137 | $ echo "log=log -g" >> $HGRC |
|
137 | $ echo "log=log -g" >> $HGRC | |
138 |
|
138 | |||
139 | customized hgrc |
|
139 | customized hgrc | |
140 |
|
140 | |||
141 | $ hg showconfig |
|
141 | $ hg showconfig | |
142 | read config from: $TESTTMP/hgrc |
|
142 | read config from: $TESTTMP/hgrc | |
143 | $TESTTMP/hgrc:13: alias.log=log -g |
|
143 | $TESTTMP/hgrc:13: alias.log=log -g | |
144 | repo: bundle.mainreporoot=$TESTTMP |
|
144 | repo: bundle.mainreporoot=$TESTTMP | |
145 | $TESTTMP/hgrc:11: defaults.identify=-n |
|
145 | $TESTTMP/hgrc:11: defaults.identify=-n | |
146 | $TESTTMP/hgrc:2: ui.debug=true |
|
146 | $TESTTMP/hgrc:2: ui.debug=true | |
147 | $TESTTMP/hgrc:3: ui.fallbackencoding=ASCII |
|
147 | $TESTTMP/hgrc:3: ui.fallbackencoding=ASCII | |
148 | $TESTTMP/hgrc:4: ui.quiet=true |
|
148 | $TESTTMP/hgrc:4: ui.quiet=true | |
149 | $TESTTMP/hgrc:5: ui.slash=true |
|
149 | $TESTTMP/hgrc:5: ui.slash=true | |
150 | $TESTTMP/hgrc:6: ui.traceback=true |
|
150 | $TESTTMP/hgrc:6: ui.traceback=true | |
151 | $TESTTMP/hgrc:7: ui.verbose=true |
|
151 | $TESTTMP/hgrc:7: ui.verbose=true | |
152 | $TESTTMP/hgrc:8: ui.style=~/.hgstyle |
|
152 | $TESTTMP/hgrc:8: ui.style=~/.hgstyle | |
153 | $TESTTMP/hgrc:9: ui.logtemplate={node} |
|
153 | $TESTTMP/hgrc:9: ui.logtemplate={node} | |
154 |
|
154 | |||
155 | plain hgrc |
|
155 | plain hgrc | |
156 |
|
156 | |||
157 | $ HGPLAIN=; export HGPLAIN |
|
157 | $ HGPLAIN=; export HGPLAIN | |
158 | $ hg showconfig --config ui.traceback=True --debug |
|
158 | $ hg showconfig --config ui.traceback=True --debug | |
159 | read config from: $TESTTMP/hgrc |
|
159 | read config from: $TESTTMP/hgrc | |
160 | repo: bundle.mainreporoot=$TESTTMP |
|
160 | repo: bundle.mainreporoot=$TESTTMP | |
161 | --config: ui.traceback=True |
|
161 | --config: ui.traceback=True | |
162 | --verbose: ui.verbose=False |
|
162 | --verbose: ui.verbose=False | |
163 | --debug: ui.debug=True |
|
163 | --debug: ui.debug=True | |
164 | --quiet: ui.quiet=False |
|
164 | --quiet: ui.quiet=False | |
165 |
|
165 | |||
166 | plain mode with exceptions |
|
166 | plain mode with exceptions | |
167 |
|
167 | |||
168 | $ cat > plain.py <<EOF |
|
168 | $ cat > plain.py <<EOF | |
169 | > def uisetup(ui): |
|
169 | > def uisetup(ui): | |
170 | > ui.write('plain: %r\n' % ui.plain()) |
|
170 | > ui.write('plain: %r\n' % ui.plain()) | |
171 | > EOF |
|
171 | > EOF | |
172 | $ echo "[extensions]" >> $HGRC |
|
172 | $ echo "[extensions]" >> $HGRC | |
173 | $ echo "plain=./plain.py" >> $HGRC |
|
173 | $ echo "plain=./plain.py" >> $HGRC | |
174 | $ HGPLAINEXCEPT=; export HGPLAINEXCEPT |
|
174 | $ HGPLAINEXCEPT=; export HGPLAINEXCEPT | |
175 | $ hg showconfig --config ui.traceback=True --debug |
|
175 | $ hg showconfig --config ui.traceback=True --debug | |
176 | plain: True |
|
176 | plain: True | |
177 | read config from: $TESTTMP/hgrc |
|
177 | read config from: $TESTTMP/hgrc | |
178 | repo: bundle.mainreporoot=$TESTTMP |
|
178 | repo: bundle.mainreporoot=$TESTTMP | |
179 | $TESTTMP/hgrc:15: extensions.plain=./plain.py |
|
179 | $TESTTMP/hgrc:15: extensions.plain=./plain.py | |
180 | --config: ui.traceback=True |
|
180 | --config: ui.traceback=True | |
181 | --verbose: ui.verbose=False |
|
181 | --verbose: ui.verbose=False | |
182 | --debug: ui.debug=True |
|
182 | --debug: ui.debug=True | |
183 | --quiet: ui.quiet=False |
|
183 | --quiet: ui.quiet=False | |
184 | $ unset HGPLAIN |
|
184 | $ unset HGPLAIN | |
185 | $ hg showconfig --config ui.traceback=True --debug |
|
185 | $ hg showconfig --config ui.traceback=True --debug | |
186 | plain: True |
|
186 | plain: True | |
187 | read config from: $TESTTMP/hgrc |
|
187 | read config from: $TESTTMP/hgrc | |
188 | repo: bundle.mainreporoot=$TESTTMP |
|
188 | repo: bundle.mainreporoot=$TESTTMP | |
189 | $TESTTMP/hgrc:15: extensions.plain=./plain.py |
|
189 | $TESTTMP/hgrc:15: extensions.plain=./plain.py | |
190 | --config: ui.traceback=True |
|
190 | --config: ui.traceback=True | |
191 | --verbose: ui.verbose=False |
|
191 | --verbose: ui.verbose=False | |
192 | --debug: ui.debug=True |
|
192 | --debug: ui.debug=True | |
193 | --quiet: ui.quiet=False |
|
193 | --quiet: ui.quiet=False | |
194 | $ HGPLAINEXCEPT=i18n; export HGPLAINEXCEPT |
|
194 | $ HGPLAINEXCEPT=i18n; export HGPLAINEXCEPT | |
195 | $ hg showconfig --config ui.traceback=True --debug |
|
195 | $ hg showconfig --config ui.traceback=True --debug | |
196 | plain: True |
|
196 | plain: True | |
197 | read config from: $TESTTMP/hgrc |
|
197 | read config from: $TESTTMP/hgrc | |
198 | repo: bundle.mainreporoot=$TESTTMP |
|
198 | repo: bundle.mainreporoot=$TESTTMP | |
199 | $TESTTMP/hgrc:15: extensions.plain=./plain.py |
|
199 | $TESTTMP/hgrc:15: extensions.plain=./plain.py | |
200 | --config: ui.traceback=True |
|
200 | --config: ui.traceback=True | |
201 | --verbose: ui.verbose=False |
|
201 | --verbose: ui.verbose=False | |
202 | --debug: ui.debug=True |
|
202 | --debug: ui.debug=True | |
203 | --quiet: ui.quiet=False |
|
203 | --quiet: ui.quiet=False | |
|
204 | ||||
|
205 | source of paths is not mangled | |||
|
206 | ||||
|
207 | $ cat >> $HGRCPATH <<EOF | |||
|
208 | > [paths] | |||
|
209 | > foo = bar | |||
|
210 | > EOF | |||
|
211 | $ hg showconfig --debug paths | |||
|
212 | plain: True | |||
|
213 | read config from: $TESTTMP/hgrc | |||
|
214 | $TESTTMP/hgrc:17: paths.foo=$TESTTMP/bar |
General Comments 0
You need to be logged in to leave comments.
Login now