use of org.zmlx.hg4idea.HgFileStatusEnum in project intellij-community by JetBrains.
the class HgStatusCommand method parseChangesFromResult.
private Collection<HgChange> parseChangesFromResult(VirtualFile repo, HgCommandResult result, List<String> args) {
final Set<HgChange> changes = new HashSet<>();
HgChange previous = null;
if (result == null) {
return changes;
}
List<String> errors = result.getErrorLines();
if (!errors.isEmpty()) {
if (result.getExitValue() != 0 && !myProject.isDisposed()) {
String title = "Could not execute hg status command ";
LOG.warn(title + errors.toString());
VcsNotifier.getInstance(myProject).logInfo(title, errors.toString());
return changes;
}
LOG.warn(errors.toString());
}
for (String line : result.getOutputLines()) {
if (StringUtil.isEmptyOrSpaces(line) || line.length() < ITEM_COUNT) {
LOG.warn("Unexpected line in status '" + line + '\'');
continue;
}
char statusChar = line.charAt(STATUS_INDEX);
HgFileStatusEnum status = HgFileStatusEnum.parse(statusChar);
if (status == null) {
LOG.error("Unknown status [" + statusChar + "] in line [" + line + "]" + "\n with arguments " + args);
continue;
}
File ioFile = new File(repo.getPath(), line.substring(2));
if (HgFileStatusEnum.COPY == status && previous != null && previous.getStatus() == HgFileStatusEnum.ADDED) {
previous.setStatus(HgFileStatusEnum.COPY);
previous.setBeforeFile(new HgFile(repo, ioFile));
previous = null;
} else {
previous = new HgChange(new HgFile(repo, ioFile), status);
changes.add(previous);
}
}
return changes;
}
Aggregations