[PATCH 3 of 3 stable] obsolete: add __eq__ and __hash__ to marker to make set() deduplication work

Augie Fackler raf at durin42.com
Sun Nov 17 10:00:24 CST 2013


queued these with english tweaks in 2 of 3, thanks

On Nov 16, 2013, at 8:45 PM, pierre-yves.david at ens-lyon.org wrote:

> # HG changeset patch
> # User Augie Fackler <raf at durin42.com>
> # Date 1384650722 18000
> #      Sat Nov 16 20:12:02 2013 -0500
> # Branch stable
> # Node ID 94fa59f68e5a796f5d74c57097ca6af8c866efa9
> # Parent  913ccfc2f66abe0b937caa40a64a5ea21d53f763
> obsolete: add __eq__ and __hash__ to marker to make set() deduplication work
> 
> diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
> --- a/mercurial/obsolete.py
> +++ b/mercurial/obsolete.py
> @@ -194,10 +194,18 @@ class marker(object):
>         # the repo argument will be used to create changectx in later version
>         self._repo = repo
>         self._data = data
>         self._decodedmeta = None
> 
> +    def __hash__(self):
> +        return hash(self._data)
> +
> +    def __eq__(self, other):
> +        if type(other) != type(self):
> +            return False
> +        return self._data == other._data
> +
>     def precnode(self):
>         """Precursor changeset node identifier"""
>         return self._data[0]
> 
>     def succnodes(self):



More information about the Mercurial-devel mailing list