Commit c6aaca0f authored by Ximin Luo's avatar Ximin Luo

presenters: html: more intuitive "limit" flags, some backwards-incompatible changes:

--max-report-size:
  Old: in --html-dir this limited only the parent page
  New: in --html-dir this applies across all pages

--max-diff-block-lines:
  Old: in --html-dir 4 * this number applied across all pages (for a given diff block)
  New: in --html-dir this applies across all pages (for a given diff block)

--max-page-size:
  New flag
  Applies to the sole --html page, or the top-level --html-dir page

--max-report-child-size
  Renamed to
--max-page-size-child:
  No behavioural changes

--max-diff-block-lines-parent
  Renamed to
--max-page-diff-block-lines:
  Old: Only applied to the top-level --html-dir page
  New: Applies to the sole --html page, or the top-level --html-dir page

The reasoning behind these changes is that it's unlikely someone would want to
generate a 500MB single html page, but they might in theory generate a 500MB html
directory split up into several 200KB pages, plus a single 200KB html page as
a summary. The new semantics for these flags allows both to be generated in one
run using the same set of flags.
parent 9e222529
......@@ -20,16 +20,21 @@
class Config(object):
max_diff_block_lines = 256
max_diff_block_lines_parent = 50
max_diff_block_lines_saved = float("inf")
# html-dir output uses ratio * max-diff-block-lines as its limit
max_diff_block_lines_html_dir_ratio = 4
# GNU diff cannot process arbitrary large files :(
max_diff_input_lines = 2 ** 20
max_report_size = 2000 * 2 ** 10 # 2000 kB
max_diff_input_lines = 2 ** 22
max_diff_block_lines_saved = float("inf")
# hard limits, restricts single-file and multi-file formats
max_report_size = 40 * 2 ** 20 # 40 MB
max_diff_block_lines = 2 ** 10 # 1024 lines
# structural limits, restricts single-file formats
# semi-restricts multi-file formats
max_page_size = 400 * 2 ** 10 # 400 kB
max_page_size_child = 200 * 2 ** 10 # 200 kB
max_page_diff_block_lines = 2 ** 7 # 128 lines
max_text_report_size = 0
max_report_child_size = 500 * 2 ** 10
new_file = False
fuzzy_threshold = 60
enforce_constraints = True
......@@ -47,21 +52,13 @@ class Config(object):
def __setattr__(self, k, v):
super(Config, self).__setattr__(k, v)
if self.enforce_constraints:
self.check_constraints()
def check_ge(self, a, b):
va = getattr(self, a)
vb = getattr(self, b)
if va < vb:
raise ValueError("{0} ({1}) cannot be smaller than {2} ({3})".format(a, va, b, vb))
def check_constraints(self):
if self.max_diff_block_lines < self.max_diff_block_lines_parent: # noqa
raise ValueError("max_diff_block_lines ({0.max_diff_block_lines}) "
"cannot be smaller than max_diff_block_lines_parent "
"({0.max_diff_block_lines_parent})".format(self),
)
max_ = self.max_diff_block_lines_html_dir_ratio * \
self.max_diff_block_lines
if self.max_diff_block_lines_saved < max_: # noqa
raise ValueError("max_diff_block_lines_saved "
"({0.max_diff_block_lines_saved}) cannot be smaller than "
"{0.max_diff_block_lines_html_dir_ratio} * "
"max_diff_block_lines ({1})".format(self, max_),
)
self.check_ge("max_diff_block_lines", "max_page_diff_block_lines")
self.check_ge("max_report_size", "max_page_size")
self.check_ge("max_report_size", "max_page_size_child")
This diff is collapsed.
This diff is collapsed.
......@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
HEADER = """<!DOCTYPE html>
HEADER = u"""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
......@@ -147,12 +147,12 @@ HEADER = """<!DOCTYPE html>
<body class="diffoscope">
"""
FOOTER = """<div class="footer">Generated by <a href="https://diffoscope.org" rel="noopener noreferrer" target="_blank">diffoscope</a> %(version)s</div>
FOOTER = u"""<div class="footer">Generated by <a href="https://diffoscope.org" rel="noopener noreferrer" target="_blank">diffoscope</a> %(version)s</div>
</body>
</html>
"""
SCRIPTS = """<script src="%(jquery_url)s"></script>
SCRIPTS = u"""<script src="%(jquery_url)s"></script>
<script type="text/javascript">
$(function() {
// activate "loading" controls
......@@ -209,7 +209,10 @@ $(function() {
</script>
"""
DIFFNODE_LAZY_LOAD = """<div class="ondemand-details">... <a href="%s.html">load details</a> ...</div>
DIFFNODE_LAZY_LOAD = u"""<div class="ondemand-details">... <a href="%s.html">load details</a> ...</div>
"""
DIFFNODE_LIMIT = u"""<div class="error">Max report size reached</div>
"""
UD_TABLE_HEADER = u"""<table class="diff">
......@@ -220,5 +223,8 @@ UD_TABLE_HEADER = u"""<table class="diff">
UD_TABLE_FOOTER = u"""<tr class="ondemand"><td colspan="4">
... <a href="%(filename)s">%(text)s</a> ...
</td></tr>
</table>
"""
UD_TABLE_LIMIT_FOOTER = u"""<tr class="error"><td colspan="4">
Max %(limit_type)s reached; %(bytes_left)s/%(bytes_total)s bytes (%(percent).2f%%) of diff not shown.
</td></tr>"""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment