Skip to content

Commit 40f0801

Browse files
committed
refactor tag parsing into new method
1 parent 4b34795 commit 40f0801

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/CVSHistoryParser.java

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,7 @@ public void processStream(InputStream input) throws IOException {
7676
}
7777
if (state == ParseState.TAG) {
7878
if (s.startsWith("\t")) {
79-
String[] pair = s.trim().split(": ");
80-
if (pair.length != 2) {
81-
//
82-
// Overriding processStream() thus need to comply with the
83-
// set of exceptions it can throw.
84-
//
85-
throw new IOException("Failed to parse tag: '" + s + "'");
86-
} else {
87-
if (tags.containsKey(pair[1])) {
88-
// Join multiple tags for one revision
89-
String oldtag = tags.get(pair[1]);
90-
tags.remove(pair[1]);
91-
tags.put(pair[1], oldtag + " " + pair[0]);
92-
} else {
93-
tags.put(pair[1], pair[0]);
94-
}
95-
}
79+
parseTag(tags, s);
9680
} else {
9781
state = ParseState.REVISION;
9882
s = in.readLine();
@@ -158,6 +142,26 @@ public void processStream(InputStream input) throws IOException {
158142
history.setHistoryEntries(entries);
159143
}
160144

145+
private void parseTag(HashMap<String, String> tags, String s) throws IOException {
146+
String[] pair = s.trim().split(": ");
147+
if (pair.length != 2) {
148+
//
149+
// Overriding processStream() thus need to comply with the
150+
// set of exceptions it can throw.
151+
//
152+
throw new IOException("Failed to parse tag: '" + s + "'");
153+
} else {
154+
if (tags.containsKey(pair[1])) {
155+
// Join multiple tags for one revision
156+
String oldTag = tags.get(pair[1]);
157+
tags.remove(pair[1]);
158+
tags.put(pair[1], oldTag + " " + pair[0]);
159+
} else {
160+
tags.put(pair[1], pair[0]);
161+
}
162+
}
163+
}
164+
161165
/**
162166
* Sort history entries in the object according to semantic ordering of the revision string.
163167
* @param history {@link History} object

0 commit comments

Comments
 (0)