IDEA-101361 Copying file from hg ignored directory and adding it to VCS problem fixed.

*How to reproduce: try to copy unversioned or ignored file, then  hg ask you to add it to vcs,when you say "Yes" file will be copied,but not added to vcs. it happens because hg can't perform "hg copy" action with unversoned source file.
* if source file is not under vcs the copy command should be replaced by add command.
This commit is contained in:
Nadya.Zabrodina
2013-02-20 14:32:17 +04:00
parent 8746f58d43
commit 2192eaf0ea
2 changed files with 17 additions and 1 deletions
@@ -140,6 +140,22 @@ public class HgVFSListener extends VcsVFSListener {
@Override public void run(@NotNull ProgressIndicator aProgressIndicator) {
final ArrayList<VirtualFile> adds = new ArrayList<VirtualFile>();
final HashMap<VirtualFile, VirtualFile> copies = new HashMap<VirtualFile, VirtualFile>(); // from -> to
//delete unversioned and ignored files from copy source
if (myProject != null) {
Collection<VirtualFile> unversionedAndIgnoredFiles = new ArrayList<VirtualFile>();
final Map<VirtualFile, Collection<VirtualFile>> sortedSourceFilesByRepos = HgUtil.sortByHgRoots(myProject, copyFromMap.values());
HgStatusCommand statusCommand = new HgStatusCommand(myProject);
statusCommand.setOnlyUntrackedTrue();
statusCommand.setIncludeIgnored(true);
for (VirtualFile repo : sortedSourceFilesByRepos.keySet()) {
Set<HgChange> 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) {
@@ -187,7 +187,7 @@ public class HgStatusCommand {
return changes;
}
private void setOnlyUntrackedTrue() {
public void setOnlyUntrackedTrue() {
includeAdded = false;
includeModified = false;
includeRemoved = false;