Search in sources :

Example 6 with SvnVcs

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

the class DefaultBranchConfigInitializer method getDefaultConfiguration.

@Nullable
public SvnBranchConfigurationNew getDefaultConfiguration() {
    SvnBranchConfigurationNew result = null;
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    SVNURL rootUrl = SvnUtil.getUrl(vcs, VfsUtilCore.virtualToIoFile(myRoot));
    if (rootUrl != null) {
        try {
            result = getDefaultConfiguration(vcs, rootUrl);
        } catch (SVNException | VcsException e) {
            LOG.info(e);
        }
    } else {
        LOG.info("Directory is not a working copy: " + myRoot.getPresentableUrl());
    }
    return result;
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException) SvnVcs(org.jetbrains.idea.svn.SvnVcs) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with SvnVcs

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

the class NewRootBunch method reloadBranches.

public void reloadBranches(@NotNull VirtualFile root, @Nullable SvnBranchConfigurationNew prev, @NotNull SvnBranchConfigurationNew next) {
    final Set<String> oldUrls = (prev == null) ? Collections.emptySet() : new HashSet<>(prev.getBranchUrls());
    final SvnVcs vcs = SvnVcs.getInstance(myProject);
    if (!vcs.isVcsBackgroundOperationsAllowed(root))
        return;
    for (String newBranchUrl : next.getBranchUrls()) {
        // check if cancel had been put
        if (!vcs.isVcsBackgroundOperationsAllowed(root))
            return;
        if (!oldUrls.contains(newBranchUrl)) {
            reloadBranches(root, newBranchUrl, InfoReliability.defaultValues, true);
        }
    }
}
Also used : SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 8 with SvnVcs

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

the class BasicAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    SvnVcs vcs = project != null ? SvnVcs.getInstance(project) : null;
    VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
    boolean visible = project != null;
    e.getPresentation().setEnabled(visible && vcs != null && !isEmpty(files) && isEnabled(vcs, files));
    e.getPresentation().setVisible(visible);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 9 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 10 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)

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