19
19
20
20
/*
21
21
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
22
+ * Portions Copyright (c) 2020, Chris Fraire <[email protected] >.
22
23
*/
23
24
package org .opengrok .indexer .history ;
24
25
@@ -49,19 +50,23 @@ public class PerforceAnnotationParser implements Executor.StreamHandler {
49
50
*/
50
51
private final Annotation annotation ;
51
52
53
+ private final PerforceRepository repo ;
54
+
52
55
private final File file ;
53
56
54
57
private final String rev ;
55
58
56
59
private static final Pattern ANNOTATION_PATTERN
57
60
= Pattern .compile ("^(\\ d+): .*" );
58
-
61
+
59
62
/**
63
+ * @param repo defined instance
60
64
* @param file the file being annotated
61
65
* @param rev revision to be annotated
62
66
*/
63
- public PerforceAnnotationParser (File file , String rev ) {
67
+ public PerforceAnnotationParser (PerforceRepository repo , File file , String rev ) {
64
68
annotation = new Annotation (file .getName ());
69
+ this .repo = repo ;
65
70
this .file = file ;
66
71
this .rev = rev ;
67
72
}
@@ -77,8 +82,9 @@ public Annotation getAnnotation() {
77
82
78
83
@ Override
79
84
public void processStream (InputStream input ) throws IOException {
80
- List <HistoryEntry > revisions
81
- = PerforceHistoryParser .getRevisions (file , rev ).getHistoryEntries ();
85
+ // Pass null for revision to get all history for the file.
86
+ PerforceHistoryParser parser = new PerforceHistoryParser (repo );
87
+ List <HistoryEntry > revisions = parser .getRevisions (file , null ).getHistoryEntries ();
82
88
HashMap <String , String > revAuthor = new HashMap <>();
83
89
for (HistoryEntry entry : revisions ) {
84
90
// a.addDesc(entry.getRevision(), entry.getMessage());
@@ -90,6 +96,11 @@ public void processStream(InputStream input) throws IOException {
90
96
try (BufferedReader reader = new BufferedReader (new InputStreamReader (input ))) {
91
97
while ((line = reader .readLine ()) != null ) {
92
98
++lineno ;
99
+ if (line .equals ("(... files differ ...)" )) {
100
+ // Perforce knows as a binary file?
101
+ continue ;
102
+ }
103
+
93
104
Matcher matcher = ANNOTATION_PATTERN .matcher (line );
94
105
if (matcher .find ()) {
95
106
String revision = matcher .group (1 );
0 commit comments