dmitry@266: /* pavel@976: * Copyright 2000-2018 JetBrains s.r.o. dmitry@266: * dmitry@266: * Licensed under the Apache License, Version 2.0 (the "License"); dmitry@266: * you may not use this file except in compliance with the License. dmitry@266: * You may obtain a copy of the License at dmitry@266: * dmitry@266: * http://www.apache.org/licenses/LICENSE-2.0 dmitry@266: * dmitry@266: * Unless required by applicable law or agreed to in writing, software dmitry@266: * distributed under the License is distributed on an "AS IS" BASIS, dmitry@266: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. dmitry@266: * See the License for the specific language governing permissions and dmitry@266: * limitations under the License. dmitry@266: */ dmitry@266: package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; dmitry@266: dmitry@266: import jetbrains.buildServer.vcs.VcsException; dmitry@266: import org.jetbrains.annotations.NotNull; dmitry@266: dmitry@266: import java.io.File; dmitry@266: dmitry@266: /** dmitry@266: * @author pavel dmitry@266: */ dmitry@497: public class PushCommand extends AuthCommand { dmitry@266: dmitry@749: private String myBookmark; dmitry@399: private String myRepositoryUrl; dmitry@399: dmitry@480: public PushCommand(@NotNull CommandSettings commandSettings, dmitry@480: @NotNull String hgPath, dmitry@480: @NotNull File workingDir, dmitry@480: @NotNull AuthSettings authSettings) { dmitry@480: super(commandSettings, hgPath, workingDir, authSettings); dmitry@266: } dmitry@266: dmitry@749: public PushCommand bookmark(@NotNull String bookmark) { dmitry@749: myBookmark = bookmark; dmitry@749: return this; dmitry@749: } dmitry@749: dmitry@399: public PushCommand toRepository(@NotNull String repositoryUrl) { dmitry@399: myRepositoryUrl = repositoryUrl; dmitry@399: return this; dmitry@266: } dmitry@266: dmitry@399: public void call() throws VcsException { dmitry@480: MercurialCommandLine cli = createCommandLine(); dmitry@266: cli.addParameter("push"); dmitry@749: if (myBookmark != null) { dmitry@749: cli.addParameters("-B", myBookmark); dmitry@749: } dmitry@515: if (myRepositoryUrl.startsWith("http")) { dmitry@515: addHttpAuthParams(cli); dmitry@515: cli.addParameter(myRepositoryUrl); dmitry@515: } else { dmitry@515: cli.addParameter(myAuthSettings.getRepositoryUrlWithCredentials(myRepositoryUrl)); dmitry@515: } dmitry@858: runCommand(cli, myCommandSettings); dmitry@266: } dmitry@890: dmitry@890: @NotNull dmitry@890: @Override dmitry@890: protected String getDescription() { dmitry@890: return "hg push " + myAuthSettings.getRepositoryUrlWithHiddenPassword(myRepositoryUrl); dmitry@890: } dmitry@266: }