Mercurial > hg > mercurial
view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java @ 322:6667765025c6
Merge branch Eluru-6.5.x
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Mon, 19 Sep 2011 12:02:37 +0400 |
parents | 016223a02931 f5092b982bdb |
children | 4a49a0baf30b |
line wrap: on
line source
/* * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; import com.intellij.execution.configurations.GeneralCommandLine; import jetbrains.buildServer.ExecResult; import jetbrains.buildServer.vcs.VcsException; import org.jetbrains.annotations.NotNull; import java.io.File; public class CloneCommand extends VcsRootCommand { private String myToId; private boolean myUpdateWorkingDir = true; private String myRepository; private File myWorkingDir; private boolean myUsePullProtocol = true; public CloneCommand(@NotNull Settings settings, @NotNull File workingDir) { super(settings, workingDir); myWorkingDir = workingDir; myRepository = getSettings().getRepositoryUrl(); } /** * Sets repository to clone, by default uses repository from the specified settings * @param repo repository path */ public void setRepository(@NotNull String repo) { myRepository = repo; } public void setToId(final String toId) { myToId = toId; } public void setUpdateWorkingDir(final boolean updateWorkingDir) { myUpdateWorkingDir = updateWorkingDir; } public void setUsePullProtocol(boolean usePullProtocol) { myUsePullProtocol = usePullProtocol; } public void execute() throws VcsException { GeneralCommandLine cli = createCommandLine(); File parent = myWorkingDir.getParentFile(); cli.setWorkDirectory(parent.getAbsolutePath()); cli.addParameter("clone"); if (myToId != null) { cli.addParameter("-r"); cli.addParameter(myToId); } if (myUsePullProtocol) cli.addParameter("--pull"); if (!myUpdateWorkingDir) { cli.addParameter("-U"); } if (getSettings().isUncompressedTransfer()) { cli.addParameter("--uncompressed"); } cli.addParameter(myRepository); cli.addParameter(myWorkingDir.getName()); ExecResult res = runCommand(cli, 24*3600); // some repositories are quite large, we set timeout to 24 hours } }