Search in sources :

Example 61 with FilePath

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;
        }
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Change(com.intellij.openapi.vcs.changes.Change)

Example 62 with FilePath

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;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) HashSet(com.intellij.util.containers.HashSet)

Example 63 with FilePath

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;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) Nullable(org.jetbrains.annotations.Nullable)

Example 64 with FilePath

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()]);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) HashMap(com.intellij.util.containers.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CvsEnvironment(com.intellij.cvsSupport2.connections.CvsEnvironment) CvsConnectionSettings(com.intellij.cvsSupport2.connections.CvsConnectionSettings) File(java.io.File)

Example 65 with FilePath

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;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) CommitFilesOperation(com.intellij.cvsSupport2.cvsoperations.cvsCommit.CommitFilesOperation) TagOperation(com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.TagOperation) VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsLightweightFile(com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile) File(java.io.File)

Aggregations

FilePath (com.intellij.openapi.vcs.FilePath)167 VirtualFile (com.intellij.openapi.vfs.VirtualFile)68 NotNull (org.jetbrains.annotations.NotNull)43 VcsException (com.intellij.openapi.vcs.VcsException)34 File (java.io.File)30 Change (com.intellij.openapi.vcs.changes.Change)26 Nullable (org.jetbrains.annotations.Nullable)22 Project (com.intellij.openapi.project.Project)20 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)15 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)13 FileStatus (com.intellij.openapi.vcs.FileStatus)10 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)8 GitRepository (git4idea.repo.GitRepository)7 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Test (org.junit.Test)6 StringUtil (com.intellij.openapi.util.text.StringUtil)5 Logger (com.intellij.openapi.diagnostic.Logger)4