Show More
@@ -44,6 +44,7 b' 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 | if data: |
|
48 | if data: | |
48 | for k in data._data: |
|
49 | for k in data._data: | |
49 | self._data[k] = data[k].copy() |
|
50 | self._data[k] = data[k].copy() | |
@@ -58,6 +59,10 b' class config(object):' | |||||
58 | for d in self.sections(): |
|
59 | for d in self.sections(): | |
59 | yield d |
|
60 | yield d | |
60 | def update(self, src): |
|
61 | def update(self, src): | |
|
62 | for s, n in src._unset: | |||
|
63 | if s in self and n in self._data[s]: | |||
|
64 | del self._data[s][n] | |||
|
65 | del self._source[(s, n)] | |||
61 | for s in src: |
|
66 | for s in src: | |
62 | if s not in self: |
|
67 | if s not in self: | |
63 | self._data[s] = sortdict() |
|
68 | self._data[s] = sortdict() | |
@@ -173,6 +178,7 b' class config(object):' | |||||
173 | continue |
|
178 | continue | |
174 | if self.get(section, name) is not None: |
|
179 | if self.get(section, name) is not None: | |
175 | del self._data[section][name] |
|
180 | del self._data[section][name] | |
|
181 | self._unset.append((section, name)) | |||
176 | continue |
|
182 | continue | |
177 |
|
183 | |||
178 | raise error.ParseError(l.rstrip(), ("%s:%s" % (src, line))) |
|
184 | raise error.ParseError(l.rstrip(), ("%s:%s" % (src, line))) |
@@ -11,3 +11,34 b' Test case sensitive configuration' | |||||
11 | Section.KeY=Case Sensitive |
|
11 | Section.KeY=Case Sensitive | |
12 | Section.key=lower case |
|
12 | Section.key=lower case | |
13 |
|
13 | |||
|
14 | Test "%unset" | |||
|
15 | ||||
|
16 | $ cat >> $HGRCPATH <<EOF | |||
|
17 | > [unsettest] | |||
|
18 | > local-hgrcpath = should be unset (HGRCPATH) | |||
|
19 | > %unset local-hgrcpath | |||
|
20 | > | |||
|
21 | > global = should be unset (HGRCPATH) | |||
|
22 | > | |||
|
23 | > both = should be unset (HGRCPATH) | |||
|
24 | > | |||
|
25 | > set-after-unset = should be unset (HGRCPATH) | |||
|
26 | > EOF | |||
|
27 | ||||
|
28 | $ cat >> .hg/hgrc <<EOF | |||
|
29 | > [unsettest] | |||
|
30 | > local-hgrc = should be unset (.hg/hgrc) | |||
|
31 | > %unset local-hgrc | |||
|
32 | > | |||
|
33 | > %unset global | |||
|
34 | > | |||
|
35 | > both = should be unset (.hg/hgrc) | |||
|
36 | > %unset both | |||
|
37 | > | |||
|
38 | > set-after-unset = should be unset (.hg/hgrc) | |||
|
39 | > %unset set-after-unset | |||
|
40 | > set-after-unset = should be set (.hg/hgrc) | |||
|
41 | > EOF | |||
|
42 | ||||
|
43 | $ hg showconfig unsettest | |||
|
44 | unsettest.set-after-unset=should be set (.hg/hgrc) |
General Comments 0
You need to be logged in to leave comments.
Login now