[diffoscope] 05/05: Distinguish between a full vs truncated set of pieces

Chris Lamb chris at chris-lamb.co.uk
Mon Jan 9 17:31:23 CET 2017


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

lamby pushed a commit to branch better-lazy-loading
in repository diffoscope.

commit 04a0b90b39c52cb1a75f540c6457696b0afdcd2b
Author: Ximin Luo <infinity0 at debian.org>
Date:   Thu Aug 25 13:00:56 2016 +0200

    Distinguish between a full vs truncated set of pieces
---
 diffoscope/presenters/html.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/diffoscope/presenters/html.py b/diffoscope/presenters/html.py
index 2470707..bb1bc14 100644
--- a/diffoscope/presenters/html.py
+++ b/diffoscope/presenters/html.py
@@ -170,8 +170,11 @@ SCRIPTS = """
 $(function() {
   var load_cont = function() {
     var a = $(this);
+    var textparts = /^(.*)\((\d+) pieces?(.*)\)$/.exec(a.text());
+    var numleft = Number.parseInt(textparts[2]) - 1;
+    var noun = numleft == 1 ? "piece" : "pieces";
+    var newtext = textparts[1] + "(" + numleft + " " + noun + textparts[3] + ")";
     var filename = a.attr('href');
-    var numleft = Number.parseInt(/\((\d+) pieces?\)/.exec(a.text())[1]) - 1
     var td = a.parent();
     td.text('... loading ...');
     td.parent().load(filename + " tr", function() {
@@ -179,8 +182,7 @@ $(function() {
         var elems = $(this).children(':first').unwrap();
         // set this behaviour for the next link too
         var a = elems.parent().find(".ondemand a");
-        var noun = numleft > 1 ? "pieces" : "piece" // be sure the regex matches either
-        a.text(a.text() + " (" + numleft + " " + noun + ")");
+        a.text(newtext);
         a.on('click', load_cont);
     });
     return false;
@@ -596,12 +598,14 @@ def output_unified_diff(print_func, css_url, directory, unified_diff, has_intern
         filename="%s.html" % mainname
         logger.debug('separate html output for diff of size %d', len(unified_diff))
         num_pages = 0
+        truncated = False
         rows_per_page = estimate_num_rows_per_page(Config.general.separate_file_diff_size)
         rotation_params = directory, mainname, css_url, rows_per_page
         try:
             spl_print_enter(spl_file_printer(directory, filename), rotation_params)
             output_unified_diff_table(unified_diff, has_internal_linenos)
         except PrintLimitReached:
+            truncated = True
             spl_print_func(u"<table><tr class='error'><td colspan='4'>Max output size reached.</td></tr></table>",
                            force=True)
             spl_print_exit(None, None, None) # swallow
@@ -612,8 +616,9 @@ def output_unified_diff(print_func, css_url, directory, unified_diff, has_intern
         finally:
             num_pages = spl_current_page + 1
 
+        text = "load diff (%s pieces%s)" % (num_pages, (", truncated" if truncated else ""))
         print_func(UD_TABLE_HEADER, force=True)
-        print_func(UD_TABLE_FOOTER % {"filename": escape(filename), "text": "load diff (%s pieces)" % num_pages}, force=True)
+        print_func(UD_TABLE_FOOTER % {"filename": escape(filename), "text": text}, force=True)
 
     else:
         try:

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


More information about the diffoscope mailing list