[diffoscope] 01/01: difference: also copy self._comment properly, compare self._visuals in equals()
Ximin Luo
infinity0 at debian.org
Thu Sep 21 18:33:41 CEST 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository diffoscope.
commit f5c9986bfbb4c89f78162a5f6f417994d555e63c
Author: Ximin Luo <infinity0 at debian.org>
Date: Thu Sep 21 18:32:56 2017 +0200
difference: also copy self._comment properly, compare self._visuals in equals()
---
diffoscope/difference.py | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 274f348..88c6244 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -77,7 +77,7 @@ class Difference(object):
"".join(map(f_diff, diff_split_lines(unified_diff))) if unified_diff is not None else None,
self.source1,
self.source2,
- comment=["".join(map(f_comment, diff_split_lines(comment))) for comment in self.comments],
+ comment=["".join(map(f_comment, diff_split_lines(comment))) for comment in self._comments],
has_internal_linenos=self.has_internal_linenos,
details=self._details[:],
visuals=self._visuals[:],
@@ -88,7 +88,7 @@ class Difference(object):
self.unified_diff,
self.source1,
self.source2,
- comment=self.comments,
+ comment=self._comments[:],
has_internal_linenos=self.has_internal_linenos,
details=[d.fmap(f) for d in self._details],
visuals=self._visuals[:],
@@ -104,7 +104,7 @@ class Difference(object):
reverse_unified_diff(self.unified_diff) if self.unified_diff is not None else None,
self.source2,
self.source1,
- comment=self.comments,
+ comment=self._comments, # already copied by fmap in get_reverse
has_internal_linenos=self.has_internal_linenos,
details=self._details, # already reversed by fmap in get_reverse, no need to copy
)
@@ -118,9 +118,10 @@ class Difference(object):
self.unified_diff == other.unified_diff and
self.source1 == other.source1 and
self.source2 == other.source2 and
- self.comments == other.comments and
+ self._comments == other._comments and
self.has_internal_linenos == other.has_internal_linenos and
- all(x.equals(y) for x, y in zip(self.details, other.details)))
+ all(x.equals(y) for x, y in zip(self._details, other._details)) and
+ all(x.equals(y) for x, y in zip(self._visuals, other._visuals)))
def size(self):
if self._size_cache is None:
@@ -345,3 +346,9 @@ class VisualDifference(object):
def size(self):
return len(self.data_type) + len(self.content) + len(self.source)
+
+ def equals(self, other):
+ return self == other or (
+ self._data_type == other._data_type and
+ self._content == other._content and
+ self._source == other._source)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list