public void execute() {
try {
executeCommand();
} catch (IOException e) {
//noinspection ThrowableInstanceNeverThrown
errors.add(new VcsException(e));
return;
}
Pattern wholeLinePattern = Pattern.compile(wholeLinePatternString);
BufferedReader reader = new BufferedReader(new StringReader(commandOutput));
try {
String firstLine = reader.readLine();
if (firstLine == null || !VcsUtil.getFilePath(member).equals(VcsUtil.getFilePath(firstLine))) {
LOGGER.warn("unexpected command output " + commandOutput + ", first line is expected to be " + member);
} else {
String line;
while ((line = reader.readLine()) != null) {
Matcher matcher = wholeLinePattern.matcher(line);
try {
if (matcher.matches()) {
String rev = matcher.group(REVISION_IDX);
String date = matcher.group(DATE_IDX);
String cpid = matcher.group(CPID_IDX);
String author = matcher.group(AUTHOR_IDX);
String description = matcher.group(DESCRIPTION_IDX);
MksMemberRevisionInfo info = new MksMemberRevisionInfo();
info.setRevision(createRevision(rev));
info.setDate(parseDate(date, true));
info.setCPID(cpid);
info.setAuthor(author);
info.setDescription(description);
revisionsInfo.add(info);
} else if (line.startsWith("Member added")) {
// ignore this line
// Don't ignore the following ones
} else if (revisionsInfo.size() >= 1) {
LOGGER.debug("assuming multiline comment :" + line);
final MksMemberRevisionInfo info = revisionsInfo.get(revisionsInfo.size() - 1);
info.setDescription(info.getDescription() + "\n" + line);
} else {
//noinspection ThrowableInstanceNeverThrown
errors.add(new VcsException("ViewMemberHistory: unexpected line [" + line + "]"));
}
} catch (VcsException e) {
errors.add(e);
}
}
}
} catch (IOException e) {
//noinspection ThrowableInstanceNeverThrown
errors.add(new VcsException(e));
}
}