Search in sources :

Example 1 with ClientFactory

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

the class SvnCheckoutProvider method getFactory.

@NotNull
public static ClientFactory getFactory(@NotNull SvnVcs vcs, @NotNull WorkingCopyFormat format) throws VcsException {
    ClientFactory settingsFactory = vcs.getFactoryFromSettings();
    ClientFactory otherFactory = vcs.getOtherFactory();
    List<WorkingCopyFormat> settingsFactoryFormats = settingsFactory.createCheckoutClient().getSupportedFormats();
    List<WorkingCopyFormat> otherFactoryFormats = CheckoutFormatFromUserProvider.getOtherFactoryFormats(otherFactory);
    return settingsFactoryFormats.contains(format) || !otherFactoryFormats.contains(format) ? settingsFactory : otherFactory;
}
Also used : WorkingCopyFormat(org.jetbrains.idea.svn.WorkingCopyFormat) ClientFactory(org.jetbrains.idea.svn.api.ClientFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ClientFactory

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

the class CreateExternalAction method addToExternalProperty.

public static void addToExternalProperty(@NotNull SvnVcs vcs, @NotNull File ioFile, String target, String url) throws VcsException {
    ClientFactory factory = vcs.getFactory(ioFile);
    PropertyValue propertyValue = factory.createPropertyClient().getProperty(SvnTarget.fromFile(ioFile), SvnPropertyKeys.SVN_EXTERNALS, false, SVNRevision.UNDEFINED);
    boolean hasExternals = propertyValue != null && !isEmptyOrSpaces(propertyValue.toString());
    String newExternals = "";
    if (hasExternals) {
        String externalsForTarget = parseExternalsProperty(propertyValue.toString()).get(target);
        if (externalsForTarget != null) {
            throw new VcsException("Selected destination conflicts with existing: " + externalsForTarget);
        }
        newExternals = propertyValue.toString().trim() + "\n";
    }
    newExternals += escape(url) + " " + target;
    factory.createPropertyClient().setProperty(ioFile, SvnPropertyKeys.SVN_EXTERNALS, PropertyValue.create(newExternals), Depth.EMPTY, false);
}
Also used : ClientFactory(org.jetbrains.idea.svn.api.ClientFactory) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue)

Example 3 with ClientFactory

use of org.jetbrains.idea.svn.api.ClientFactory 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)

Example 4 with ClientFactory

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

the class CopiesPanel method getSupportedFormats.

@NotNull
private List<WorkingCopyFormat> getSupportedFormats() {
    List<WorkingCopyFormat> result = ContainerUtil.newArrayList();
    ClientFactory factory = myVcs.getFactory();
    ClientFactory otherFactory = myVcs.getOtherFactory(factory);
    try {
        result.addAll(factory.createUpgradeClient().getSupportedFormats());
        result.addAll(SvnFormatWorker.getOtherFactoryFormats(otherFactory));
    } catch (VcsException e) {
        LOG.info(e);
    }
    return result;
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) ClientFactory(org.jetbrains.idea.svn.api.ClientFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with ClientFactory

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

the class SvnFormatWorker method getFactory.

@NotNull
private ClientFactory getFactory(@NotNull File path, @NotNull WorkingCopyFormat format) throws VcsException {
    ClientFactory factory = myVcs.getFactory(path);
    ClientFactory otherFactory = myVcs.getOtherFactory(factory);
    List<WorkingCopyFormat> factoryFormats = factory.createUpgradeClient().getSupportedFormats();
    List<WorkingCopyFormat> otherFactoryFormats = getOtherFactoryFormats(otherFactory);
    return factoryFormats.contains(format) || !otherFactoryFormats.contains(format) ? factory : otherFactory;
}
Also used : WorkingCopyFormat(org.jetbrains.idea.svn.WorkingCopyFormat) ClientFactory(org.jetbrains.idea.svn.api.ClientFactory) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ClientFactory (org.jetbrains.idea.svn.api.ClientFactory)6 NotNull (org.jetbrains.annotations.NotNull)4 VcsException (com.intellij.openapi.vcs.VcsException)2 WorkingCopyFormat (org.jetbrains.idea.svn.WorkingCopyFormat)2 Ref (com.intellij.openapi.util.Ref)1 File (java.io.File)1 ShareDialog (org.jetbrains.idea.svn.dialogs.ShareDialog)1 PropertyValue (org.jetbrains.idea.svn.properties.PropertyValue)1 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)1