[PATCH 1 of 2] config: introduce load order tracking

Yuya Nishihara yuya at tcha.org
Mon Jul 9 08:50:39 EDT 2018


On Mon, 09 Jul 2018 12:12:21 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld at octobus.net>
> # Date 1530887625 -7200
> #      Fri Jul 06 16:33:45 2018 +0200
> # Node ID 1019d8a4f6b810aaa63651ed56b29668650f590e
> # Parent  8c38d29482177cd40243a008057d6762c7d23c6f
> # EXP-Topic config-order
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1019d8a4f6b8
> config: introduce load order tracking
> 
> Configuration values reads from disk are now associated with the index of the
> file they came from. (First loaded file has index 0, second file index 1,
> etc…).
> 
> This will ultimately allow us to use the alias value of a configuration item
> if it was defined in a higher priority file than the configuration item value
> itself.
> 
> See next changeset for details.
> 
> Value set directly through the code or through the command line have the highest
> priority.

Didn't read this thoroughly, but have you tried making configs layered (e.g.
overlay -> repo -> user -> env -> system)?

https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-March/095733.html

The previous RFC series seems a bit over engineered, but I think the idea
behind it is probably better overall than keep track of the "level" for each
item. We can get rid of the "cow" hack, configoverride() can be instant, etc.

> --- a/mercurial/config.py
> +++ b/mercurial/config.py

>      def restore(self, data):
>          """restore data returned by self.backup"""
>          self._source = self._source.preparewrite()
> -        if len(data) == 4:
> +        self._level = self._level.preparewrite()
> +        if len(data) == 5:
>              # restore old data
> -            section, item, value, source = data
> +            section, item, value, source, level = data
>              self._data[section] = self._data[section].preparewrite()
>              self._data[section][item] = value
>              self._source[(section, item)] = source
> +            self._source[(section, item)] = level

self._level ?

> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -191,6 +191,9 @@ def _catchterm(*args):
>  # _reqexithandlers: callbacks run at the end of a request
>  _reqexithandlers = []
>  
> +# config level set directly have higher level than those from disk
> +directconfig = sys.maxint

sys.maxint no longer exists in Python 3.


More information about the Mercurial-devel mailing list