Search in sources :

Example 1 with AbstractVcsHelper

use of com.intellij.openapi.vcs.AbstractVcsHelper in project intellij-community by JetBrains.

the class BasicAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
    if (isEmpty(files))
        return;
    SvnVcs vcs = SvnVcs.getInstance(project);
    if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, files))
        return;
    project.save();
    String actionName = getActionName();
    LocalHistoryAction action = LocalHistory.getInstance().startAction(actionName);
    AbstractVcsHelper helper = AbstractVcsHelper.getInstance(project);
    try {
        List<VcsException> exceptions = helper.runTransactionRunnable(vcs, exceptionList -> {
            VirtualFile badFile = null;
            try {
                if (isBatchAction()) {
                    batchExecute(vcs, files, e.getDataContext());
                } else {
                    for (VirtualFile file : files) {
                        badFile = file;
                        execute(vcs, file, e.getDataContext());
                    }
                }
            } catch (VcsException ex) {
                ex.setVirtualFile(badFile);
                exceptionList.add(ex);
            }
        }, null);
        helper.showErrors(exceptions, actionName);
    } finally {
        action.finish();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) AbstractVcsHelper(com.intellij.openapi.vcs.AbstractVcsHelper) VcsException(com.intellij.openapi.vcs.VcsException) LocalHistoryAction(com.intellij.history.LocalHistoryAction) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 2 with AbstractVcsHelper

use of com.intellij.openapi.vcs.AbstractVcsHelper in project intellij-community by JetBrains.

the class ResolveWorker method execute.

// on EDT, dispose checked
public void execute(final UpdatedFiles updatedFiles) {
    if (myConflictedVirtualFiles.isEmpty()) {
        return;
    }
    final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(myProject);
    List<VirtualFile> mergedFiles = vcsHelper.showMergeDialog(myConflictedVirtualFiles, new SvnMergeProvider(myProject));
    final FileGroup mergedGroup = updatedFiles.getGroupById(FileGroup.MERGED_ID);
    final FileGroup conflictedGroup = updatedFiles.getGroupById(FileGroup.MERGED_WITH_CONFLICT_ID);
    final VcsKey vcsKey = SvnVcs.getKey();
    for (final VirtualFile mergedFile : mergedFiles) {
        String path = FileUtil.toSystemDependentName(mergedFile.getPresentableUrl());
        conflictedGroup.remove(path);
        mergedGroup.add(path, vcsKey, null);
        mergedFile.refresh(false, false);
        // for additionally created files removal to be detected
        mergedFile.getParent().refresh(false, false);
        if (myChangesUnderProjectRoot) {
            myDirtyScopeManager.fileDirty(mergedFile);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsKey(com.intellij.openapi.vcs.VcsKey) SvnMergeProvider(org.jetbrains.idea.svn.actions.SvnMergeProvider) AbstractVcsHelper(com.intellij.openapi.vcs.AbstractVcsHelper) FileGroup(com.intellij.openapi.vcs.update.FileGroup)

Example 3 with AbstractVcsHelper

use of com.intellij.openapi.vcs.AbstractVcsHelper in project intellij-community by JetBrains.

the class RemoveLocallyFileOrDirectoryAction method getCvsHandler.

private static CvsHandler getCvsHandler(final Project project, final Collection<File> filesToRemove, final boolean showDialog) {
    final ArrayList<File> files = new ArrayList<>();
    for (final File file : filesToRemove) {
        if (CvsUtil.fileIsLocallyAdded(file)) {
            CvsUtil.removeEntryFor(file);
        } else {
            files.add(file);
        }
    }
    if (files.isEmpty())
        return CvsHandler.NULL;
    Collection<FilePath> filesToBeRemoved = filesToFilePaths(files);
    if (showDialog) {
        final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);
        filesToBeRemoved = vcsHelper.selectFilePathsToProcess(filesToFilePaths(files), CvsBundle.message("dialog.title.delete.files.from.cvs"), null, CvsBundle.message("dialog.title.delete.file.from.cvs"), CvsBundle.message("confirmation.text.delete.file.from.cvs"), VcsShowConfirmationOption.STATIC_SHOW_CONFIRMATION, CvsBundle.message("button.text.delete.from.cvs"), CommonBundle.getCancelButtonText());
        if (filesToBeRemoved == null || filesToBeRemoved.isEmpty())
            return CvsHandler.NULL;
    }
    return CommandCvsHandler.createRemoveFilesHandler(project, ChangesUtil.filePathsToFiles(filesToBeRemoved));
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) AbstractVcsHelper(com.intellij.openapi.vcs.AbstractVcsHelper) ArrayList(java.util.ArrayList) File(java.io.File)

Example 4 with AbstractVcsHelper

use of com.intellij.openapi.vcs.AbstractVcsHelper in project intellij-community by JetBrains.

the class HgAbstractFilesAction method actionPerformed.

public final void actionPerformed(AnActionEvent event) {
    final DataContext dataContext = event.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
    if (project == null || files == null || files.length == 0) {
        return;
    }
    project.save();
    final HgVcs vcs = HgVcs.getInstance(project);
    if ((vcs == null) || !ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, files)) {
        return;
    }
    final AbstractVcsHelper helper = AbstractVcsHelper.getInstance(project);
    List<VcsException> exceptions = helper.runTransactionRunnable(vcs, new TransactionRunnable() {

        public void run(List<VcsException> exceptions) {
            try {
                execute(project, vcs, files, dataContext);
            } catch (VcsException ex) {
                exceptions.add(ex);
            }
        }
    }, null);
    helper.showErrors(exceptions, vcs.getName());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) HgVcs(org.zmlx.hg4idea.HgVcs) AbstractVcsHelper(com.intellij.openapi.vcs.AbstractVcsHelper) VcsException(com.intellij.openapi.vcs.VcsException) TransactionRunnable(com.intellij.openapi.vcs.TransactionRunnable)

Aggregations

AbstractVcsHelper (com.intellij.openapi.vcs.AbstractVcsHelper)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Project (com.intellij.openapi.project.Project)2 VcsException (com.intellij.openapi.vcs.VcsException)2 LocalHistoryAction (com.intellij.history.LocalHistoryAction)1 FilePath (com.intellij.openapi.vcs.FilePath)1 TransactionRunnable (com.intellij.openapi.vcs.TransactionRunnable)1 VcsKey (com.intellij.openapi.vcs.VcsKey)1 FileGroup (com.intellij.openapi.vcs.update.FileGroup)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 SvnVcs (org.jetbrains.idea.svn.SvnVcs)1 SvnMergeProvider (org.jetbrains.idea.svn.actions.SvnMergeProvider)1 HgVcs (org.zmlx.hg4idea.HgVcs)1