summaryrefslogtreecommitdiff
path: root/plugins/svn4idea/src/org/jetbrains/idea/svn/change/CmdChangeListClient.java
blob: dc9feddf61d7e5c308c2517dd80d265b66741af8 (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
package org.jetbrains.idea.svn.change;

import com.intellij.openapi.vcs.VcsException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.api.BaseSvnClient;
import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.commandLine.CommandUtil;
import org.jetbrains.idea.svn.commandLine.SvnCommandName;
import org.tmatesoft.svn.core.wc2.SvnTarget;

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

/**
 * @author Konstantin Kolosovsky.
 */
public class CmdChangeListClient extends BaseSvnClient implements ChangeListClient {

  @Override
  public void add(@NotNull String changeList, @NotNull File path, @Nullable String[] changeListsToOperate) throws VcsException {
    List<String> parameters = new ArrayList<String>();

    parameters.add(changeList);
    CommandUtil.put(parameters, path);
    CommandUtil.put(parameters, Depth.EMPTY);
    if (changeListsToOperate != null) {
      CommandUtil.putChangeLists(parameters, Arrays.asList(changeListsToOperate));
    }

    // for now parsing of the output is not required as command is executed only for one file
    // and will be either successful or exception will be thrown
    execute(myVcs, SvnTarget.fromFile(path), SvnCommandName.changelist, parameters, null);
  }

  @Override
  public void remove(@NotNull File path) throws VcsException {
    List<String> parameters = new ArrayList<String>();

    parameters.add("--remove");
    CommandUtil.put(parameters, path);
    CommandUtil.put(parameters, Depth.EMPTY);

    // for now parsing of the output is not required as command is executed only for one file
    // and will be either successful or exception will be thrown
    execute(myVcs, SvnTarget.fromFile(path), SvnCommandName.changelist, parameters, null);
  }
}