Skip to content
Snippets Groups Projects
Commit 8269af35 authored by Matt Mackall's avatar Matt Mackall
Browse files

merge with crew

parents 10da5a1f 7285b282
No related branches found
No related tags found
No related merge requests found
...@@ -98,7 +98,8 @@ ...@@ -98,7 +98,8 @@
self.fixconfig(root=root) self.fixconfig(root=root)
def fixconfig(self, root=None): def fixconfig(self, root=None):
# expand vars and ~
# translate paths relative to root (or home) into absolute paths # translate paths relative to root (or home) into absolute paths
root = root or os.getcwd() root = root or os.getcwd()
for c in self._tcfg, self._ucfg, self._ocfg: for c in self._tcfg, self._ucfg, self._ocfg:
for n, p in c.items('paths'): for n, p in c.items('paths'):
...@@ -101,9 +102,17 @@ ...@@ -101,9 +102,17 @@
# translate paths relative to root (or home) into absolute paths # translate paths relative to root (or home) into absolute paths
root = root or os.getcwd() root = root or os.getcwd()
for c in self._tcfg, self._ucfg, self._ocfg: for c in self._tcfg, self._ucfg, self._ocfg:
for n, p in c.items('paths'): for n, p in c.items('paths'):
if p and "://" not in p and not os.path.isabs(p): if not p:
c.set("paths", n, os.path.normpath(os.path.join(root, 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 # update ui options
self.debugflag = self.configbool('ui', 'debug') self.debugflag = self.configbool('ui', 'debug')
...@@ -300,18 +309,8 @@ ...@@ -300,18 +309,8 @@
user = util.shortuser(user) user = util.shortuser(user)
return 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): def expandpath(self, loc, default=None):
"""Return repository location relative to cwd or from [paths]""" """Return repository location relative to cwd or from [paths]"""
if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')): if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')):
return loc return loc
...@@ -313,7 +312,7 @@ ...@@ -313,7 +312,7 @@
def expandpath(self, loc, default=None): def expandpath(self, loc, default=None):
"""Return repository location relative to cwd or from [paths]""" """Return repository location relative to cwd or from [paths]"""
if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')): if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')):
return loc return loc
path = self._path(loc) path = self.config('paths', loc)
if not path and default is not None: if not path and default is not None:
...@@ -319,5 +318,5 @@ ...@@ -319,5 +318,5 @@
if not path and default is not None: if not path and default is not None:
path = self._path(default) path = self.config('paths', default)
return path or loc return path or loc
def pushbuffer(self): def pushbuffer(self):
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
$ cd a $ cd a
$ echo '[paths]' >> .hg/hgrc $ echo '[paths]' >> .hg/hgrc
$ echo 'dupe = ../b' >> .hg/hgrc $ echo 'dupe = ../b' >> .hg/hgrc
$ echo 'expand = $SOMETHING/bar' >> .hg/hgrc
$ hg in dupe $ hg in dupe
comparing with $TESTTMP/b comparing with $TESTTMP/b
no changes found no changes found
...@@ -14,3 +15,13 @@ ...@@ -14,3 +15,13 @@
comparing with $TESTTMP/b comparing with $TESTTMP/b
no changes found no changes found
[1] [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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment