[PATCH] make path expanding more consistent
Alexander Solovyov
piranha at piranha.org.ua
Mon Oct 19 19:19:39 UTC 2009
# HG changeset patch
# User Alexander Solovyov <piranha at piranha.org.ua>
# Date 1255979968 -10800
# Node ID b8c2f3e5d8eb10dd2bb080f2bf3a9c469b25511b
# Parent 220d39af2e5779879dd9a7bf3af41d787b7ef9b6
make path expanding more consistent
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -100,7 +100,7 @@ class dirstate(object):
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
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -248,7 +248,7 @@ def _parse(ui, args):
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,7 +477,6 @@ def _runcommand(ui, options, cmd, cmdfun
output = ui.config('profiling', 'output')
if output:
- path = os.path.expanduser(output)
path = ui.expandpath(path)
ostream = open(path, 'wb')
else:
diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -30,7 +30,7 @@ def find(name):
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('/'))
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -202,7 +202,7 @@ class ui(object):
self.warn("(deprecated '%%' in path %s=%s from %s)\n" %
(loc, p, self.configsource('paths', loc)))
p = p.replace('%%', '%')
- return p
+ return util.expandpath(p)
def expandpath(self, loc, default=None):
"""Return repository location relative to cwd or from [paths]"""
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1158,6 +1158,7 @@ def rcpath():
_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 @@ def iterlines(iterator):
for chunk in iterator:
for line in chunk.splitlines():
yield line
+
+def expandpath(path):
+ return os.path.expanduser(os.path.expandvars(path))
More information about the Mercurial-devel
mailing list