annotate mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommand.java @ 181:0ea2ad14ce97

Add local mirrors for agent checkout. To turn them on set agent property teamcity.hg.use.local.mirrors = true.
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Tue, 01 Mar 2011 17:55:41 +0300
parents 5198b02fc5e9
children 643fa1236f4e e8f0eb6d4ca4
rev   line source
95
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
1 /*
160
5198b02fc5e9 Update copyrights
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents: 95
diff changeset
2 * Copyright 2000-2011 JetBrains s.r.o.
95
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
3 *
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
4 * Licensed under the Apache License, Version 2.0 (the "License");
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
5 * you may not use this file except in compliance with the License.
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
6 * You may obtain a copy of the License at
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
7 *
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
8 * http://www.apache.org/licenses/LICENSE-2.0
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
9 *
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
10 * Unless required by applicable law or agreed to in writing, software
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
11 * distributed under the License is distributed on an "AS IS" BASIS,
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
13 * See the License for the specific language governing permissions and
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
14 * limitations under the License.
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 67
diff changeset
15 */
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
16 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
17
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
18 import com.intellij.execution.configurations.GeneralCommandLine;
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
19 import jetbrains.buildServer.ExecResult;
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
20 import jetbrains.buildServer.vcs.VcsException;
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
21 import org.jetbrains.annotations.NotNull;
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
22
181
0ea2ad14ce97 Add local mirrors for agent checkout. To turn them on set agent property teamcity.hg.use.local.mirrors = true.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents: 160
diff changeset
23 import java.io.File;
0ea2ad14ce97 Add local mirrors for agent checkout. To turn them on set agent property teamcity.hg.use.local.mirrors = true.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents: 160
diff changeset
24
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
25 /**
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
26 * @author pavel
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
27 */
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
28 public class PushCommand extends BaseCommand {
57
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
29 private boolean myForced;
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
30
181
0ea2ad14ce97 Add local mirrors for agent checkout. To turn them on set agent property teamcity.hg.use.local.mirrors = true.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents: 160
diff changeset
31 public PushCommand(@NotNull Settings settings, @NotNull File workingDir) {
0ea2ad14ce97 Add local mirrors for agent checkout. To turn them on set agent property teamcity.hg.use.local.mirrors = true.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents: 160
diff changeset
32 super(settings, workingDir);
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
33 }
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
34
57
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
35 public void setForce(boolean force) {
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
36 myForced = force;
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
37 }
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
38
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
39 public void execute() throws VcsException {
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
40 GeneralCommandLine cli = createCommandLine();
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
41 cli.addParameter("push");
57
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
42 if (myForced) {
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
43 cli.addParameter("-f");
99e757f2527b branches support
Pavel.Sher
parents: 44
diff changeset
44 }
67
e6971dc6b17c always use url with credentials if username/password are specified
Pavel.Sher
parents: 57
diff changeset
45 cli.addParameter(getSettings().getRepositoryUrl());
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
46 ExecResult res = runCommand(cli);
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
47 failIfNotEmptyStdErr(cli, res);
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
48 }
1490e2981799 labeling/tagging support
Pavel.Sher
parents:
diff changeset
49 }