Search in sources :

Example 16 with VcsException

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

the class SvnEditFileProvider method editFiles.

public void editFiles(VirtualFile[] files) throws VcsException {
    File[] ioFiles = new File[files.length];
    for (int i = 0; i < files.length; i++) {
        ioFiles[i] = virtualToIoFile(files[i]);
        PropertyClient client = myVCS.getFactory(ioFiles[i]).createPropertyClient();
        PropertyValue property = client.getProperty(SvnTarget.fromFile(ioFiles[i], SVNRevision.WORKING), SvnPropertyKeys.SVN_NEEDS_LOCK, false, SVNRevision.WORKING);
        if (property == null) {
            throw new VcsException(SvnBundle.message("exception.text.file.miss.svn", ioFiles[i].getName()));
        }
    }
    SvnUtil.doLockFiles(myVCS.getProject(), myVCS, ioFiles);
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) VcsException(com.intellij.openapi.vcs.VcsException) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)

Example 17 with VcsException

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

the class SvnChangelistListener method addToChangeList.

private void addToChangeList(@NotNull String changeList, @NotNull Collection<Change> changes, @Nullable String[] changeListsToOperate) {
    for (FilePath path : getPathsFromChanges(changes)) {
        try {
            File file = path.getIOFile();
            myVcs.getFactory(file).createChangeListClient().add(changeList, file, changeListsToOperate);
        } catch (VcsException e) {
            LOG.info(e);
        }
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsException(com.intellij.openapi.vcs.VcsException) File(java.io.File)

Example 18 with VcsException

use of com.intellij.openapi.vcs.VcsException 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 19 with VcsException

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

the class CleanupWorker method run.

@Override
public void run(@NotNull ProgressIndicator indicator) {
    indicator.setIndeterminate(true);
    for (VirtualFile root : myRoots) {
        try {
            File path = virtualToIoFile(root);
            File pathOrParent = virtualToIoFile(root.isDirectory() ? root : root.getParent());
            indicator.setText(message("action.Subversion.cleanup.progress.text", path));
            myVcs.getFactory(path).createCleanupClient().cleanup(pathOrParent, new SvnProgressCanceller(indicator));
        } catch (VcsException e) {
            myExceptions.add(Pair.create(e, root));
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsException(com.intellij.openapi.vcs.VcsException) SvnProgressCanceller(org.jetbrains.idea.svn.SvnProgressCanceller) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)

Example 20 with VcsException

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

the class CleanupWorker method onSuccess.

@Override
public void onSuccess() {
    if (myProject.isDisposed())
        return;
    getApplication().invokeLater(() -> getApplication().runWriteAction(() -> {
        if (!myProject.isDisposed()) {
            LocalFileSystem.getInstance().refreshFiles(myRoots, false, true, null);
        }
    }));
    markFilesDirty(myProject, myRoots);
    if (!myExceptions.isEmpty()) {
        AbstractVcsHelper.getInstance(myProject).showErrors(myExceptions.stream().map(pair -> new VcsException(message("action.Subversion.cleanup.error.message", toSystemDependentName(pair.second.getPath()), pair.first == null ? "" : pair.first.getMessage()))).collect(toList()), myTitle);
    }
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException)

Aggregations

VcsException (com.intellij.openapi.vcs.VcsException)200 VirtualFile (com.intellij.openapi.vfs.VirtualFile)89 File (java.io.File)48 NotNull (org.jetbrains.annotations.NotNull)42 FilePath (com.intellij.openapi.vcs.FilePath)35 Change (com.intellij.openapi.vcs.changes.Change)33 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)26 ArrayList (java.util.ArrayList)24 Nullable (org.jetbrains.annotations.Nullable)23 IOException (java.io.IOException)20 SVNException (org.tmatesoft.svn.core.SVNException)19 Project (com.intellij.openapi.project.Project)17 Ref (com.intellij.openapi.util.Ref)16 Test (org.junit.Test)14 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)13 GitRepository (git4idea.repo.GitRepository)12 Task (com.intellij.openapi.progress.Task)11 List (java.util.List)11 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)10 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)10