mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user