Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/LogOutputParser.java @ 152:7a908ba66ff3
Correctly parse comments with newlines inside
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 24 Feb 2011 21:36:52 +0100 |
parents | 6b55f10ef54b |
children | 934037edbea0 |
comparison
equal
deleted
inserted
replaced
151:305ee74c0aa6 | 152:7a908ba66ff3 |
---|---|
33 private final List<Record> result = new LinkedList<Record>(); | 33 private final List<Record> result = new LinkedList<Record>(); |
34 private Pattern pattern1; | 34 private Pattern pattern1; |
35 private Pattern pattern2; | 35 private Pattern pattern2; |
36 private Pattern pattern3; | 36 private Pattern pattern3; |
37 private Pattern pattern4; | 37 private Pattern pattern4; |
38 private Pattern pattern5; | |
38 | 39 |
39 public LogOutputParser(boolean outputWithDebug) { | 40 public LogOutputParser(boolean outputWithDebug) { |
40 if (outputWithDebug) { | 41 if (outputWithDebug) { |
41 pattern1 = Pattern.compile("^changeset:\\s+(\\d+):([a-f0-9]{40})\n(^tag:(.+)$)?", Pattern.MULTILINE); | 42 pattern1 = Pattern.compile("^changeset:\\s+(\\d+):([a-f0-9]{40})\n(^tag:(.+)$)?", Pattern.MULTILINE); |
42 pattern2 = Pattern.compile("^parent:\\s+(-?\\d+):([a-f0-9]{40})\n", Pattern.MULTILINE); | 43 pattern2 = Pattern.compile("^parent:\\s+(-?\\d+):([a-f0-9]{40})\n", Pattern.MULTILINE); |
43 pattern3 = Pattern.compile("^manifest:\\s+(\\d+):([a-f0-9]{40})\nuser:\\s+(\\S.+)\ndate:\\s+(\\S.+)\n", Pattern.MULTILINE); | 44 pattern3 = Pattern.compile("^manifest:\\s+(\\d+):([a-f0-9]{40})\nuser:\\s+(\\S.+)\ndate:\\s+(\\S.+)\n", Pattern.MULTILINE); |
44 pattern4 = Pattern.compile("^description:\n^(.+)\n\n", Pattern.MULTILINE); | 45 pattern4 = Pattern.compile("^description:\\n", Pattern.MULTILINE); |
46 pattern5 = Pattern.compile("\\n\\n"); | |
45 //p = "^manifest:\\s+(\\d+):([a-f0-9]{40})\nuser:(.+)$"; | 47 //p = "^manifest:\\s+(\\d+):([a-f0-9]{40})\nuser:(.+)$"; |
46 } else { | 48 } else { |
47 throw HgRepository.notImplemented(); | 49 throw HgRepository.notImplemented(); |
48 } | 50 } |
49 } | 51 } |
77 r.user = m.group(3); | 79 r.user = m.group(3); |
78 r.date = m.group(4); | 80 r.date = m.group(4); |
79 } | 81 } |
80 m.usePattern(pattern4); | 82 m.usePattern(pattern4); |
81 if (m.find()) { | 83 if (m.find()) { |
82 r.description = m.group(1); | 84 int commentStart = m.end(); |
85 m.usePattern(pattern5); | |
86 if (m.find()) { | |
87 r.description = seq.subSequence(commentStart, m.start()).toString(); | |
88 } | |
83 } | 89 } |
84 result.add(r); | 90 result.add(r); |
85 m.usePattern(pattern1); | 91 m.usePattern(pattern1); |
86 } | 92 } |
87 } | 93 } |