[Reproducible-commits] [debbindiff] 04/04: Stop processing diff output after too many lines
Jérémy Bobbio
lunar at moszumanska.debian.org
Sat Mar 28 14:52:29 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository debbindiff.
commit 9c176a26927fce4367a7fde0d22af6d4b1f529fc
Author: Jérémy Bobbio <lunar at debian.org>
Date: Sat Mar 28 15:50:13 2015 +0100
Stop processing diff output after too many lines
---
debbindiff/difference.py | 15 ++++++++++++++-
debbindiff/presenters/html.py | 4 ++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/debbindiff/difference.py b/debbindiff/difference.py
index 9fae386..4d3e689 100644
--- a/debbindiff/difference.py
+++ b/debbindiff/difference.py
@@ -28,6 +28,7 @@ from debbindiff import logger, tool_required, RequiredToolNotFound
MAX_DIFF_BLOCK_LINES = 50
+MAX_DIFF_LINES = 10000
class DiffParser(object):
@@ -37,6 +38,8 @@ class DiffParser(object):
self._output = output
self._action = self.read_headers
self._diff = ''
+ self._success = False
+ self._line_count = 0
self._remaining_hunk_lines = None
self._block_len = None
self._direction = None
@@ -45,9 +48,19 @@ class DiffParser(object):
def diff(self):
return self._diff
+ @property
+ def success(self):
+ return self._success
+
def parse(self):
for line in iter(self._output.readline, b''):
+ self._line_count += 1
+ if self._line_count >= MAX_DIFF_LINES:
+ self._diff += '\n[ Processing stopped after %d lines. ]' % self._line_count
+ break
self._action = self._action(line.decode('utf-8'))
+ self._success = True
+ self._output.close()
def read_headers(self, line):
found = DiffParser.RANGE_RE.match(line)
@@ -154,7 +167,7 @@ def diff(content1, content2):
t_write2.join()
t_read.join()
p.wait()
- if p.returncode not in (0, 1):
+ if not parser.success and p.returncode not in (0, 1):
raise subprocess.CalledProcessError(cmd, p.returncode, output=diff)
return parser.diff
diff --git a/debbindiff/presenters/html.py b/debbindiff/presenters/html.py
index f0fc273..1c1295a 100644
--- a/debbindiff/presenters/html.py
+++ b/debbindiff/presenters/html.py
@@ -410,6 +410,10 @@ def output_unified_diff(print_func, unified_diff):
output_hunk(print_func)
continue
+ if re.match(r'^\[', l):
+ empty_buffer(print_func)
+ print_func(u'<td colspan="2">%s</td>\n' % l)
+
if re.match(r"^\\ No newline", l):
if hunk_size2 == 0:
buf[-1] = (buf[-1][0], buf[-1][1] + '\n' + l[2:])
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git
More information about the Reproducible-commits
mailing list