IDEA-93398 Commit file to Mercurial repository throws exception.

*How to reproduce: make one repo inside another. Inner repository has many revisions. Outer repository has no committed and created files. Next, create new file in outer repo, try to type smth or copy/past in active editor, thus  base revision will be empty, but not null-> produce exception
 *Refactor  parseChangeFromResult method for future easy debugging such exception.(remember arguments)
This commit is contained in:
Nadya.Zabrodina
2012-11-27 12:13:07 +04:00
parent 91082a45d4
commit be5b2a3aef
@@ -125,9 +125,9 @@ public class HgStatusCommand {
if (includeCopySource) {
options.add("--copies");
}
if (baseRevision != null) {
if (baseRevision != null && !baseRevision.getRevision().isEmpty()) {
options.add("--rev");
options.add(baseRevision.getChangeset().equals("") ? baseRevision.getRevision() : baseRevision.getChangeset());
options.add(baseRevision.getChangeset().isEmpty() ? baseRevision.getRevision() : baseRevision.getChangeset());
if (targetRevision != null) {
options.add("--rev");
options.add(targetRevision.getChangeset());
@@ -143,16 +143,16 @@ public class HgStatusCommand {
args.addAll(options);
args.addAll(chunk);
HgCommandResult result = executor.executeInCurrentThread(repo, "status", args);
changes.addAll(parseChangesFromResult(repo, result));
changes.addAll(parseChangesFromResult(repo, result, args));
}
} else {
HgCommandResult result = executor.executeInCurrentThread(repo, "status", options);
changes.addAll(parseChangesFromResult(repo, result));
changes.addAll(parseChangesFromResult(repo, result, options));
}
return changes;
}
private static Collection<HgChange> parseChangesFromResult(VirtualFile repo, HgCommandResult result) {
private static Collection<HgChange> parseChangesFromResult(VirtualFile repo, HgCommandResult result, List<String> args) {
final Set<HgChange> changes = new HashSet<HgChange>();
HgChange previous = null;
if (result == null) {
@@ -166,7 +166,7 @@ public class HgStatusCommand {
char statusChar = line.charAt(STATUS_INDEX);
HgFileStatusEnum status = HgFileStatusEnum.parse(statusChar);
if (status == null) {
LOG.error("Unknown status [" + statusChar + "] in line [" + line + "]");
LOG.error("Unknown status [" + statusChar + "] in line [" + line + "]" + "\n with arguments " + args);
continue;
}
File ioFile = new File(repo.getPath(), line.substring(2));