[Updated] D9924: config: use a new `alter` method in `fixconfig`

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Thu Mar 4 12:38:38 UTC 2021


Closed by commit rHG7621ab4005bf: config: use a new `alter` method in `fixconfig` (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D9924?vs=25573&id=26055

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D9924/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D9924

AFFECTED FILES
  mercurial/config.py
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -554,7 +554,7 @@
                     p = util.expandpath(p)
                     if not util.hasscheme(p) and not os.path.isabs(p):
                         p = os.path.normpath(os.path.join(root, p))
-                    c.set(b"paths", n, p)
+                    c.alter(b"paths", n, p)
 
         if section in (None, b'ui'):
             # update ui options
diff --git a/mercurial/config.py b/mercurial/config.py
--- a/mercurial/config.py
+++ b/mercurial/config.py
@@ -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()



To: marmoute, #hg-reviewers, Alphare, pulkit
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210304/31e93248/attachment-0002.html>


More information about the Mercurial-patches mailing list