##// END OF EJS Templates
ui: simplify fixconfig
Matt Mackall -
r8197:d94f17c2 default
parent child Browse files
Show More
@@ -98,47 +98,34 b' class ui(object):'
98 root = os.path.expanduser('~')
98 root = os.path.expanduser('~')
99 self.fixconfig(root=root)
99 self.fixconfig(root=root)
100
100
101 def fixconfig(self, section=None, name=None, value=None, root=None):
101 def fixconfig(self, root=None):
102 # translate paths relative to root (or home) into absolute paths
102 # translate paths relative to root (or home) into absolute paths
103 if section is None or section == 'paths':
103 root = root or os.getcwd()
104 if root is None:
104 for c in self.cdata, self.ucdata, self.overlay:
105 root = os.getcwd()
105 for n, p in c.items('paths'):
106 items = section and [(name, value)] or []
106 if p and "://" not in p and not os.path.isabs(p):
107 for cdata in self.cdata, self.ucdata, self.overlay:
107 c.set("paths", n, os.path.normpath(os.path.join(root, p)))
108 if not items and 'paths' in cdata:
109 pathsitems = cdata.items('paths')
110 else:
111 pathsitems = items
112 for n, path in pathsitems:
113 if path and "://" not in path and not os.path.isabs(path):
114 cdata.set("paths", n,
115 os.path.normpath(os.path.join(root, path)))
116
108
117 # update ui options
109 # update ui options
118 if section is None or section == 'ui':
110 self.debugflag = self.configbool('ui', 'debug')
119 self.debugflag = self.configbool('ui', 'debug')
111 self.verbose = self.debugflag or self.configbool('ui', 'verbose')
120 self.verbose = self.debugflag or self.configbool('ui', 'verbose')
112 self.quiet = not self.debugflag and self.configbool('ui', 'quiet')
121 self.quiet = not self.debugflag and self.configbool('ui', 'quiet')
113 if self.verbose and self.quiet:
122 if self.verbose and self.quiet:
114 self.quiet = self.verbose = False
123 self.quiet = self.verbose = False
115 self.report_untrusted = self.configbool("ui", "report_untrusted", True)
124
116 self.interactive = self.configbool("ui", "interactive", self.isatty())
125 self.report_untrusted = self.configbool("ui", "report_untrusted",
117 self.traceback = self.configbool('ui', 'traceback', False)
126 True)
127 self.interactive = self.configbool("ui", "interactive",
128 self.isatty())
129 self.traceback = self.configbool('ui', 'traceback', False)
130
118
131 # update trust information
119 # update trust information
132 if section is None or section == 'trusted':
120 for user in self.configlist('trusted', 'users'):
133 for user in self.configlist('trusted', 'users'):
121 self.trusted_users[user] = 1
134 self.trusted_users[user] = 1
122 for group in self.configlist('trusted', 'groups'):
135 for group in self.configlist('trusted', 'groups'):
123 self.trusted_groups[group] = 1
136 self.trusted_groups[group] = 1
137
124
138 def setconfig(self, section, name, value):
125 def setconfig(self, section, name, value):
139 for cdata in (self.overlay, self.cdata, self.ucdata):
126 for cdata in (self.overlay, self.cdata, self.ucdata):
140 cdata.set(section, name, value)
127 cdata.set(section, name, value)
141 self.fixconfig(section, name, value)
128 self.fixconfig()
142
129
143 def _get_cdata(self, untrusted):
130 def _get_cdata(self, untrusted):
144 if untrusted:
131 if untrusted:
@@ -231,7 +218,7 b' class ui(object):'
231 if p and '%%' in p:
218 if p and '%%' in p:
232 ui.warn('(deprecated \'\%\%\' in path %s=%s from %s)\n' %
219 ui.warn('(deprecated \'\%\%\' in path %s=%s from %s)\n' %
233 (loc, p, self.configsource('paths', loc)))
220 (loc, p, self.configsource('paths', loc)))
234 return p.replace('%%', '%')
221 p = p.replace('%%', '%')
235 return p
222 return p
236
223
237 def expandpath(self, loc, default=None):
224 def expandpath(self, loc, default=None):
General Comments 0
You need to be logged in to leave comments. Login now