[PATCH 6 of 6] record: add comparison methods for recordhunk class
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Mar 13 17:46:55 CDT 2015
On 03/13/2015 02:21 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1426280910 25200
> # Fri Mar 13 14:08:30 2015 -0700
> # Node ID 897ab5f050bae8a33fa9a732db697f93ee03f330
> # Parent c5650ec7e9b12e14b7d9be5b0997f0712e17016e
> record: add comparison methods for recordhunk class
I've pushed these 6 to the clowncopter after minor fixing.
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -884,6 +884,21 @@
> self.hunk = hunk
> self.added, self.removed = self.countchanges(self.hunk)
>
> + def __eq__(self, v):
> + if not isinstance(v, recordhunk):
> + return False
> +
> + return ((v.hunk == self.hunk) and
> + (v.proc == self.proc) and
> + (self.fromline == v.fromline) and
> + (self.header.files() == v.header.files()))
> +
> + def __hash__(self):
> + return hash((tuple(self.hunk),
> + tuple(self.header.files()),
> + self.fromline,
> + self.proc))
> +
> def countchanges(self, hunk):
> """hunk -> (n+,n-)"""
> add = len([h for h in hunk if h[0] == '+'])
> @@ -1076,6 +1091,7 @@
> else:
> self.read_unified_hunk(lr)
>
> +
sneaky new line (dropped locally)
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list