# HG changeset patch # User Matt Mackall # Date 1286653978 18000 # Node ID 8269af351a64b186a575fdd492e19e28e9575397 # Parent 10da5a1f25dd820741067c5ce47c06bd6fc3a850# Parent 7285b2824fb7c40d6f7569417cc10ac3e88ddf07 merge with crew diff -r 10da5a1f25dd -r 8269af351a64 mercurial/ui.py --- a/mercurial/ui.py Tue Aug 17 15:44:38 2010 +0200 +++ b/mercurial/ui.py Sat Oct 09 14:52:58 2010 -0500 @@ -98,12 +98,21 @@ self.fixconfig(root=root) def fixconfig(self, root=None): + # expand vars and ~ # translate paths relative to root (or home) into absolute paths root = root or os.getcwd() for c in self._tcfg, self._ucfg, self._ocfg: for n, p in c.items('paths'): - if p and "://" not in p and not os.path.isabs(p): - c.set("paths", n, os.path.normpath(os.path.join(root, p))) + if not p: + continue + if '%%' in p: + self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") + % (n, p, self.configsource('paths', n))) + p = p.replace('%%', '%') + p = util.expandpath(p) + if '://' not in p and not os.path.isabs(p): + p = os.path.normpath(os.path.join(root, p)) + c.set("paths", n, p) # update ui options self.debugflag = self.configbool('ui', 'debug') @@ -300,24 +309,14 @@ user = util.shortuser(user) return user - def _path(self, loc): - p = self.config('paths', loc) - if p: - if '%%' in p: - self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") % - (loc, p, self.configsource('paths', loc))) - p = p.replace('%%', '%') - p = util.expandpath(p) - return p - def expandpath(self, loc, default=None): """Return repository location relative to cwd or from [paths]""" if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')): return loc - path = self._path(loc) + path = self.config('paths', loc) if not path and default is not None: - path = self._path(default) + path = self.config('paths', default) return path or loc def pushbuffer(self): diff -r 10da5a1f25dd -r 8269af351a64 tests/test-paths.t --- a/tests/test-paths.t Tue Aug 17 15:44:38 2010 +0200 +++ b/tests/test-paths.t Sat Oct 09 14:52:58 2010 -0500 @@ -5,6 +5,7 @@ $ cd a $ echo '[paths]' >> .hg/hgrc $ echo 'dupe = ../b' >> .hg/hgrc + $ echo 'expand = $SOMETHING/bar' >> .hg/hgrc $ hg in dupe comparing with $TESTTMP/b no changes found @@ -14,3 +15,13 @@ comparing with $TESTTMP/b no changes found [1] + $ cd a + $ hg paths + dupe = $TESTTMP/b + expand = $TESTTMP/a/$SOMETHING/bar + $ SOMETHING=foo hg paths + dupe = $TESTTMP/b + expand = $TESTTMP/a/foo/bar + $ SOMETHING=/foo hg paths + dupe = $TESTTMP/b + expand = /foo/bar