##// END OF EJS Templates
Read paths specified in .hg/hgrc relative to repo root, otherwise to home dir.
Thomas Arendsen Hein -
r1893:6569651a default
parent child Browse files
Show More
@@ -629,7 +629,7 b' def bundle(ui, repo, fname, dest="defaul'
629 contents including permissions, rename data, and revision history.
629 contents including permissions, rename data, and revision history.
630 """
630 """
631 f = open(fname, "wb")
631 f = open(fname, "wb")
632 dest = ui.expandpath(dest, repo.root)
632 dest = ui.expandpath(dest)
633 other = hg.repository(ui, dest)
633 other = hg.repository(ui, dest)
634 o = repo.findoutgoing(other)
634 o = repo.findoutgoing(other)
635 cg = repo.changegroup(o, 'bundle')
635 cg = repo.changegroup(o, 'bundle')
@@ -1543,7 +1543,7 b' def incoming(ui, repo, source="default",'
1543
1543
1544 Currently only local repositories are supported.
1544 Currently only local repositories are supported.
1545 """
1545 """
1546 source = ui.expandpath(source, repo.root)
1546 source = ui.expandpath(source)
1547 other = hg.repository(ui, source)
1547 other = hg.repository(ui, source)
1548 if not other.local():
1548 if not other.local():
1549 raise util.Abort(_("incoming doesn't work for remote repositories yet"))
1549 raise util.Abort(_("incoming doesn't work for remote repositories yet"))
@@ -1730,7 +1730,7 b' def outgoing(ui, repo, dest="default-pus'
1730
1730
1731 See pull for valid source format details.
1731 See pull for valid source format details.
1732 """
1732 """
1733 dest = ui.expandpath(dest, repo.root)
1733 dest = ui.expandpath(dest)
1734 other = hg.repository(ui, dest)
1734 other = hg.repository(ui, dest)
1735 o = repo.findoutgoing(other)
1735 o = repo.findoutgoing(other)
1736 o = repo.changelog.nodesbetween(o)[0]
1736 o = repo.changelog.nodesbetween(o)[0]
@@ -1804,7 +1804,7 b' def pull(ui, repo, source="default", **o'
1804 to the remote user's home directory by default; use two slashes at
1804 to the remote user's home directory by default; use two slashes at
1805 the start of a path to specify it as relative to the filesystem root.
1805 the start of a path to specify it as relative to the filesystem root.
1806 """
1806 """
1807 source = ui.expandpath(source, repo.root)
1807 source = ui.expandpath(source)
1808 ui.status(_('pulling from %s\n') % (source))
1808 ui.status(_('pulling from %s\n') % (source))
1809
1809
1810 if opts['ssh']:
1810 if opts['ssh']:
@@ -1849,7 +1849,7 b' def push(ui, repo, dest="default-push", '
1849 SSH requires an accessible shell account on the destination
1849 SSH requires an accessible shell account on the destination
1850 machine and a copy of hg in the remote path.
1850 machine and a copy of hg in the remote path.
1851 """
1851 """
1852 dest = ui.expandpath(dest, repo.root)
1852 dest = ui.expandpath(dest)
1853 ui.status('pushing to %s\n' % (dest))
1853 ui.status('pushing to %s\n' % (dest))
1854
1854
1855 if opts['ssh']:
1855 if opts['ssh']:
@@ -47,7 +47,7 b' class localrepository(object):'
47
47
48 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
48 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
49 try:
49 try:
50 self.ui.readconfig(self.join("hgrc"))
50 self.ui.readconfig(self.join("hgrc"), self.root)
51 except IOError:
51 except IOError:
52 pass
52 pass
53
53
@@ -48,7 +48,7 b' class ui(object):'
48 self.debugflag = (self.debugflag or debug)
48 self.debugflag = (self.debugflag or debug)
49 self.interactive = (self.interactive and interactive)
49 self.interactive = (self.interactive and interactive)
50
50
51 def readconfig(self, fn):
51 def readconfig(self, fn, root=None):
52 if isinstance(fn, basestring):
52 if isinstance(fn, basestring):
53 fn = [fn]
53 fn = [fn]
54 for f in fn:
54 for f in fn:
@@ -56,6 +56,12 b' class ui(object):'
56 self.cdata.read(f)
56 self.cdata.read(f)
57 except ConfigParser.ParsingError, inst:
57 except ConfigParser.ParsingError, inst:
58 raise util.Abort(_("Failed to parse %s\n%s") % (f, inst))
58 raise util.Abort(_("Failed to parse %s\n%s") % (f, inst))
59 # translate paths relative to root (or home) into absolute paths
60 if root is None:
61 root = os.path.expanduser('~')
62 for name, path in self.configitems("paths"):
63 if path.find("://") == -1 and not os.path.isabs(path):
64 self.cdata.set("paths", name, os.path.join(root, path))
59
65
60 def setconfig(self, section, name, val):
66 def setconfig(self, section, name, val):
61 self.overlay[(section, name)] = val
67 self.overlay[(section, name)] = val
@@ -153,19 +159,12 b' class ui(object):'
153 user = user[f+1:]
159 user = user[f+1:]
154 return user
160 return user
155
161
156 def expandpath(self, loc, root=""):
162 def expandpath(self, loc):
157 """Return repository location relative to cwd or from [paths]"""
163 """Return repository location relative to cwd or from [paths]"""
158 if os.path.exists(loc):
164 if loc.find("://") != -1 or os.path.exists(loc):
159 return loc
165 return loc
160
166
161 paths = {}
167 return self.config("paths", loc, loc)
162 for name, path in self.configitems("paths"):
163 m = path.find("://")
164 if m == -1:
165 path = os.path.join(root, path)
166 paths[name] = path
167
168 return paths.get(loc, loc)
169
168
170 def write(self, *args):
169 def write(self, *args):
171 for a in args:
170 for a in args:
General Comments 0
You need to be logged in to leave comments. Login now