[2,of,2,RFC] RFC: switch to immutable configs

Jun Wu quark at fb.com
Wed Mar 29 19:00:45 EDT 2017


Excerpts from David Soria Parra's message of 2017-03-29 15:56:21 -0700:
> > +            # immutable configs
> > +            self._ocfgs = config.mergedconfig('setconfig', []) # overlay
> > +            self._tcfgs = config.mergedconfig('loaded', []) # trusted
> i would probably actually call them 'trusted' instead of 'loaded'
> > +            self._ucfgs = config.mergedconfig('loaded', []) # trusted+untrusted
> with merge configs in, we would split up trusted+untrusted into trusted and
> untrusted?
> 
> > +    def setconfig(self, section, name, value, source='', priority=None):
> I think we can do better by using the title, e.g. 'untrusted', 'setconfig' to
> access the right layer. a numeric priority seems to be very hard to use and I
> think we could improve this interface a bit.

Yeah, the "priority" is added in the last hour. It was "overlay=True/False",
until I met "ui.commitsubrepos", which seems to have to be a global
affecting multiple uis. Basically we need at least 3 priorities: ('normal',
'overlay', 'global').

> > +        title = source or 'setconfig'
> > +        acfg = config.atomicconfig(title, [(section, name, (value, source))])
> > +        try:
> > +            cwd = pycompat.getcwd()
> > +        except OSError:
> > +            pass
> > +        else:
> > +            acfg = _fixpathsection(acfg, cwd)
> > +        if priority == 3:
> > +            # global overlay
> > +            self.__class__._gcfgs = self.__class__._gcfgs.append(acfg)
> > +        elif priority == 2:
> > +            # change overlay in this ui
> > +            self._ocfgs = self._ocfgs.append(acfg)
> > +        elif priority == 1:
> > +            # change overlay in this ui, do not override existing overlays
> > +            self._ocfgs = self._ocfgs.prepend(acfg)
> > +        else:
> > +            self._tcfgs = self._tcfgs.append(acfg)
> > +            self._ucfgs = self._ucfgs.append(acfg)
> >  


More information about the Mercurial-devel mailing list