Mercurial > hg > mercurial
view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java @ 388:3b799724b82b Eluru-6.5.x
TW-20304 port fix from branch default
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 17 Feb 2012 10:55:58 +0400 |
parents | e8f0eb6d4ca4 |
children | e182bb6b5921 |
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.vcs.VcsException; import org.jetbrains.annotations.NotNull; import java.io.File; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with; public class CloneCommand extends BaseCommand{ 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()); runCommand(cli, with().timeout(24 * 3600)); // some repositories are quite large, we set timeout to 24 hours } }