dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00604
[PATCH 05/34] objects: Make ShaFile.__eq__ work when other is not a ShaFile.
From: Dave Borowitz <dborowitz@xxxxxxxxxx>
Change-Id: I3944e84ae64ea1ddb6acbc51b171b6a039cccf04
---
NEWS | 2 ++
dulwich/objects.py | 10 +++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index 264bbd5..a064cac 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,8 @@
* Fix a bug in reading the pack checksum when there are fewer than 20 bytes
left in the buffer. (Dave Borowitz)
+ * Make ShaFile.__eq__ work when other is not a ShaFile. (Dave Borowitz)
+
API CHANGES
* write_pack no longer takes the num_objects argument and requires an object
diff --git a/dulwich/objects.py b/dulwich/objects.py
index 26ebef4..a3c3d25 100644
--- a/dulwich/objects.py
+++ b/dulwich/objects.py
@@ -469,15 +469,15 @@ class ShaFile(object):
return "<%s %s>" % (self.__class__.__name__, self.id)
def __ne__(self, other):
- return self.id != other.id
+ return not isinstance(other, ShaFile) or self.id != other.id
def __eq__(self, other):
- """Return true if the sha of the two objects match.
+ """Return True if the SHAs of the two objects match.
- The __le__ etc methods aren't overriden as they make no sense,
- certainly at this level.
+ It doesn't make sense to talk about an order on ShaFiles, so we don't
+ override the rich comparison methods (__le__, etc.).
"""
- return self.id == other.id
+ return isinstance(other, ShaFile) and self.id == other.id
class Blob(ShaFile):
--
1.7.3.1
References