use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class CvsRollbackEnvironment method rollbackChanges.
public void rollbackChanges(List<Change> changes, final List<VcsException> exceptions, @NotNull final RollbackProgressListener listener) {
listener.determinate();
for (Change change : changes) {
final FilePath filePath = ChangesUtil.getFilePath(change);
listener.accept(change);
final VirtualFile parent = filePath.getVirtualFileParent();
final String name = filePath.getName();
switch(change.getType()) {
case DELETED:
restoreFile(parent, name);
break;
case MODIFICATION:
restoreFile(parent, name);
break;
case MOVED:
CvsUtil.removeEntryFor(CvsVfsUtil.getFileFor(parent, name));
break;
case NEW:
CvsUtil.removeEntryFor(CvsVfsUtil.getFileFor(parent, name));
break;
}
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class TagsHelper method findVcsRoots.
public static Collection<FilePath> findVcsRoots(FilePath[] files, Project project) {
if (files.length == 0) {
return Collections.emptyList();
}
final Collection<FilePath> roots = new HashSet<>();
final Set<VirtualFile> seen = new HashSet<>();
for (FilePath filePath : files) {
final VirtualFile root = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(filePath);
if (root == null || !seen.add(root)) {
continue;
}
roots.add(VcsContextFactory.SERVICE.getInstance().createFilePathOn(root));
}
return roots;
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class UpdateOperation method fileIsUnderProject.
@Override
public boolean fileIsUnderProject(File file) {
final FilePath path = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file);
if (!super.fileIsUnderProject(file)) {
return false;
}
final AbstractVcs vcs = ApplicationManager.getApplication().runReadAction(new Computable<AbstractVcs>() {
@Nullable
public AbstractVcs compute() {
return myVcsManager.getVcsFor(path);
}
});
return vcs == myVcs;
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class RTagOperation method createOn.
public static RTagOperation[] createOn(FilePath[] files, String tagName, boolean overrideExisting) {
Map<CvsEnvironment, List<File>> envToFiles = new HashMap<>();
for (FilePath file : files) {
CvsConnectionSettings cvsConnectionSettings = CvsUtil.getCvsConnectionSettings(file);
if (!envToFiles.containsKey(cvsConnectionSettings))
envToFiles.put(cvsConnectionSettings, new ArrayList<>());
envToFiles.get(cvsConnectionSettings).add(file.getIOFile());
}
ArrayList<RTagOperation> result = new ArrayList<>();
for (CvsEnvironment cvsEnvironment : envToFiles.keySet()) {
RTagOperation rTagOperation = new RTagOperation(cvsEnvironment, tagName, overrideExisting);
result.add(rTagOperation);
List<File> iofiles = envToFiles.get(cvsEnvironment);
for (File file : iofiles) {
rTagOperation.addFile(file);
}
}
return result.toArray(new RTagOperation[result.size()]);
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class CommandCvsHandler method createCommitHandler.
public static CvsHandler createCommitHandler(FilePath[] selectedFiles, String commitMessage, String title, boolean makeNewFilesReadOnly, Project project, final boolean tagFilesAfterCommit, final String tagName, @NotNull final List<File> dirsToPrune) {
final CommitFilesOperation operation = new CommitFilesOperation(commitMessage, makeNewFilesReadOnly);
if (selectedFiles != null) {
for (FilePath selectedFile : selectedFiles) {
operation.addFile(selectedFile.getIOFile());
}
}
if (!dirsToPrune.isEmpty()) {
operation.addFinishAction(() -> {
final IOFilesBasedDirectoryPruner pruner = new IOFilesBasedDirectoryPruner(null);
for (File dir : dirsToPrune) {
pruner.addFile(dir);
}
pruner.execute();
});
}
final CommandCvsHandler result = new CommandCvsHandler(title, operation, FileSetToBeUpdated.selectedFiles(selectedFiles));
if (tagFilesAfterCommit) {
result.addOperation(new TagOperation(selectedFiles, tagName, false, CvsConfiguration.getInstance(project).OVERRIDE_EXISTING_TAG_FOR_PROJECT));
}
return result;
}
Aggregations