[diffoscope] 01/01: difference: has_children -> has_visible_children, and take into account comments

Ximin Luo infinity0 at debian.org
Wed Jun 14 17:25:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch WIP/humungous-diffs
in repository diffoscope.

commit 72f1158cbeb112e7d87c35652e4e05b2007855ea
Author: Ximin Luo <infinity0 at debian.org>
Date:   Wed Jun 14 19:24:28 2017 +0200

    difference: has_children -> has_visible_children, and take into account comments
    
    An earlier commit made the [+]/[-] behaviour also show/hide comments so we
    should add that logic to Difference as well. Also, we use the phrase "children"
    elsewhere to refer to only the _details, so use a different phrase here.
---
 diffoscope/difference.py           | 7 ++++---
 diffoscope/presenters/html/html.py | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 0436016..97340cf 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -126,11 +126,12 @@ class Difference(object):
                 sum(map(len, self.comments)) +
                 sum(v.size() for v in self._visuals))
 
-    def has_children(self):
-        """Whether there are children.
+    def has_visible_children(self):
+        """Whether there are visible children.
 
         Useful for e.g. choosing whether to display [+]/[-] controls."""
-        return self._unified_diff is not None or self._details or self._visuals
+        return (self._unified_diff is not None or
+                self._comments or self._details or self._visuals)
 
     def traverse_depth(self, depth=-1):
         yield self
diff --git a/diffoscope/presenters/html/html.py b/diffoscope/presenters/html/html.py
index f86db3e..e7ad83c 100644
--- a/diffoscope/presenters/html/html.py
+++ b/diffoscope/presenters/html/html.py
@@ -337,7 +337,7 @@ class HTMLPresenter(Presenter):
         print_func(u'<div class="difference">')
         try:
             print_func(u'<div class="diffheader">')
-            diffcontrol = ("diffcontrol", u'⊟') if difference.has_children() else ("diffcontrol-nochildren", u'⊡')
+            diffcontrol = ("diffcontrol", u'⊟') if difference.has_visible_children() else ("diffcontrol-nochildren", u'⊡')
             if difference.source1 == difference.source2:
                 print_func(u'<div class="%s">%s</div>' % diffcontrol)
                 print_func(u'<div><span class="source">%s</span>'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list