summaryrefslogtreecommitdiff
path: root/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitCheckoutClient.java
blob: 9abd2da1b35cb0bdf2557027ab2979d397dfa627 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package org.jetbrains.idea.svn.checkout;

import com.intellij.openapi.vcs.VcsException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.WorkingCopyFormat;
import org.jetbrains.idea.svn.api.BaseSvnClient;
import org.jetbrains.idea.svn.commandLine.SvnBindException;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.internal.wc2.SvnWcGeneration;
import org.tmatesoft.svn.core.wc.ISVNEventHandler;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;
import org.tmatesoft.svn.core.wc2.SvnTarget;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Konstantin Kolosovsky.
 */
public class SvnKitCheckoutClient extends BaseSvnClient implements CheckoutClient {

  public static final List<WorkingCopyFormat> SUPPORTED_FORMATS;

  static {
    List<WorkingCopyFormat> supportedFormats = new ArrayList<WorkingCopyFormat>();

    supportedFormats.add(WorkingCopyFormat.ONE_DOT_SEVEN);
    supportedFormats.add(WorkingCopyFormat.ONE_DOT_SIX);

    SUPPORTED_FORMATS = Collections.unmodifiableList(supportedFormats);
  }

  @Override
  public void checkout(@NotNull SvnTarget source,
                       @NotNull File destination,
                       @Nullable SVNRevision revision,
                       @Nullable SVNDepth depth,
                       boolean ignoreExternals,
                       boolean force,
                       @NotNull WorkingCopyFormat format,
                       @Nullable ISVNEventHandler handler) throws VcsException {
    assertUrl(source);
    validateFormat(format, getSupportedFormats());

    SVNUpdateClient client = myVcs.getSvnKitManager().createUpdateClient();

    if (WorkingCopyFormat.ONE_DOT_SIX.equals(format)) {
      client.getOperationsFactory().setPrimaryWcGeneration(SvnWcGeneration.V16);
    }

    client.setIgnoreExternals(ignoreExternals);
    client.setEventHandler(handler);

    try {
      client.doCheckout(source.getURL(), destination, source.getPegRevision(), revision, depth, force);
    }
    catch (SVNException e) {
      throw new SvnBindException(e);
    }
  }

  @Override
  public List<WorkingCopyFormat> getSupportedFormats() throws VcsException {
    return SUPPORTED_FORMATS;
  }
}