Search in sources :

Example 1 with SvnTarget

use of org.tmatesoft.svn.core.wc2.SvnTarget in project intellij-community by JetBrains.

the class SvnCheckoutProvider method doExport.

public static void doExport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean ignoreExternals, final boolean force, final String eolStyle) {
    try {
        final VcsException[] exception = new VcsException[1];
        final SvnVcs vcs = SvnVcs.getInstance(project);
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
            ProgressTracker handler = new CheckoutEventHandler(vcs, true, progressIndicator);
            try {
                progressIndicator.setText(message("progress.text.export", target.getAbsolutePath()));
                SvnTarget from = SvnTarget.fromURL(url);
                ExportClient client = vcs.getFactoryFromSettings().createExportClient();
                client.export(from, target, SVNRevision.HEAD, depth, eolStyle, force, ignoreExternals, handler);
            } catch (VcsException e) {
                exception[0] = e;
            }
        }, message("message.title.export"), true, project);
        if (exception[0] != null) {
            throw exception[0];
        }
    } catch (VcsException e1) {
        showErrorDialog(message("message.text.cannot.export", e1.getMessage()), message("message.title.export"));
    }
}
Also used : ProgressTracker(org.jetbrains.idea.svn.api.ProgressTracker) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 2 with SvnTarget

use of org.tmatesoft.svn.core.wc2.SvnTarget in project intellij-community by JetBrains.

the class ShowPropertiesDiffAction method getPropertyList.

@NotNull
private static List<PropertyData> getPropertyList(@NotNull SvnVcs vcs, @Nullable final ContentRevision contentRevision, @Nullable final SVNRevision revision) throws SVNException, VcsException {
    if (contentRevision == null) {
        return Collections.emptyList();
    }
    SvnTarget target;
    if (contentRevision instanceof SvnRepositoryContentRevision) {
        final SvnRepositoryContentRevision svnRevision = (SvnRepositoryContentRevision) contentRevision;
        target = SvnTarget.fromURL(SVNURL.parseURIEncoded(svnRevision.getFullPath()), revision);
    } else {
        final File ioFile = contentRevision.getFile().getIOFile();
        target = SvnTarget.fromFile(ioFile, revision);
    }
    return getPropertyList(vcs, target, revision);
}
Also used : SvnRepositoryContentRevision(org.jetbrains.idea.svn.history.SvnRepositoryContentRevision) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with SvnTarget

use of org.tmatesoft.svn.core.wc2.SvnTarget in project intellij-community by JetBrains.

the class CommandParametersResolutionModule method resolveWorkingDirectory.

@NotNull
private File resolveWorkingDirectory(@NotNull Command command) {
    SvnTarget target = command.getTarget();
    File workingDirectory = target.isFile() ? target.getFile() : null;
    // TODO: Do we really need search existing parent - or just take parent directory if target is file???
    workingDirectory = CommandUtil.findExistingParent(workingDirectory);
    return workingDirectory != null ? workingDirectory : getDefaultWorkingDirectory(myVcs.getProject());
}
Also used : SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with SvnTarget

use of org.tmatesoft.svn.core.wc2.SvnTarget in project intellij-community by JetBrains.

the class DefaultBranchConfigInitializer method getDefaultConfiguration.

@NotNull
private static SvnBranchConfigurationNew getDefaultConfiguration(@NotNull SvnVcs vcs, @NotNull SVNURL url) throws SVNException, VcsException {
    SvnBranchConfigurationNew result = new SvnBranchConfigurationNew();
    result.setTrunkUrl(url.toString());
    SVNURL branchLocationsParent = getBranchLocationsParent(url);
    if (branchLocationsParent != null) {
        SvnTarget target = SvnTarget.fromURL(branchLocationsParent);
        vcs.getFactory(target).createBrowseClient().list(target, SVNRevision.HEAD, Depth.IMMEDIATES, createHandler(result, target.getURL()));
    }
    return result;
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with SvnTarget

use of org.tmatesoft.svn.core.wc2.SvnTarget in project intellij-community by JetBrains.

the class ShareProjectAction method performImpl.

private static boolean performImpl(@NotNull SvnVcs vcs, @NotNull VirtualFile file) throws VcsException {
    ShareDialog shareDialog = new ShareDialog(vcs.getProject(), file.getName());
    shareDialog.show();
    String parent = shareDialog.getSelectedURL();
    if (shareDialog.isOK() && parent != null) {
        Ref<Boolean> actionStarted = new Ref<>(Boolean.TRUE);
        Exception[] error = new Exception[1];
        ShareDialog.ShareTarget shareTarget = shareDialog.getShareTarget();
        if (ShareDialog.ShareTarget.useSelected.equals(shareTarget) && !isFolderEmpty(vcs, parent) && YES != showYesNoDialog(vcs.getProject(), "Remote folder \"" + parent + "\" is not empty.\nDo you want to continue sharing?", "Share Directory", getWarningIcon())) {
            return false;
        }
        WorkingCopyFormat format = SvnCheckoutProvider.promptForWCopyFormat(virtualToIoFile(file), vcs.getProject());
        actionStarted.set(format != WorkingCopyFormat.UNKNOWN);
        // means operation cancelled
        if (format == WorkingCopyFormat.UNKNOWN) {
            return true;
        }
        ExclusiveBackgroundVcsAction.run(vcs.getProject(), () -> ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            try {
                SvnWorkingCopyFormatHolder.setPresetFormat(format);
                SvnTarget checkoutTarget = createFolderStructure(vcs, file, shareTarget, shareDialog.createStandardStructure(), createUrl(parent), shareDialog.getCommitText());
                progress(message("share.directory.checkout.back.progress.text", checkoutTarget.getPathOrUrlString()));
                ClientFactory factory = SvnCheckoutProvider.getFactory(vcs, format);
                factory.createCheckoutClient().checkout(SvnTarget.fromURL(checkoutTarget.getURL()), virtualToIoFile(file), checkoutTarget.getPegRevision(), Depth.INFINITY, false, false, format, null);
                addRecursively(vcs, factory, file);
            } catch (VcsException e) {
                error[0] = e;
            } finally {
                vcs.invokeRefreshSvnRoots();
                SvnWorkingCopyFormatHolder.setPresetFormat(null);
            }
        }, message("share.directory.title"), true, vcs.getProject()));
        if (Boolean.TRUE.equals(actionStarted.get())) {
            if (error[0] != null) {
                throw new VcsException(error[0].getMessage());
            }
            showInfoMessage(vcs.getProject(), message("share.directory.info.message", file.getName()), message("share.directory.title"));
        }
        return true;
    }
    return false;
}
Also used : Ref(com.intellij.openapi.util.Ref) ShareDialog(org.jetbrains.idea.svn.dialogs.ShareDialog) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) VcsException(com.intellij.openapi.vcs.VcsException) ClientFactory(org.jetbrains.idea.svn.api.ClientFactory) VcsException(com.intellij.openapi.vcs.VcsException)

Aggregations

SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)29 NotNull (org.jetbrains.annotations.NotNull)15 File (java.io.File)10 SVNURL (org.tmatesoft.svn.core.SVNURL)10 VcsException (com.intellij.openapi.vcs.VcsException)7 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)7 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 SvnVcs (org.jetbrains.idea.svn.SvnVcs)5 Logger (com.intellij.openapi.diagnostic.Logger)4 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)4 Pair (com.intellij.openapi.util.Pair)4 Ref (com.intellij.openapi.util.Ref)4 FilePath (com.intellij.openapi.vcs.FilePath)4 Nullable (org.jetbrains.annotations.Nullable)4 SVNException (org.tmatesoft.svn.core.SVNException)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 FileUtil (com.intellij.openapi.util.io.FileUtil)3 Registry (com.intellij.openapi.util.registry.Registry)3 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)3