Mercurial > hg
comparison mercurial/patch.py @ 24346:31edcea517c1
record: add comparison methods for recordhunk class
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Fri, 13 Mar 2015 14:08:30 -0700 |
parents | 616c01b69898 |
children | 8a997bd73448 |
comparison
equal
deleted
inserted
replaced
24345:01b39149ebb3 | 24346:31edcea517c1 |
---|---|
890 self.fromline, self.before = trimcontext(fromline, before) | 890 self.fromline, self.before = trimcontext(fromline, before) |
891 self.toline, self.after = trimcontext(toline, after) | 891 self.toline, self.after = trimcontext(toline, after) |
892 self.proc = proc | 892 self.proc = proc |
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 | |
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)) | |
895 | 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] == '+']) |
899 rem = len([h for h in hunk if h[0] == '-']) | 914 rem = len([h for h in hunk if h[0] == '-']) |