##// END OF EJS Templates
record: add comparison methods for recordhunk class
Laurent Charignon -
r24346:31edcea5 default
parent child Browse files
Show More
@@ -893,6 +893,21 b' class recordhunk(object):'
893 self.hunk = hunk
893 self.hunk = hunk
894 self.added, self.removed = self.countchanges(self.hunk)
894 self.added, self.removed = self.countchanges(self.hunk)
895
895
896 def __eq__(self, v):
897 if not isinstance(v, recordhunk):
898 return False
899
900 return ((v.hunk == self.hunk) and
901 (v.proc == self.proc) and
902 (self.fromline == v.fromline) and
903 (self.header.files() == v.header.files()))
904
905 def __hash__(self):
906 return hash((tuple(self.hunk),
907 tuple(self.header.files()),
908 self.fromline,
909 self.proc))
910
896 def countchanges(self, hunk):
911 def countchanges(self, hunk):
897 """hunk -> (n+,n-)"""
912 """hunk -> (n+,n-)"""
898 add = len([h for h in hunk if h[0] == '+'])
913 add = len([h for h in hunk if h[0] == '+'])
General Comments 0
You need to be logged in to leave comments. Login now