commit:     cbda36d50efd616a2c149deea42785c745253566
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Jan 17 04:43:04 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Feb  5 18:08:20 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=cbda36d5

refactor(config): drop duplicated add_config_source methods.

Previously we had .update() and .add_config_source; rename (and internalize)
accordingly so we have just one.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/config/central.py | 19 +++++++++----------
 src/pkgcore/ebuild/domain.py  |  2 +-
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/pkgcore/config/central.py b/src/pkgcore/config/central.py
index 9ac4d9f57..350e25f5e 100644
--- a/src/pkgcore/config/central.py
+++ b/src/pkgcore/config/central.py
@@ -8,6 +8,7 @@ __all__ = (
     "ConfigManager",
 )
 
+import functools
 import typing
 import weakref
 from collections import defaultdict, deque, namedtuple
@@ -338,9 +339,9 @@ class ConfigManager:
         return basics.GeneratedConfigSource(config, "unknown")
 
     def reload(self) -> None:
-        """Reinitialize from the config sources originally passed in.
+        """Reinitialize from the configured config sources.
 
-        This throws away all cached instances and re-executes autoloads.
+        This throws away all cached instances.
         """
         # "Attribute defined outside __init__"
         # pylint: disable-msg=W0201
@@ -352,23 +353,21 @@ class ConfigManager:
         # force regeneration.
         self._types = klass._uncached_singleton
         for config in self.original_config_sources:
-            self.add_config_source(config)
+            self._integrate_config_source(config)
 
-    def update(self, config) -> None:
-        """Reinitialize using an additional supplied config."""
+    def add_config_source(self, config) -> None:
+        """Add the given config source and reload the internal rendering"""
         self.original_config_sources += (config,)
         self.reload()
 
-    def add_config_source(self, config) -> None:
-        self._add_config_source(self._compat_mangle_config(config))
-
-    def _add_config_source(self, config) -> None:
+    def _integrate_config_source(self, config) -> None:
         """Pull extra type and config sections from configs and use them.
 
         Things loaded this way are added after already loaded things
         (meaning the config containing the autoload section overrides
         the config(s) added by that section).
         """
+        config = self._compat_mangle_config(config)
         config_data = config.sections()
 
         collision = set(self.rendered_sections)
@@ -414,7 +413,7 @@ class ConfigManager:
             except Exception as e:
                 raise errors.AutoloadInstantiationError(name) from e
             if collapsed.type.name == "configsection":
-                self.add_config_source(instance)
+                self._integrate_config_source(instance)
 
     def sections(self) -> typing.Iterator[str]:
         """Return an iterator of all section names."""

diff --git a/src/pkgcore/ebuild/domain.py b/src/pkgcore/ebuild/domain.py
index 3339019dc..8d3f19662 100644
--- a/src/pkgcore/ebuild/domain.py
+++ b/src/pkgcore/ebuild/domain.py
@@ -774,7 +774,7 @@ class domain(config_domain):
         }
         data[f"conf:{path}"] = basics.AutoConfigSection(repo_conf_data)
         data[path] = basics.AutoConfigSection(repo_data)
-        config.update(data)
+        config.add_config_source(data)
 
         # reset repo-related jit attrs
         for attr in (x for x in dir(self) if x.startswith("_jit_repo_")):

Reply via email to