##// END OF EJS Templates
add ui.readsections...
Alexis S. L. Carvalho -
r3433:5ee5a0fe default
parent child Browse files
Show More
@@ -15,8 +15,10 b' def dupconfig(orig):'
15 updateconfig(orig, new)
15 updateconfig(orig, new)
16 return new
16 return new
17
17
18 def updateconfig(source, dest):
18 def updateconfig(source, dest, sections=None):
19 for section in source.sections():
19 if not sections:
20 sections = source.sections()
21 for section in sections:
20 if not dest.has_section(section):
22 if not dest.has_section(section):
21 dest.add_section(section)
23 dest.add_section(section)
22 for name, value in source.items(section, raw=True):
24 for name, value in source.items(section, raw=True):
@@ -100,6 +102,23 b' class ui(object):'
100 def addreadhook(self, hook):
102 def addreadhook(self, hook):
101 self.readhooks.append(hook)
103 self.readhooks.append(hook)
102
104
105 def readsections(self, filename, *sections):
106 "read filename and add only the specified sections to the config data"
107 if not sections:
108 return
109
110 cdata = util.configparser()
111 try:
112 cdata.read(filename)
113 except ConfigParser.ParsingError, inst:
114 raise util.Abort(_("failed to parse %s\n%s") % (f, inst))
115
116 for section in sections:
117 if not cdata.has_section(section):
118 cdata.add_section(section)
119
120 updateconfig(cdata, self.cdata, sections)
121
103 def fixconfig(self, section=None, name=None, value=None, root=None):
122 def fixconfig(self, section=None, name=None, value=None, root=None):
104 # translate paths relative to root (or home) into absolute paths
123 # translate paths relative to root (or home) into absolute paths
105 if section is None or section == 'paths':
124 if section is None or section == 'paths':
General Comments 0
You need to be logged in to leave comments. Login now