Patchwork [2,of,2] changing-files: implement equality checking

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 18, 2020, 11:20 a.m.
Message ID <e5b90d7932c603b1a2f6.1600428037@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/47214/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 18, 2020, 11:20 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1600174987 -7200
#      Tue Sep 15 15:03:07 2020 +0200
# Node ID e5b90d7932c603b1a2f63f20f0cda67b86d783cb
# Parent  1118abe1f9e4d927e20506bd0baac04995771c92
# EXP-Topic changing-files
# Available At https://foss.heptapod.net/octobus/mercurial-devel/
#              hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r e5b90d7932c6
changing-files: implement equality checking

This makes debugging simpler.
Yuya Nishihara - Sept. 19, 2020, 2:38 a.m.
On Fri, 18 Sep 2020 13:20:37 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1600174987 -7200
> #      Tue Sep 15 15:03:07 2020 +0200
> # Node ID e5b90d7932c603b1a2f63f20f0cda67b86d783cb
> # Parent  1118abe1f9e4d927e20506bd0baac04995771c92
> # EXP-Topic changing-files
> # Available At https://foss.heptapod.net/octobus/mercurial-devel/
> #              hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r e5b90d7932c6
> changing-files: implement equality checking
> 
> This makes debugging simpler.
> 
> diff --git a/mercurial/metadata.py b/mercurial/metadata.py
> --- a/mercurial/metadata.py
> +++ b/mercurial/metadata.py
> @@ -50,6 +50,15 @@ class ChangingFiles(object):
>          self._p1_copies = dict(p1_copies)
>          self._p2_copies = dict(p2_copies)
>  
> +    def __eq__(self, other):

I just learned Python 3 delegates __ne__ to __eq__ automatically.

Patch

diff --git a/mercurial/metadata.py b/mercurial/metadata.py
--- a/mercurial/metadata.py
+++ b/mercurial/metadata.py
@@ -50,6 +50,15 @@  class ChangingFiles(object):
         self._p1_copies = dict(p1_copies)
         self._p2_copies = dict(p2_copies)
 
+    def __eq__(self, other):
+        return (
+            self.added == other.added
+            and self.removed == other.removed
+            and self.touched == other.touched
+            and self.copied_from_p1 == other.copied_from_p1
+            and self.copied_from_p2 == other.copied_from_p2
+        )
+
     @property
     def added(self):
         """files actively added in the changeset