# HG changeset patch # User Thomas Arendsen Hein # Date 1142190838 -3600 # Node ID 6569651a4f1e8ce80116b15f8e459f59459c4ded # Parent 622ee75cb4c9aef1fef0e87644ca2781225a27ca Read paths specified in .hg/hgrc relative to repo root, otherwise to home dir. diff -r 622ee75cb4c9 -r 6569651a4f1e mercurial/commands.py --- a/mercurial/commands.py Sun Mar 12 18:05:13 2006 +0100 +++ b/mercurial/commands.py Sun Mar 12 20:13:58 2006 +0100 @@ -629,7 +629,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -r 622ee75cb4c9 -r 6569651a4f1e mercurial/localrepo.py --- a/mercurial/localrepo.py Sun Mar 12 18:05:13 2006 +0100 +++ b/mercurial/localrepo.py Sun Mar 12 20:13:58 2006 +0100 @@ -47,7 +47,7 @@ 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 -r 622ee75cb4c9 -r 6569651a4f1e mercurial/ui.py --- a/mercurial/ui.py Sun Mar 12 18:05:13 2006 +0100 +++ b/mercurial/ui.py Sun Mar 12 20:13:58 2006 +0100 @@ -48,7 +48,7 @@ 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 @@ 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 @@ 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: