Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 12662:7285b2824fb7
ui.paths: expand paths directly in fixconfig (issue2373)
var and home expansion should be done first.
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sat, 09 Oct 2010 12:28:16 -0500 |
parents | a88a4720c2f0 |
children | cf24b6b5517c |
comparison
equal
deleted
inserted
replaced
12660:6ed5ae6264c2 | 12662:7285b2824fb7 |
---|---|
96 if root is None: | 96 if root is None: |
97 root = os.path.expanduser('~') | 97 root = os.path.expanduser('~') |
98 self.fixconfig(root=root) | 98 self.fixconfig(root=root) |
99 | 99 |
100 def fixconfig(self, root=None): | 100 def fixconfig(self, root=None): |
101 # expand vars and ~ | |
101 # translate paths relative to root (or home) into absolute paths | 102 # translate paths relative to root (or home) into absolute paths |
102 root = root or os.getcwd() | 103 root = root or os.getcwd() |
103 for c in self._tcfg, self._ucfg, self._ocfg: | 104 for c in self._tcfg, self._ucfg, self._ocfg: |
104 for n, p in c.items('paths'): | 105 for n, p in c.items('paths'): |
105 if p and "://" not in p and not os.path.isabs(p): | 106 if not p: |
106 c.set("paths", n, os.path.normpath(os.path.join(root, p))) | 107 continue |
108 if '%%' in p: | |
109 self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") | |
110 % (n, p, self.configsource('paths', n))) | |
111 p = p.replace('%%', '%') | |
112 p = util.expandpath(p) | |
113 if '://' not in p and not os.path.isabs(p): | |
114 p = os.path.normpath(os.path.join(root, p)) | |
115 c.set("paths", n, p) | |
107 | 116 |
108 # update ui options | 117 # update ui options |
109 self.debugflag = self.configbool('ui', 'debug') | 118 self.debugflag = self.configbool('ui', 'debug') |
110 self.verbose = self.debugflag or self.configbool('ui', 'verbose') | 119 self.verbose = self.debugflag or self.configbool('ui', 'verbose') |
111 self.quiet = not self.debugflag and self.configbool('ui', 'quiet') | 120 self.quiet = not self.debugflag and self.configbool('ui', 'quiet') |
298 """Return a short representation of a user name or email address.""" | 307 """Return a short representation of a user name or email address.""" |
299 if not self.verbose: | 308 if not self.verbose: |
300 user = util.shortuser(user) | 309 user = util.shortuser(user) |
301 return user | 310 return user |
302 | 311 |
303 def _path(self, loc): | |
304 p = self.config('paths', loc) | |
305 if p: | |
306 if '%%' in p: | |
307 self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") % | |
308 (loc, p, self.configsource('paths', loc))) | |
309 p = p.replace('%%', '%') | |
310 p = util.expandpath(p) | |
311 return p | |
312 | |
313 def expandpath(self, loc, default=None): | 312 def expandpath(self, loc, default=None): |
314 """Return repository location relative to cwd or from [paths]""" | 313 """Return repository location relative to cwd or from [paths]""" |
315 if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')): | 314 if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')): |
316 return loc | 315 return loc |
317 | 316 |
318 path = self._path(loc) | 317 path = self.config('paths', loc) |
319 if not path and default is not None: | 318 if not path and default is not None: |
320 path = self._path(default) | 319 path = self.config('paths', default) |
321 return path or loc | 320 return path or loc |
322 | 321 |
323 def pushbuffer(self): | 322 def pushbuffer(self): |
324 self._buffers.append([]) | 323 self._buffers.append([]) |
325 | 324 |