Search in sources :

Example 1 with WorkingCopyFormat

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

the class CmdCheckoutClient method getSupportedFormats.

@Override
public List<WorkingCopyFormat> getSupportedFormats() throws VcsException {
    ArrayList<WorkingCopyFormat> result = new ArrayList<>();
    Version version = myFactory.createVersionClient().getVersion();
    result.add(WorkingCopyFormat.from(version));
    return result;
}
Also used : WorkingCopyFormat(org.jetbrains.idea.svn.WorkingCopyFormat) Version(com.intellij.openapi.util.Version) ArrayList(java.util.ArrayList)

Example 2 with WorkingCopyFormat

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

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

Example 4 with WorkingCopyFormat

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

Example 5 with WorkingCopyFormat

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

the class CmdDiffClient method compare.

@NotNull
@Override
public List<Change> compare(@NotNull SvnTarget target1, @NotNull SvnTarget target2) throws VcsException {
    assertUrl(target1);
    if (target2.isFile()) {
        // Such combination (file and url) with "--summarize" option is supported only in svn 1.8.
        // For svn 1.7 "--summarize" is only supported when both targets are repository urls.
        assertDirectory(target2);
        WorkingCopyFormat format = WorkingCopyFormat.from(myFactory.createVersionClient().getVersion());
        if (format.less(WorkingCopyFormat.ONE_DOT_EIGHT)) {
            throw new SvnBindException("Could not compare local file and remote url with executable for svn " + format);
        }
    }
    List<String> parameters = new ArrayList<>();
    CommandUtil.put(parameters, target1);
    CommandUtil.put(parameters, target2);
    parameters.add("--xml");
    parameters.add("--summarize");
    CommandExecutor executor = execute(myVcs, target1, SvnCommandName.diff, parameters, null);
    return parseOutput(target1, target2, executor);
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) WorkingCopyFormat(org.jetbrains.idea.svn.WorkingCopyFormat) ArrayList(java.util.ArrayList) CommandExecutor(org.jetbrains.idea.svn.commandLine.CommandExecutor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

WorkingCopyFormat (org.jetbrains.idea.svn.WorkingCopyFormat)6 NotNull (org.jetbrains.annotations.NotNull)4 ArrayList (java.util.ArrayList)2 ClientFactory (org.jetbrains.idea.svn.api.ClientFactory)2 SVNException (org.tmatesoft.svn.core.SVNException)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Ref (com.intellij.openapi.util.Ref)1 Version (com.intellij.openapi.util.Version)1 VcsException (com.intellij.openapi.vcs.VcsException)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Collection (java.util.Collection)1 SvnVcs (org.jetbrains.idea.svn.SvnVcs)1 ProgressTracker (org.jetbrains.idea.svn.api.ProgressTracker)1 CommandExecutor (org.jetbrains.idea.svn.commandLine.CommandExecutor)1 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)1 SVNCancelException (org.tmatesoft.svn.core.SVNCancelException)1