Search in sources :

Example 16 with SvnVcs

use of org.jetbrains.idea.svn.SvnVcs 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 17 with SvnVcs

use of org.jetbrains.idea.svn.SvnVcs in project intellij-community by JetBrains.

the class CreateExternalAction method doInBackground.

private static void doInBackground(@NotNull Project project, @NotNull VirtualFile file, String url, boolean checkout, String target) {
    SvnVcs vcs = SvnVcs.getInstance(project);
    VcsDirtyScopeManager dirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
    File ioFile = virtualToIoFile(file);
    try {
        addToExternalProperty(vcs, ioFile, target, url);
        dirtyScopeManager.fileDirty(file);
        if (checkout) {
            UpdateClient client = vcs.getFactory(ioFile).createUpdateClient();
            client.setEventHandler(new SvnProgressCanceller());
            client.doUpdate(ioFile, SVNRevision.HEAD, Depth.UNKNOWN, false, false);
            file.refresh(true, true, () -> dirtyScopeManager.dirDirtyRecursively(file));
        }
    } catch (VcsException e) {
        AbstractVcsHelper.getInstance(project).showError(e, "Create External");
    }
}
Also used : UpdateClient(org.jetbrains.idea.svn.update.UpdateClient) SvnProgressCanceller(org.jetbrains.idea.svn.SvnProgressCanceller) ChangesUtil.getVcsForFile(com.intellij.openapi.vcs.changes.ChangesUtil.getVcsForFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) SvnVcs(org.jetbrains.idea.svn.SvnVcs) VcsDirtyScopeManager(com.intellij.openapi.vcs.changes.VcsDirtyScopeManager)

Example 18 with SvnVcs

use of org.jetbrains.idea.svn.SvnVcs in project intellij-community by JetBrains.

the class IgnoreActionGroup method update.

public void update(final AnActionEvent e) {
    final FileGroupInfo fileGroupInfo = new FileGroupInfo();
    myHelperAction.setFileIterationListener(fileGroupInfo);
    myHelperAction.update(e);
    myGetterStub.setDelegate(fileGroupInfo);
    if ((e.getPresentation().isEnabled())) {
        removeAll();
        if (myHelperAction.allAreIgnored()) {
            final DataContext dataContext = e.getDataContext();
            final Project project = CommonDataKeys.PROJECT.getData(dataContext);
            SvnVcs vcs = SvnVcs.getInstance(project);
            final Ref<Boolean> filesOk = new Ref<>(Boolean.FALSE);
            final Ref<Boolean> extensionOk = new Ref<>(Boolean.FALSE);
            // virtual files parameter is not used -> can pass null
            SvnPropertyService.doCheckIgnoreProperty(vcs, null, fileGroupInfo, fileGroupInfo.getExtensionMask(), filesOk, extensionOk);
            if (Boolean.TRUE.equals(filesOk.get())) {
                myRemoveExactAction.setActionText(fileGroupInfo.oneFileSelected() ? fileGroupInfo.getFileName() : SvnBundle.message("action.Subversion.UndoIgnore.text"));
                add(myRemoveExactAction);
            }
            if (Boolean.TRUE.equals(extensionOk.get())) {
                myRemoveExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
                add(myRemoveExtensionAction);
            }
            e.getPresentation().setText(SvnBundle.message("group.RevertIgnoreChoicesGroup.text"));
        } else if (myHelperAction.allCanBeIgnored()) {
            final String ignoreExactlyName = (fileGroupInfo.oneFileSelected()) ? fileGroupInfo.getFileName() : SvnBundle.message("action.Subversion.Ignore.ExactMatch.text");
            myAddExactAction.setActionText(ignoreExactlyName);
            add(myAddExactAction);
            if (fileGroupInfo.sameExtension()) {
                myAddExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
                add(myAddExtensionAction);
            }
            e.getPresentation().setText(SvnBundle.message("group.IgnoreChoicesGroup.text"));
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) Ref(com.intellij.openapi.util.Ref) FileGroupInfo(org.jetbrains.idea.svn.ignore.FileGroupInfo) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 19 with SvnVcs

use of org.jetbrains.idea.svn.SvnVcs in project intellij-community by JetBrains.

the class BranchesLoader method loadBranches.

@NotNull
public List<SvnBranchItem> loadBranches() throws SVNException, VcsException {
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    SVNURL branchesUrl = SVNURL.parseURIEncoded(myUrl);
    List<SvnBranchItem> result = new LinkedList<>();
    SvnTarget target = SvnTarget.fromURL(branchesUrl);
    DirectoryEntryConsumer handler = createConsumer(result);
    vcs.getFactory(target).create(BrowseClient.class, !myPassive).list(target, SVNRevision.HEAD, Depth.IMMEDIATES, handler);
    Collections.sort(result);
    return result;
}
Also used : DirectoryEntryConsumer(org.jetbrains.idea.svn.browse.DirectoryEntryConsumer) BrowseClient(org.jetbrains.idea.svn.browse.BrowseClient) SVNURL(org.tmatesoft.svn.core.SVNURL) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) LinkedList(java.util.LinkedList) SvnVcs(org.jetbrains.idea.svn.SvnVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 20 with SvnVcs

use of org.jetbrains.idea.svn.SvnVcs in project intellij-community by JetBrains.

the class SvnCheckoutProvider method checkout.

public static void checkout(final Project project, final File target, final String url, final SVNRevision revision, final Depth depth, final boolean ignoreExternals, final Listener listener, final WorkingCopyFormat selectedFormat) {
    final Ref<Boolean> checkoutSuccessful = new Ref<>();
    final Exception[] exception = new Exception[1];
    final Task.Backgroundable checkoutBackgroundTask = new Task.Backgroundable(project, message("message.title.check.out"), true, VcsConfiguration.getInstance(project).getCheckoutOption()) {

        public void run(@NotNull final ProgressIndicator indicator) {
            final WorkingCopyFormat format = selectedFormat == null ? UNKNOWN : selectedFormat;
            SvnWorkingCopyFormatHolder.setPresetFormat(format);
            SvnVcs vcs = SvnVcs.getInstance(project);
            ProgressTracker handler = new CheckoutEventHandler(vcs, false, ProgressManager.getInstance().getProgressIndicator());
            ProgressManager.progress(message("progress.text.checking.out", target.getAbsolutePath()));
            try {
                getFactory(vcs, format).createCheckoutClient().checkout(SvnTarget.fromURL(SVNURL.parseURIEncoded(url)), target, revision, depth, ignoreExternals, true, format, handler);
                ProgressManager.checkCanceled();
                checkoutSuccessful.set(Boolean.TRUE);
            } catch (SVNCancelException ignore) {
            } catch (SVNException | VcsException e) {
                exception[0] = e;
            } finally {
                SvnWorkingCopyFormatHolder.setPresetFormat(null);
            }
        }

        public void onCancel() {
            onSuccess();
        }

        public void onSuccess() {
            if (exception[0] != null) {
                showErrorDialog(message("message.text.cannot.checkout", exception[0].getMessage()), message("message.title.check.out"));
            }
            VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(target);
            if (vf != null) {
                vf.refresh(true, true, () -> getApplication().invokeLater(() -> notifyListener()));
            } else {
                notifyListener();
            }
        }

        private void notifyListener() {
            notifyRootManagerIfUnderProject(project, target);
            if (listener != null) {
                if (!checkoutSuccessful.isNull()) {
                    listener.directoryCheckedOut(target, SvnVcs.getKey());
                }
                listener.checkoutCompleted();
            }
        }
    };
    ProgressManager.getInstance().run(checkoutBackgroundTask);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Task(com.intellij.openapi.progress.Task) WorkingCopyFormat(org.jetbrains.idea.svn.WorkingCopyFormat) ProgressTracker(org.jetbrains.idea.svn.api.ProgressTracker) SVNException(org.tmatesoft.svn.core.SVNException) NotNull(org.jetbrains.annotations.NotNull) VcsException(com.intellij.openapi.vcs.VcsException) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) SVNException(org.tmatesoft.svn.core.SVNException) SvnVcs(org.jetbrains.idea.svn.SvnVcs) Ref(com.intellij.openapi.util.Ref) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) VcsException(com.intellij.openapi.vcs.VcsException)

Aggregations

SvnVcs (org.jetbrains.idea.svn.SvnVcs)31 VirtualFile (com.intellij.openapi.vfs.VirtualFile)20 File (java.io.File)9 VcsException (com.intellij.openapi.vcs.VcsException)8 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)8 ChangeBrowserSettings (com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings)7 SvnChangeList (org.jetbrains.idea.svn.history.SvnChangeList)7 SvnRepositoryLocation (org.jetbrains.idea.svn.history.SvnRepositoryLocation)7 Test (org.junit.Test)7 Project (com.intellij.openapi.project.Project)5 NotNull (org.jetbrains.annotations.NotNull)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Ref (com.intellij.openapi.util.Ref)3 RootUrlInfo (org.jetbrains.idea.svn.RootUrlInfo)2 ProgressTracker (org.jetbrains.idea.svn.api.ProgressTracker)2 Info (org.jetbrains.idea.svn.info.Info)2 SVNException (org.tmatesoft.svn.core.SVNException)2 SVNURL (org.tmatesoft.svn.core.SVNURL)2 LocalHistoryAction (com.intellij.history.LocalHistoryAction)1 UsageDescriptor (com.intellij.internal.statistic.beans.UsageDescriptor)1