##// END OF EJS Templates
urlutil: move url "fixing" at the time of `ui.paths` initialization...
marmoute -
r48046:a671832a default
parent child Browse files
Show More
@@ -233,6 +233,8 b' class ui(object):'
233 233 self._trustusers = set()
234 234 self._trustgroups = set()
235 235 self.callhooks = True
236 # hold the root to use for each [paths] entry
237 self._path_to_root = {}
236 238 # Insecure server connections requested.
237 239 self.insecureconnections = False
238 240 # Blocked time
@@ -264,6 +266,7 b' class ui(object):'
264 266 self._trustgroups = src._trustgroups.copy()
265 267 self.environ = src.environ
266 268 self.callhooks = src.callhooks
269 self._path_to_root = src._path_to_root
267 270 self.insecureconnections = src.insecureconnections
268 271 self._colormode = src._colormode
269 272 self._terminfoparams = src._terminfoparams.copy()
@@ -545,21 +548,25 b' class ui(object):'
545 548 root = root or encoding.getcwd()
546 549 for c in self._tcfg, self._ucfg, self._ocfg:
547 550 for n, p in c.items(b'paths'):
551 old_p = p
552 s = self.configsource(b'paths', n) or b'none'
553 root_key = (n, p, s)
554 if root_key not in self._path_to_root:
555 self._path_to_root[root_key] = root
548 556 # Ignore sub-options.
549 557 if b':' in n:
550 558 continue
551 559 if not p:
552 560 continue
553 561 if b'%%' in p:
554 s = self.configsource(b'paths', n) or b'none'
562 if s is None:
563 s = 'none'
555 564 self.warn(
556 565 _(b"(deprecated '%%' in path %s=%s from %s)\n")
557 566 % (n, p, s)
558 567 )
559 568 p = p.replace(b'%%', b'%')
560 p = util.expandpath(p)
561 if not urlutil.hasscheme(p) and not os.path.isabs(p):
562 p = os.path.normpath(os.path.join(root, p))
569 if p != old_p:
563 570 c.alter(b"paths", n, p)
564 571
565 572 if section in (None, b'ui'):
@@ -637,11 +637,20 b' class paths(dict):'
637 637 def __init__(self, ui):
638 638 dict.__init__(self)
639 639
640 home_path = os.path.expanduser(b'~')
641
640 642 for name, loc in ui.configitems(b'paths', ignoresub=True):
641 643 # No location is the same as not existing.
642 644 if not loc:
643 645 continue
644 loc, sub_opts = ui.configsuboptions(b'paths', name)
646 _value, sub_opts = ui.configsuboptions(b'paths', name)
647 s = ui.configsource(b'paths', name)
648 root_key = (name, loc, s)
649 root = ui._path_to_root.get(root_key, home_path)
650 loc = os.path.expandvars(loc)
651 loc = os.path.expanduser(loc)
652 if not hasscheme(loc) and not os.path.isabs(loc):
653 loc = os.path.normpath(os.path.join(root, loc))
645 654 self[name] = [path(ui, name, rawloc=loc, suboptions=sub_opts)]
646 655
647 656 for name, old_paths in sorted(self.items()):
@@ -337,8 +337,14 b" sub-options in [paths] aren't expanded"
337 337 > EOF
338 338
339 339 $ hg showconfig paths
340 paths.foo=~/foo
340 341 paths.foo:suboption=~/foo
341 paths.foo=$TESTTMP/foo
342
343 note: The path expansion no longer happens at the config level, but the path is
344 still expanded:
345
346 $ hg path | grep foo
347 foo = $TESTTMP/foo
342 348
343 349 edit failure
344 350
@@ -74,6 +74,10 b' TODO: add rhg support for path aliases'
74 74 8580ff50825a tip
75 75 $ echo '[paths]' >> $HGRCPATH
76 76 $ echo 'relativetohome = a' >> $HGRCPATH
77 $ hg path | grep relativetohome
78 relativetohome = $TESTTMP/a
79 $ HOME=`pwd`/../ hg path | grep relativetohome
80 relativetohome = $TESTTMP/a
77 81 $ HOME=`pwd`/../ hg -R relativetohome identify
78 82 8580ff50825a tip
79 83 $ cd ..
@@ -255,7 +255,7 b' source of paths is not mangled'
255 255 > EOF
256 256 $ hg showconfig --source paths
257 257 plain: True
258 $TESTTMP/hgrc:17: paths.foo=$TESTTMP/bar
258 $TESTTMP/hgrc:17: paths.foo=bar
259 259
260 260 Test we can skip the user configuration
261 261
General Comments 0
You need to be logged in to leave comments. Login now