From be5b2a3aefb4d021f444ee009ac0424bc287d7f0 Mon Sep 17 00:00:00 2001 From: "Nadya.Zabrodina" Date: Tue, 27 Nov 2012 12:04:46 +0400 Subject: [PATCH] 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) --- .../org/zmlx/hg4idea/command/HgStatusCommand.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java index c37ab457ad92..d0f62c7bbce8 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java @@ -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 parseChangesFromResult(VirtualFile repo, HgCommandResult result) { + private static Collection parseChangesFromResult(VirtualFile repo, HgCommandResult result, List args) { final Set changes = new HashSet(); 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));