Mercurial > hg > pyhgsh
comparison mercurial/ui.py @ 1893:6569651a4f1e
Read paths specified in .hg/hgrc relative to repo root, otherwise to home dir.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sun, 12 Mar 2006 20:13:58 +0100 |
parents | 622ee75cb4c9 |
children | b7cc0f323a4c acce3f7e1779 |
comparison
equal
deleted
inserted
replaced
1892:622ee75cb4c9 | 1893:6569651a4f1e |
---|---|
46 self.quiet = (self.quiet or quiet) and not verbose and not debug | 46 self.quiet = (self.quiet or quiet) and not verbose and not debug |
47 self.verbose = (self.verbose or verbose) or debug | 47 self.verbose = (self.verbose or verbose) or debug |
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: |
55 try: | 55 try: |
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 |
62 | 68 |
63 def config(self, section, name, default=None): | 69 def config(self, section, name, default=None): |
151 f = user.find('<') | 157 f = user.find('<') |
152 if f >= 0: | 158 if f >= 0: |
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: |
172 sys.stdout.write(str(a)) | 171 sys.stdout.write(str(a)) |
173 | 172 |