[PATCH 3 of 3 V2] config: add a __hash__ method to config object

Laurent Charignon lcharignon at fb.com
Tue Jul 7 10:24:41 CDT 2015


> On Jul 7, 2015, at 5:55 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> 
> On Mon, 6 Jul 2015 11:42:42 -0700, Laurent Charignon wrote:
>> # HG changeset patch
>> # User Laurent Charignon <lcharignon at fb.com>
>> # Date 1435880907 25200
>> #      Thu Jul 02 16:48:27 2015 -0700
>> # Node ID 86a06a67556f2c5e15c0517ac3b13b82327e734c
>> # Parent  19d4a2676ee71fc8f30731ebd32cb544b28663ca
>> config: add a __hash__ method to config object
>> 
>> This will be used by the command server to detect config file change.
>> 
>> diff --git a/mercurial/config.py b/mercurial/config.py
>> --- a/mercurial/config.py
>> +++ b/mercurial/config.py
>> @@ -30,6 +30,8 @@ class config(object):
>>         return section in self._data
>>     def __getitem__(self, section):
>>         return self._data.get(section, {})
>> +    def __hash__(self):
>> +        return self.computehash()
> 
> If it implements __hash__, it should also have __eq__ and __ne__.

Ok, I will send a v3 with __eq__ and __ne__ 

> 
> https://urldefense.proofpoint.com/v1/url?u=https://docs.python.org/2.7/reference/datamodel.html%23object.__hash__&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ovX3wDZmWBc057vX%2Bdkir5laRYh0DpiaFZ0DBnnb7ps%3D%0A&m=Z11QAXfMTFqHZ0HI9dKygrF4KGCXW86CUoxgqaMmezo%3D%0A&s=a51ce8072d6542f6866d045676a85d7bc5a21a10649866707f335d4cac5262af



More information about the Mercurial-devel mailing list