comparison mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java @ 181:0ea2ad14ce97

Add local mirrors for agent checkout. To turn them on set agent property teamcity.hg.use.local.mirrors = true.
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Tue, 01 Mar 2011 17:55:41 +0300
parents b3697b3a162d
children 73708ca4521f
comparison
equal deleted inserted replaced
175:d94b260c4808 181:0ea2ad14ce97
21 import org.jetbrains.annotations.NotNull; 21 import org.jetbrains.annotations.NotNull;
22 22
23 import java.io.File; 23 import java.io.File;
24 24
25 public class CloneCommand extends BaseCommand{ 25 public class CloneCommand extends BaseCommand{
26 private String myDestDir;
27 private String myToId; 26 private String myToId;
28 private boolean myUpdateWorkingDir = true; 27 private boolean myUpdateWorkingDir = true;
29 private String myRepository; 28 private String myRepository;
29 private File myWorkingDir;
30 30
31 public CloneCommand(@NotNull final Settings settings) { 31 public CloneCommand(@NotNull Settings settings, @NotNull File workingDir) {
32 super(settings); 32 super(settings, workingDir);
33 myWorkingDir = workingDir;
33 myRepository = getSettings().getRepositoryUrl(); 34 myRepository = getSettings().getRepositoryUrl();
34 } 35 }
35 36
36 /** 37 /**
37 * Sets repository to clone, by default uses repository from the specified settings 38 * Sets repository to clone, by default uses repository from the specified settings
39 */ 40 */
40 public void setRepository(@NotNull String repo) { 41 public void setRepository(@NotNull String repo) {
41 myRepository = repo; 42 myRepository = repo;
42 } 43 }
43 44
44 public void setDestDir(@NotNull String destDir) {
45 myDestDir = destDir;
46 }
47
48 public void setToId(final String toId) { 45 public void setToId(final String toId) {
49 myToId = toId; 46 myToId = toId;
50 } 47 }
51 48
52 public void setUpdateWorkingDir(final boolean updateWorkingDir) { 49 public void setUpdateWorkingDir(final boolean updateWorkingDir) {
53 myUpdateWorkingDir = updateWorkingDir; 50 myUpdateWorkingDir = updateWorkingDir;
54 } 51 }
55 52
56 public void execute() throws VcsException { 53 public void execute() throws VcsException {
57 if (myDestDir == null) throw new IllegalStateException("Destination dir must be specified");
58 GeneralCommandLine cli = createCommandLine(); 54 GeneralCommandLine cli = createCommandLine();
59 File dir = new File(myDestDir); 55 File parent = myWorkingDir.getParentFile();
60 File parent = dir.getParentFile();
61 cli.setWorkDirectory(parent.getAbsolutePath()); 56 cli.setWorkDirectory(parent.getAbsolutePath());
62 cli.addParameter("clone"); 57 cli.addParameter("clone");
63 if (myToId != null) { 58 if (myToId != null) {
64 cli.addParameter("-r"); 59 cli.addParameter("-r");
65 cli.addParameter(myToId); 60 cli.addParameter(myToId);
70 } 65 }
71 if (getSettings().isUncompressedTransfer()) { 66 if (getSettings().isUncompressedTransfer()) {
72 cli.addParameter("--uncompressed"); 67 cli.addParameter("--uncompressed");
73 } 68 }
74 cli.addParameter(myRepository); 69 cli.addParameter(myRepository);
75 cli.addParameter(dir.getName()); 70 cli.addParameter(myWorkingDir.getName());
76 71
77 ExecResult res = runCommand(cli, 24*3600); // some repositories are quite large, we set timeout to 24 hours 72 ExecResult res = runCommand(cli, 24*3600); // some repositories are quite large, we set timeout to 24 hours
78 failIfNonZeroExitCode(cli, res); 73 failIfNonZeroExitCode(cli, res);
79 } 74 }
80 } 75 }