diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -629,7 +629,7 @@ def bundle(ui, repo, fname, dest="defaul contents including permissions, rename data, and revision history. """ f = open(fname, "wb") - dest = ui.expandpath(dest, repo.root) + dest = ui.expandpath(dest) other = hg.repository(ui, dest) o = repo.findoutgoing(other) cg = repo.changegroup(o, 'bundle') @@ -1543,7 +1543,7 @@ def incoming(ui, repo, source="default", Currently only local repositories are supported. """ - source = ui.expandpath(source, repo.root) + source = ui.expandpath(source) other = hg.repository(ui, source) if not other.local(): raise util.Abort(_("incoming doesn't work for remote repositories yet")) @@ -1730,7 +1730,7 @@ def outgoing(ui, repo, dest="default-pus See pull for valid source format details. """ - dest = ui.expandpath(dest, repo.root) + dest = ui.expandpath(dest) other = hg.repository(ui, dest) o = repo.findoutgoing(other) o = repo.changelog.nodesbetween(o)[0] @@ -1804,7 +1804,7 @@ def pull(ui, repo, source="default", **o to the remote user's home directory by default; use two slashes at the start of a path to specify it as relative to the filesystem root. """ - source = ui.expandpath(source, repo.root) + source = ui.expandpath(source) ui.status(_('pulling from %s\n') % (source)) if opts['ssh']: @@ -1849,7 +1849,7 @@ def push(ui, repo, dest="default-push", SSH requires an accessible shell account on the destination machine and a copy of hg in the remote path. """ - dest = ui.expandpath(dest, repo.root) + dest = ui.expandpath(dest) ui.status('pushing to %s\n' % (dest)) if opts['ssh']: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -47,7 +47,7 @@ class localrepository(object): self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root) try: - self.ui.readconfig(self.join("hgrc")) + self.ui.readconfig(self.join("hgrc"), self.root) except IOError: pass diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -48,7 +48,7 @@ class ui(object): 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 @@ class ui(object): 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 @@ class ui(object): 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: