[PATCH 03 of 10 RFC v2] ui: don't return certain layers when they are supposed to be displayed

Jun Wu quark at fb.com
Wed Mar 15 01:43:49 EDT 2017


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


More information about the Mercurial-devel mailing list