Mercurial > hg
diff mercurial/ui.py @ 46823:f1f2961d2816
path: move handling of "default" (*) suboptions value inside __init__
With the introduction of `path://` scheme the handling of default value will need to be subtler. We do simple code movement first to clarify the future changes.
Differential Revision: https://phab.mercurial-scm.org/D10260
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 18 Mar 2021 10:12:55 +0100 |
parents | d4ba4d51f85f |
children | 57218b7ffb2a |
line wrap: on
line diff
--- a/mercurial/ui.py Tue Mar 16 15:12:03 2021 +0100 +++ b/mercurial/ui.py Thu Mar 18 10:12:55 2021 +0100 @@ -2190,16 +2190,12 @@ def __init__(self, ui): dict.__init__(self) - _path, base_sub_options = ui.configsuboptions(b'paths', b'*') for name, loc in ui.configitems(b'paths', ignoresub=True): # No location is the same as not existing. if not loc: continue - loc, sub = ui.configsuboptions(b'paths', name) - sub_opts = base_sub_options.copy() - sub_opts.update(sub) + loc, sub_opts = ui.configsuboptions(b'paths', name) self[name] = path(ui, name, rawloc=loc, suboptions=sub_opts) - self._default_sub_opts = base_sub_options def getpath(self, ui, name, default=None): """Return a ``path`` from a string, falling back to default. @@ -2234,9 +2230,7 @@ # Try to resolve as a local path or URI. try: # we pass the ui instance are warning might need to be issued - return path( - ui, None, rawloc=name, suboptions=self._default_sub_opts - ) + return path(ui, None, rawloc=name) except ValueError: raise error.RepoError(_(b'repository %s does not exist') % name) @@ -2334,17 +2328,19 @@ b'repo: %s' % rawloc ) - suboptions = suboptions or {} + _path, sub_opts = ui.configsuboptions(b'paths', b'*') + if suboptions is not None: + sub_opts.update(suboptions) # Now process the sub-options. If a sub-option is registered, its # attribute will always be present. The value will be None if there # was no valid sub-option. for suboption, (attr, func) in pycompat.iteritems(_pathsuboptions): - if suboption not in suboptions: + if suboption not in sub_opts: setattr(self, attr, None) continue - value = func(ui, self, suboptions[suboption]) + value = func(ui, self, sub_opts[suboption]) setattr(self, attr, value) def _isvalidlocalpath(self, path):