Mercurial > hg
comparison mercurial/ui.py @ 46622:a3dced4b7b04
config: track the "level" of a value
Config value now remember the "level" of the config that loaded it. This will be
used to ensure good priority management for alias.
Differential Revision: https://phab.mercurial-scm.org/D9926
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 29 Jan 2021 11:21:49 +0100 |
parents | 7621ab4005bf |
children | b91a695b3b08 |
comparison
equal
deleted
inserted
replaced
46621:d3df397e7a59 | 46622:a3dced4b7b04 |
---|---|
300 self._exportableenviron = {} | 300 self._exportableenviron = {} |
301 for k in allowed: | 301 for k in allowed: |
302 if k in self.environ: | 302 if k in self.environ: |
303 self._exportableenviron[k] = self.environ[k] | 303 self._exportableenviron[k] = self.environ[k] |
304 | 304 |
305 def _new_source(self): | |
306 self._ocfg.new_source() | |
307 self._tcfg.new_source() | |
308 self._ucfg.new_source() | |
309 | |
305 @classmethod | 310 @classmethod |
306 def load(cls): | 311 def load(cls): |
307 """Create a ui and load global and user configs""" | 312 """Create a ui and load global and user configs""" |
308 u = cls() | 313 u = cls() |
309 # we always trust global config files and environment variables | 314 # we always trust global config files and environment variables |
311 if t == b'path': | 316 if t == b'path': |
312 u.readconfig(f, trust=True) | 317 u.readconfig(f, trust=True) |
313 elif t == b'resource': | 318 elif t == b'resource': |
314 u.read_resource_config(f, trust=True) | 319 u.read_resource_config(f, trust=True) |
315 elif t == b'items': | 320 elif t == b'items': |
321 u._new_source() | |
316 sections = set() | 322 sections = set() |
317 for section, name, value, source in f: | 323 for section, name, value, source in f: |
318 # do not set u._ocfg | 324 # do not set u._ocfg |
319 # XXX clean this up once immutable config object is a thing | 325 # XXX clean this up once immutable config object is a thing |
320 u._tcfg.set(section, name, value, source) | 326 u._tcfg.set(section, name, value, source) |
323 for section in sections: | 329 for section in sections: |
324 u.fixconfig(section=section) | 330 u.fixconfig(section=section) |
325 else: | 331 else: |
326 raise error.ProgrammingError(b'unknown rctype: %s' % t) | 332 raise error.ProgrammingError(b'unknown rctype: %s' % t) |
327 u._maybetweakdefaults() | 333 u._maybetweakdefaults() |
334 u._new_source() # anything after that is a different level | |
328 return u | 335 return u |
329 | 336 |
330 def _maybetweakdefaults(self): | 337 def _maybetweakdefaults(self): |
331 if not self.configbool(b'ui', b'tweakdefaults'): | 338 if not self.configbool(b'ui', b'tweakdefaults'): |
332 return | 339 return |