[PATCH 4 of 7 path-configs] ui: implement ui.sections()

Sean Farley sean.michael.farley at gmail.com
Mon Feb 9 17:21:48 CST 2015


Augie Fackler writes:

> On Sat, Feb 07, 2015 at 05:13:40PM -0800, Gregory Szorc wrote:
>> # HG changeset patch
>> # User Gregory Szorc <gregory.szorc at gmail.com>
>> # Date 1423345652 28800
>> #      Sat Feb 07 13:47:32 2015 -0800
>> # Node ID e93fb90e9b87879402147a2fdff2a937087639ca
>> # Parent  0f2bea2665040e626a7b6d039b698def3bf58dd4
>> ui: implement ui.sections()
>>
>> An upcoming patch will introduce a configuration mechanism allowing
>> configurations for different but related items (paths) to be stored
>> in different config sections. There is currently no public API to
>> iterate over sections or for all sections within a logical group
>> of sections. So, we introduce that API.
>>
>> This API could arguably go on the lower-level config class. This
>> should be scrutinized during review.
>
> I don't think it matters overmuch.
>
>>
>> diff --git a/mercurial/ui.py b/mercurial/ui.py
>> --- a/mercurial/ui.py
>> +++ b/mercurial/ui.py
>> @@ -230,8 +230,45 @@ class ui(object):
>>
>>      def _data(self, untrusted):
>>          return untrusted and self._ucfg or self._tcfg
>>
>> +    def sections(self, group=None, untrusted=False):
>> +        """Obtain sections from the config with their data.
>> +
>> +        If ``group`` is defined, only sections belonging to the specified
>> +        group will be returned. A section group consists of config sections
>> +        where the names are of the from ``[group x]`` or ``[group "x"]``.
>
> I'm not sure I like defining groups using a space, partially because
> then setting them on the command line is annoying.

That is something I forgot about. Good point. Down with spaces!


More information about the Mercurial-devel mailing list