Mercurial > hg
changeset 9610:d78fe60f6bda
make path expanding more consistent
This expands ~user and $FOO constructs in ui.ignore files, [defaults],
[paths], extension paths, and HGRCPATH files.
author | Alexander Solovyov <piranha@piranha.org.ua> |
---|---|
date | Mon, 19 Oct 2009 22:19:28 +0300 |
parents | aa404f3f661b |
children | a3d73b3e1f8a |
files | mercurial/dirstate.py mercurial/dispatch.py mercurial/extensions.py mercurial/ui.py mercurial/util.py |
diffstat | 5 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Sat Oct 17 15:40:34 2009 +0200 +++ b/mercurial/dirstate.py Mon Oct 19 22:19:28 2009 +0300 @@ -100,7 +100,7 @@ files = [self._join('.hgignore')] for name, path in self._ui.configitems("ui"): if name == 'ignore' or name.startswith('ignore.'): - files.append(os.path.expanduser(path)) + files.append(util.expandpath(path)) return ignore.ignore(self._root, files, self._ui.warn) @propertycache
--- a/mercurial/dispatch.py Sat Oct 17 15:40:34 2009 +0200 +++ b/mercurial/dispatch.py Mon Oct 19 22:19:28 2009 +0300 @@ -248,7 +248,7 @@ args = aliasargs(i[0]) + args defaults = ui.config("defaults", cmd) if defaults: - args = shlex.split(defaults) + args + args = map(util.expandpath, shlex.split(defaults)) + args c = list(i[1]) else: cmd = None @@ -477,8 +477,7 @@ output = ui.config('profiling', 'output') if output: - path = os.path.expanduser(output) - path = ui.expandpath(path) + path = ui.expandpath(output) ostream = open(path, 'wb') else: ostream = sys.stderr
--- a/mercurial/extensions.py Sat Oct 17 15:40:34 2009 +0200 +++ b/mercurial/extensions.py Mon Oct 19 22:19:28 2009 +0300 @@ -30,7 +30,7 @@ def loadpath(path, module_name): module_name = module_name.replace('.', '_') - path = os.path.expanduser(path) + path = util.expandpath(path) if os.path.isdir(path): # module/__init__.py style d, f = os.path.split(path.rstrip('/'))
--- a/mercurial/ui.py Sat Oct 17 15:40:34 2009 +0200 +++ b/mercurial/ui.py Mon Oct 19 22:19:28 2009 +0300 @@ -198,10 +198,12 @@ def _path(self, loc): p = self.config('paths', loc) - if p and '%%' in p: - self.warn("(deprecated '%%' in path %s=%s from %s)\n" % - (loc, p, self.configsource('paths', loc))) - p = p.replace('%%', '%') + 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):
--- a/mercurial/util.py Sat Oct 17 15:40:34 2009 +0200 +++ b/mercurial/util.py Mon Oct 19 22:19:28 2009 +0300 @@ -1158,6 +1158,7 @@ _rcpath = [] for p in os.environ['HGRCPATH'].split(os.pathsep): if not p: continue + p = expandpath(p) if os.path.isdir(p): for f, kind in osutil.listdir(p): if f.endswith('.rc'): @@ -1250,3 +1251,6 @@ for chunk in iterator: for line in chunk.splitlines(): yield line + +def expandpath(path): + return os.path.expanduser(os.path.expandvars(path))