Mercurial > hg > mercurial
view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java @ 266:643fa1236f4e
Fix file encoding
* * *
Fix line-endings
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Wed, 20 Jul 2011 12:04:08 +0400 |
parents | 73708ca4521f |
children | 8c1fd2e565ae |
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 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()); ExecResult res = runCommand(cli, 24*3600); // some repositories are quite large, we set timeout to 24 hours failIfNonZeroExitCode(cli, res); } }