diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java index e8ef1fa502cd..1f1be2056375 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVFSListener.java @@ -140,6 +140,22 @@ public class HgVFSListener extends VcsVFSListener { @Override public void run(@NotNull ProgressIndicator aProgressIndicator) { final ArrayList adds = new ArrayList(); final HashMap copies = new HashMap(); // from -> to + //delete unversioned and ignored files from copy source + if (myProject != null) { + Collection unversionedAndIgnoredFiles = new ArrayList(); + final Map> sortedSourceFilesByRepos = HgUtil.sortByHgRoots(myProject, copyFromMap.values()); + HgStatusCommand statusCommand = new HgStatusCommand(myProject); + statusCommand.setOnlyUntrackedTrue(); + statusCommand.setIncludeIgnored(true); + for (VirtualFile repo : sortedSourceFilesByRepos.keySet()) { + Set changes = statusCommand.execute(repo); + for (HgChange change : changes) { + unversionedAndIgnoredFiles.add(change.afterFile().toFilePath().getVirtualFile()); + } + } + copyFromMap.values().removeAll(unversionedAndIgnoredFiles); + } + // separate adds from copies for (VirtualFile file : addedFiles) { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java index 9c469657ad98..3d377e9155c6 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgStatusCommand.java @@ -187,7 +187,7 @@ public class HgStatusCommand { return changes; } - private void setOnlyUntrackedTrue() { + public void setOnlyUntrackedTrue() { includeAdded = false; includeModified = false; includeRemoved = false;