[PATCH 11 of 35 V2] context: move __eq__ from changectx

Sean Farley sean.michael.farley at gmail.com
Wed Aug 7 18:51:25 CDT 2013


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1375740009 18000
#      Mon Aug 05 17:00:09 2013 -0500
# Node ID e685c688e55f971b359f3f77d008b12dbe0485d6
# Parent  87f23e37295fe60ad8d1a7faea8621663a897c42
context: move __eq__ from changectx

We also add type checking for extra protection.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -42,10 +42,16 @@
         return self.rev()
 
     def __repr__(self):
         return "<%s %s>" % (type(self).__name__, str(self))
 
+    def __eq__(self, other):
+        try:
+            return type(self) == type(other) and self._rev == other._rev
+        except AttributeError:
+            return False
+
     def rev(self):
         return self._rev
     def node(self):
         return self._node
     def hex(self):
@@ -160,16 +166,10 @@
         try:
             return hash(self._rev)
         except AttributeError:
             return id(self)
 
-    def __eq__(self, other):
-        try:
-            return self._rev == other._rev
-        except AttributeError:
-            return False
-
     def __ne__(self, other):
         return not (self == other)
 
     def __nonzero__(self):
         return self._rev != nullrev


More information about the Mercurial-devel mailing list