From 56c16165be3bbb85ae817ac1afdb04adac0875ff Mon Sep 17 00:00:00 2001 From: Samuel Bronson Date: Sat, 18 Jul 2009 19:07:37 -0400 Subject: Add a test for bug #400960. --- tests/test_parser.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_parser.py b/tests/test_parser.py index ac5239e..91e27f0 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -101,6 +101,14 @@ author now committer now data 20 first commit, empty +# Test a commit with a heredoc-style (delimited_data) messsage (bug #400960) +commit refs/heads/master +mark :4 +author now +committer now +data < Date: Sat, 18 Jul 2009 19:09:23 -0400 Subject: Implement here-document style input data. Fixes bug #400960. --- parser.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/parser.py b/parser.py index 4897fa0..b93fc9d 100644 --- a/parser.py +++ b/parser.py @@ -88,7 +88,8 @@ The grammar is: # note: delim may be any string but must not contain lf. # data_line may contain any data but must not be exactly - # delim. + # delim. The lf after the final data_line is included in + # the data. delimited_data ::= 'data' sp '<<' delim lf (data_line lf)* delim lf; @@ -234,7 +235,16 @@ class LineBasedParser(object): :return: the bytes read up to but excluding the terminator. """ - raise NotImplementedError(self.read_until) + + lines = [] + term = terminator + '\n' + while True: + line = self.input.readline() + if line == term: + break + else: + lines.append(line) + return ''.join(lines) # Regular expression used for parsing. (Note: The spec states that the name -- cgit v1.2.1