Show More
@@ -2463,7 +2463,7 b' def serve(ui, repo, **opts):' | |||
|
2463 | 2463 | " accesslog errorlog webdir_conf") |
|
2464 | 2464 | for o in optlist.split(): |
|
2465 | 2465 | if opts[o]: |
|
2466 | ui.setconfig("web", o, opts[o]) | |
|
2466 | ui.setconfig("web", o, str(opts[o])) | |
|
2467 | 2467 | |
|
2468 | 2468 | if repo is None and not ui.config("web", "webdir_conf"): |
|
2469 | 2469 | raise hg.RepoError(_("There is no Mercurial repository here" |
@@ -10,10 +10,22 b' from demandload import *' | |||
|
10 | 10 | demandload(globals(), "errno getpass os re socket sys tempfile") |
|
11 | 11 | demandload(globals(), "ConfigParser mdiff templater traceback util") |
|
12 | 12 | |
|
13 | def dupconfig(orig): | |
|
14 | new = ConfigParser.SafeConfigParser(orig.defaults()) | |
|
15 | updateconfig(orig, new) | |
|
16 | return new | |
|
17 | ||
|
18 | def updateconfig(source, dest): | |
|
19 | for section in source.sections(): | |
|
20 | if not dest.has_section(section): | |
|
21 | dest.add_section(section) | |
|
22 | for name, value in source.items(section, raw=True): | |
|
23 | dest.set(section, name, value) | |
|
24 | ||
|
13 | 25 | class ui(object): |
|
14 | 26 | def __init__(self, verbose=False, debug=False, quiet=False, |
|
15 | 27 | interactive=True, traceback=False, parentui=None): |
|
16 |
self.overlay = |
|
|
28 | self.overlay = None | |
|
17 | 29 | self.header = [] |
|
18 | 30 | self.prev_header = [] |
|
19 | 31 | if parentui is None: |
@@ -34,13 +46,9 b' class ui(object):' | |||
|
34 | 46 | # parentui may point to an ui object which is already a child |
|
35 | 47 | self.parentui = parentui.parentui or parentui |
|
36 | 48 | self.readhooks = self.parentui.readhooks[:] |
|
37 |
|
|
|
38 | self.cdata = ConfigParser.SafeConfigParser(parent_cdata.defaults()) | |
|
39 | # make interpolation work | |
|
40 | for section in parent_cdata.sections(): | |
|
41 | self.cdata.add_section(section) | |
|
42 | for name, value in parent_cdata.items(section, raw=True): | |
|
43 | self.cdata.set(section, name, value) | |
|
49 | self.cdata = dupconfig(self.parentui.cdata) | |
|
50 | if self.parentui.overlay: | |
|
51 | self.overlay = dupconfig(self.parentui.overlay) | |
|
44 | 52 | |
|
45 | 53 | def __getattr__(self, key): |
|
46 | 54 | return getattr(self.parentui, key) |
@@ -78,18 +86,24 b' class ui(object):' | |||
|
78 | 86 | for name, path in self.configitems("paths"): |
|
79 | 87 | if path and "://" not in path and not os.path.isabs(path): |
|
80 | 88 | self.cdata.set("paths", name, os.path.join(root, path)) |
|
89 | # override data from config files with data set with ui.setconfig | |
|
90 | if self.overlay: | |
|
91 | updateconfig(self.overlay, self.cdata) | |
|
81 | 92 | for hook in self.readhooks: |
|
82 | 93 | hook(self) |
|
83 | 94 | |
|
84 | 95 | def addreadhook(self, hook): |
|
85 | 96 | self.readhooks.append(hook) |
|
86 | 97 | |
|
87 | def setconfig(self, section, name, val): | |
|
88 | self.overlay[(section, name)] = val | |
|
98 | def setconfig(self, section, name, value): | |
|
99 | if not self.overlay: | |
|
100 | self.overlay = ConfigParser.SafeConfigParser() | |
|
101 | for cdata in (self.overlay, self.cdata): | |
|
102 | if not cdata.has_section(section): | |
|
103 | cdata.add_section(section) | |
|
104 | cdata.set(section, name, value) | |
|
89 | 105 | |
|
90 | 106 | def _config(self, section, name, default, funcname): |
|
91 | if self.overlay.has_key((section, name)): | |
|
92 | return self.overlay[(section, name)] | |
|
93 | 107 | if self.cdata.has_option(section, name): |
|
94 | 108 | try: |
|
95 | 109 | func = getattr(self.cdata, funcname) |
@@ -132,17 +146,11 b' class ui(object):' | |||
|
132 | 146 | return x |
|
133 | 147 | |
|
134 | 148 | def walkconfig(self): |
|
135 | seen = {} | |
|
136 | for (section, name), value in self.overlay.iteritems(): | |
|
137 | yield section, name, value | |
|
138 | seen[section, name] = 1 | |
|
139 | 149 | sections = self.cdata.sections() |
|
140 | 150 | sections.sort() |
|
141 | 151 | for section in sections: |
|
142 | 152 | for name, value in self.configitems(section): |
|
143 | if (section, name) in seen: continue | |
|
144 | 153 | yield section, name, value.replace('\n', '\\n') |
|
145 | seen[section, name] = 1 | |
|
146 | 154 | |
|
147 | 155 | def extensions(self): |
|
148 | 156 | result = self.configitems("extensions") |
General Comments 0
You need to be logged in to leave comments.
Login now