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

Yuya Nishihara yuya at tcha.org
Tue Jul 7 07:55:03 CDT 2015


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__.

https://docs.python.org/2.7/reference/datamodel.html#object.__hash__


More information about the Mercurial-devel mailing list