From 3461df1d8ff47ad0e1973b0ac6d151bd799d3c10 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 29 Aug 2018 12:08:01 +0300 Subject: [PATCH] config: properly merge with local config Signed-off-by: Ruslan Kuprieiev --- dvc/config.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dvc/config.py b/dvc/config.py index 5f2e2d8cb..5916a5201 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -171,7 +171,7 @@ class Config(object): # need to convert our config to dict before passing it to self._config = self._lower(self._config) local = self._lower(local) - self._config.update(local) + self._config = self._merge(self._config, local) self._config = Schema(self.SCHEMA).validate(self._config) @@ -182,6 +182,17 @@ class Config(object): except Exception as ex: raise ConfigError(ex) + @staticmethod + def _merge(first, second): + res = {} + sections = list(first.keys()) + list(second.keys()) + for section in sections: + f = first.get(section, {}).copy() + s = second.get(section, {}).copy() + f.update(s) + res[section] = f + return res + @staticmethod def _lower(config): new_config = {}