Commit 8a4729c9 authored by Ximin Luo's avatar Ximin Luo

html-dir: use 4 * the given max-diff-block-lines

This way, --html x.html --html-dir x gives reasonable output for both.

The hardcoded ratio could be another flag, but I think we have enough flags.
parent 35d48f9d
......@@ -27,9 +27,11 @@ class classproperty(property):
class Config(object):
def __init__(self):
self._max_diff_block_lines = 1024
self._max_diff_block_lines = 256
self._max_diff_block_lines_parent = 50
self._max_diff_block_lines_saved = float("inf")
# html-dir output uses ratio * max-diff-block-lines as its limit
self._max_diff_block_lines_html_dir_ratio = 4
self._max_diff_input_lines = 2 ** 20 # GNU diff cannot process arbitrary large files :(
self._max_report_size = 2000 * 2 ** 10 # 2000 kB
self._max_report_child_size = 500 * 2 ** 10
......@@ -46,9 +48,10 @@ class Config(object):
if self._max_diff_block_lines < self._max_diff_block_lines_parent:
raise ValueError("max_diff_block_lines (%s) cannot be smaller than max_diff_block_lines_parent (%s)" %
(self._max_diff_block_lines, self._max_diff_block_lines_parent))
if self._max_diff_block_lines_saved < self._max_diff_block_lines:
raise ValueError("max_diff_block_lines_saved (%s) cannot be smaller than max_diff_block_lines (%s)" %
(self._max_diff_block_lines_saved, self._max_diff_block_lines))
m = self._max_diff_block_lines_html_dir_ratio
if self._max_diff_block_lines_saved < m * self._max_diff_block_lines:
raise ValueError("max_diff_block_lines_saved (%s) cannot be smaller than %d*max_diff_block_lines (%s)" %
(self._max_diff_block_lines_saved, m, m*self._max_diff_block_lines))
@property
def max_diff_block_lines(self):
......@@ -77,6 +80,10 @@ class Config(object):
self._max_diff_block_lines_saved = value
self._check_constraints()
@property
def max_diff_block_lines_html_dir_ratio(self):
return self._max_diff_block_lines_html_dir_ratio
@property
def max_diff_input_lines(self):
return self._max_diff_input_lines
......
......@@ -86,9 +86,11 @@ def create_parser():
Config.general.max_report_child_size, 50000)
parser.add_argument('--max-diff-block-lines', dest='max_diff_block_lines',
metavar='LINES', type=int,
help='Maximum number of lines output per diff block, '
'across the whole report. (0 to disable, default: %d)' %
Config.general.max_diff_block_lines,
help='Maximum number of lines output per diff block. '
'In html-dir output, we use %d * this number instead, '
'taken over all pages. (0 to disable, default: %d)' %
(Config.general.max_diff_block_lines_html_dir_ratio,
Config.general.max_diff_block_lines),
default=None).completer=RangeCompleter(0,
Config.general.max_diff_block_lines, 5)
parser.add_argument('--max-diff-block-lines-parent', dest='max_diff_block_lines_parent',
......
......@@ -495,6 +495,7 @@ def row_was_output():
_, rotation_params = spl_print_ctrl
max_lines = Config.general.max_diff_block_lines
max_lines_parent = Config.general.max_diff_block_lines_parent
max_lines_ratio = Config.general.max_diff_block_lines_html_dir_ratio
max_report_child_size = Config.general.max_report_child_size
if not rotation_params:
# html-dir single output, don't need to rotate
......@@ -504,7 +505,7 @@ def row_was_output():
else:
# html-dir output, perhaps need to rotate
directory, mainname, css_url = rotation_params
if spl_rows >= max_lines:
if spl_rows >= max_lines_ratio * max_lines:
raise DiffBlockLimitReached()
if spl_current_page == 0: # on parent page
......
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