}
private void process(BufferedReader in) throws IOException {
DateFormat df = repository.getDateFormat();
ArrayList<HistoryEntry> entries = new ArrayList<HistoryEntry>();
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
history = new History();
HistoryEntry entry = null;
ParseState state = ParseState.HEADER;
String s = in.readLine();
while (s != null) {
if (state == ParseState.HEADER) {
if (s.startsWith("commit")) {
if (entry != null) {
entries.add(entry);
}
entry = new HistoryEntry();
entry.setActive(true);
String commit = s.substring("commit".length()).trim();
entry.setRevision(commit);
} else if (s.startsWith("Author:") && entry != null) {
entry.setAuthor(s.substring("Author:".length()).trim());
} else if (s.startsWith("AuthorDate:") && entry != null) {
String dateString =
s.substring("AuthorDate:".length()).trim();
try {
entry.setDate(df.parse(dateString));
} catch (ParseException pe) {
OpenGrokLogger.getLogger().log(Level.WARNING, "Failed to parse author date: " + s, pe);
}
} else if (StringUtils.isOnlyWhitespace(s)) {
// We are done reading the heading, start to read the message
state = ParseState.MESSAGE;
// The current line is empty - the message starts on the next line (to be parsed below).
s = in.readLine();
}
}
if (state == ParseState.MESSAGE) {
if ((s.length() == 0) || Character.isWhitespace(s.charAt(0))) {
if (entry != null) {
entry.appendMessage(s);
}
} else {
// This is the list of files after the message - add them
state = ParseState.FILES;
}
}
if (state == ParseState.FILES) {
if (StringUtils.isOnlyWhitespace(s) || s.startsWith("commit")) {
state = ParseState.HEADER;
continue; // Parse this line again - do not read a new line
}
if (entry != null) {
try {
File f = new File(myDir, s);
entry.addFile(env.getPathRelativeToSourceRoot(f, 0));
} catch (FileNotFoundException e) { //NOPMD
// If the file is not located under the source root,
// ignore it (bug #11664).
}
}