diff mercurial/config.py @ 46620:7621ab4005bf

config: use a new `alter` method in `fixconfig` The `set` function is doing various work related to metadata (eg: the source, later the level). However the `fixconfig` call only updating some values according to standard processing, not changing any of the related metadata. So we introduce a new method and use it there. Differential Revision: https://phab.mercurial-scm.org/D9924
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 30 Jan 2021 00:32:42 +0100
parents 89a2afe31e82
children d3df397e7a59
line wrap: on
line diff
--- a/mercurial/config.py	Mon Mar 01 14:44:29 2021 -0800
+++ b/mercurial/config.py	Sat Jan 30 00:32:42 2021 +0100
@@ -108,6 +108,16 @@
             self._source = self._source.preparewrite()
             self._source[(section, item)] = source
 
+    def alter(self, section, key, new_value):
+        """alter a value without altering its source or level
+
+        This method is meant to be used by `ui.fixconfig` only."""
+        item = self._data[section][key]
+        size = len(item)
+        new_item = (new_value,) + item[1:]
+        assert len(new_item) == size
+        self._data[section][key] = new_item
+
     def restore(self, data):
         """restore data returned by self.backup"""
         self._source = self._source.preparewrite()