Submitter | David Soria Parra |
---|---|
Date | March 12, 2017, 10:40 p.m. |
Message ID | <ef5ce5325596fe5fef01.1489358426@davidsp-mbp.dhcp.thefacebook.com> |
Download | mbox | patch |
Permalink | /patch/19247/ |
State | Changes Requested |
Headers | show |
Comments
Excerpts from David Soria Parra's message of 2017-03-12 15:40:26 -0700: [...] > - def _data(self, untrusted): > + def _data(self, untrusted, includeinternal=True): > + res = {} This does not seem to work. I guess you mean "res = config.config()". > + if includeinternal: > + res = self._cfg['defaults'] > if untrusted: > - return self._cfg['user'] > + res.update(self._cfg['user']) > else: > - return self._cfg['trusted'] > + res.update(self._cfg['trusted']) > + return res Two questions: - Performance: Constructing empty configs, and "update" them every time when "_data" gets called seems to be expensive. Maybe some caching (and invalidation may be tricky). - Correctness: "%unset" does not seem to be handled correctly. Maybe I should try polish and send my immutable series, which handles "%unset" and has some caching stuff. > > def configsource(self, section, name, untrusted=False): > return self._data(untrusted).source(section, name) > @@ -670,7 +674,7 @@ > return items > > def walkconfig(self, untrusted=False): > - cfg = self._data(untrusted) > + cfg = self._data(untrusted, includeinternal=False) > for section in cfg.sections(): > for name, value in self.configitems(section, untrusted): > yield section, name, value
Patch
diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -360,11 +360,15 @@ cfg.set(section, name, value, source) self.fixconfig(section=section) - def _data(self, untrusted): + def _data(self, untrusted, includeinternal=True): + res = {} + if includeinternal: + res = self._cfg['defaults'] if untrusted: - return self._cfg['user'] + res.update(self._cfg['user']) else: - return self._cfg['trusted'] + res.update(self._cfg['trusted']) + return res def configsource(self, section, name, untrusted=False): return self._data(untrusted).source(section, name) @@ -670,7 +674,7 @@ return items def walkconfig(self, untrusted=False): - cfg = self._data(untrusted) + cfg = self._data(untrusted, includeinternal=False) for section in cfg.sections(): for name, value in self.configitems(section, untrusted): yield section, name, value