Mercurial > hg-stable
diff mercurial/ui.py @ 1893:6569651a4f1e
Read paths specified in .hg/hgrc relative to repo root, otherwise to home dir.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sun, 12 Mar 2006 20:13:58 +0100 |
parents | 622ee75cb4c9 |
children | b7cc0f323a4c acce3f7e1779 |
line wrap: on
line diff
--- a/mercurial/ui.py Sun Mar 12 18:05:13 2006 +0100 +++ b/mercurial/ui.py Sun Mar 12 20:13:58 2006 +0100 @@ -48,7 +48,7 @@ self.debugflag = (self.debugflag or debug) self.interactive = (self.interactive and interactive) - def readconfig(self, fn): + def readconfig(self, fn, root=None): if isinstance(fn, basestring): fn = [fn] for f in fn: @@ -56,6 +56,12 @@ self.cdata.read(f) except ConfigParser.ParsingError, inst: raise util.Abort(_("Failed to parse %s\n%s") % (f, inst)) + # translate paths relative to root (or home) into absolute paths + if root is None: + root = os.path.expanduser('~') + for name, path in self.configitems("paths"): + if path.find("://") == -1 and not os.path.isabs(path): + self.cdata.set("paths", name, os.path.join(root, path)) def setconfig(self, section, name, val): self.overlay[(section, name)] = val @@ -153,19 +159,12 @@ user = user[f+1:] return user - def expandpath(self, loc, root=""): + def expandpath(self, loc): """Return repository location relative to cwd or from [paths]""" - if os.path.exists(loc): + if loc.find("://") != -1 or os.path.exists(loc): return loc - paths = {} - for name, path in self.configitems("paths"): - m = path.find("://") - if m == -1: - path = os.path.join(root, path) - paths[name] = path - - return paths.get(loc, loc) + return self.config("paths", loc, loc) def write(self, *args): for a in args: