Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.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 | bcafcd779d2e |
children | c887bab2dccf |
comparison
equal
deleted
inserted
replaced
47271:055f7b9f2307 | 47272:a671832a8e41 |
---|---|
231 self._tcfg = config.config() # trusted | 231 self._tcfg = config.config() # trusted |
232 self._ucfg = config.config() # untrusted | 232 self._ucfg = config.config() # untrusted |
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 |
239 self.logblockedtimes = False | 241 self.logblockedtimes = False |
240 # color mode: see mercurial/color.py for possible value | 242 # color mode: see mercurial/color.py for possible value |
262 self._ocfg = src._ocfg.copy() | 264 self._ocfg = src._ocfg.copy() |
263 self._trustusers = src._trustusers.copy() | 265 self._trustusers = src._trustusers.copy() |
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() |
270 self._styles = src._styles.copy() | 273 self._styles = src._styles.copy() |
271 | 274 |
543 # expand vars and ~ | 546 # expand vars and ~ |
544 # translate paths relative to root (or home) into absolute paths | 547 # translate paths relative to root (or home) into absolute paths |
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 |
567 self._fmsgout, self._fmsgerr = _selectmsgdests(self) | 574 self._fmsgout, self._fmsgerr = _selectmsgdests(self) |
568 self.debugflag = self.configbool(b'ui', b'debug') | 575 self.debugflag = self.configbool(b'ui', b'debug') |