Mercurial > hg
comparison mercurial/utils/urlutil.py @ 47272:a671832a8e41
urlutil: move url "fixing" at the time of `ui.paths` initialization
Doing such fixing at the time is simpler and will be necessary to deal with
urls list in a sane manner. It also reduce the size of fix-config which is
always better.
I wish we could get ride of the hackish way to pass the root around, I suspect
that the `root` variable could be stored as part of the config value, along side
the source. However getting to the end of this `root` business is a far too
large detours to make now.
The test change to `tests/test-hgrc.t` and `test-config.t` are expectied since
we are not longer altering the config itself, but the way it is interpreted when
building path. This seems more correct.
I also added a couple of test call to `test-config.t` and `test-globalopts.t` to
clarify that the expanding process is properly happening a the right time.
Differential Revision: https://phab.mercurial-scm.org/D10451
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 15 Apr 2021 20:13:29 +0200 |
parents | 7531cc34713c |
children | 834f4e9d1af2 |
comparison
equal
deleted
inserted
replaced
47271:055f7b9f2307 | 47272:a671832a8e41 |
---|---|
635 """ | 635 """ |
636 | 636 |
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()): |
648 new_paths = [] | 657 new_paths = [] |
649 for p in old_paths: | 658 for p in old_paths: |