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