Patchwork [11,of,36] context: move __eq__ from changectx

login
register
mail settings
Submitter Sean Farley
Date Aug. 7, 2013, 6:13 p.m.
Message ID <b6fba3a11c94e653cab0.1375899191@laptop.local>
Download mbox | patch
Permalink /patch/2028/
State Superseded
Commit 07d64a449f0a7cc3f213daf2405419b67e9c74d1
Delegated to: Augie Fackler
Headers show

Comments

Sean Farley - Aug. 7, 2013, 6:13 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1375740009 18000
#      Mon Aug 05 17:00:09 2013 -0500
# Node ID b6fba3a11c94e653cab0a481788724c9a6b356df
# Parent  d5f3b9240f8d6596e97917a18bf870d60fe7fe88
context: move __eq__ from changectx
Augie Fackler - Aug. 7, 2013, 6:27 p.m.
On Wed, Aug 07, 2013 at 01:13:11PM -0500, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1375740009 18000
> #      Mon Aug 05 17:00:09 2013 -0500
> # Node ID b6fba3a11c94e653cab0a481788724c9a6b356df
> # Parent  d5f3b9240f8d6596e97917a18bf870d60fe7fe88
> context: move __eq__ from changectx
>
> 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):

Does this need to grow some if type(self) != type(other) armor?

> +        try:
> +            return self._rev == other._rev
> +        except AttributeError:
> +            return False
> +
>      def rev(self):
>          return self._rev
>      def node(self):
>          return self._node
>      def hex(self):
> @@ -154,16 +160,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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Sean Farley - Aug. 7, 2013, 7:19 p.m.
raf@durin42.com writes:

> On Wed, Aug 07, 2013 at 01:13:11PM -0500, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1375740009 18000
>> #      Mon Aug 05 17:00:09 2013 -0500
>> # Node ID b6fba3a11c94e653cab0a481788724c9a6b356df
>> # Parent  d5f3b9240f8d6596e97917a18bf870d60fe7fe88
>> context: move __eq__ from changectx
>>
>> 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):
>
> Does this need to grow some if type(self) != type(other) armor?

Mayhaps? My plan was to just run the test suite and add more protection
when needed.
Augie Fackler - Aug. 7, 2013, 7:40 p.m.
On Wed, Aug 7, 2013 at 3:19 PM, Sean Farley
<sean.michael.farley@gmail.com> wrote:
>> Does this need to grow some if type(self) != type(other) armor?
>
> Mayhaps? My plan was to just run the test suite and add more protection
> when needed.


I'd prefer some paranoia proactively in this area.

Patch

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 self._rev == other._rev
+        except AttributeError:
+            return False
+
     def rev(self):
         return self._rev
     def node(self):
         return self._node
     def hex(self):
@@ -154,16 +160,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