Mercurial > hg > mercurial
view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java @ 44:1490e2981799
labeling/tagging support
author | Pavel.Sher |
---|---|
date | Fri, 05 Sep 2008 01:15:29 +0400 |
parents | 7944e8985ebd |
children | 10e774d891b5 |
line wrap: on
line source
/* * Copyright 2000-2007 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; public class CloneCommand extends BaseCommand{ private String myDestDir; private String myToId; private boolean myUpdateWorkingDir = true; public CloneCommand(@NotNull final Settings settings) { super(settings); } public void setDestDir(@NotNull String destDir) { myDestDir = destDir; } public void setToId(final String toId) { myToId = toId; } public void setUpdateWorkingDir(final boolean updateWorkingDir) { myUpdateWorkingDir = updateWorkingDir; } public void execute() throws VcsException { if (myDestDir == null) throw new IllegalStateException("Destination dir must be specified"); GeneralCommandLine cli = createCommandLine(); File dir = new File(myDestDir); File parent = dir.getParentFile(); cli.setWorkDirectory(parent.getAbsolutePath()); cli.addParameter("clone"); if (myToId != null) { cli.addParameter("-r"); cli.addParameter(myToId); } cli.addParameter("--pull"); if (!myUpdateWorkingDir) { cli.addParameter("-U"); } cli.addParameter(getSettings().getRepository()); cli.addParameter(dir.getName()); runCommand(cli); } }