Mercurial > hg > mercurial
annotate mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BranchesCommand.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 | 1 /* |
160
5198b02fc5e9
Update copyrights
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
2 * Copyright 2000-2011 JetBrains s.r.o. |
95 | 3 * |
4 * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 * you may not use this file except in compliance with the License. | |
6 * You may obtain a copy of the License at | |
7 * | |
8 * http://www.apache.org/licenses/LICENSE-2.0 | |
9 * | |
10 * Unless required by applicable law or agreed to in writing, software | |
11 * distributed under the License is distributed on an "AS IS" BASIS, | |
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 * See the License for the specific language governing permissions and | |
14 * limitations under the License. | |
15 */ | |
57 | 16 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; |
17 | |
18 import com.intellij.execution.configurations.GeneralCommandLine; | |
19 import jetbrains.buildServer.ExecResult; | |
20 import jetbrains.buildServer.vcs.VcsException; | |
21 import org.jetbrains.annotations.NotNull; | |
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; |
57 | 24 import java.util.HashMap; |
25 import java.util.Map; | |
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
|
26 import java.util.regex.Matcher; |
57 | 27 import java.util.regex.Pattern; |
28 | |
29 /** | |
30 * @author Pavel.Sher | |
31 * Date: 26.10.2008 | |
32 */ | |
33 public class BranchesCommand extends BaseCommand { | |
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
|
34 |
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
|
35 public BranchesCommand(@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
|
36 super(settings, workingDir); |
57 | 37 } |
38 | |
39 /** | |
40 * Returns map of branch name to latest changeset in that branch | |
41 * @return see above | |
42 * @throws jetbrains.buildServer.vcs.VcsException if error occurs | |
43 */ | |
44 public Map<String, ChangeSet> execute() throws VcsException { | |
45 GeneralCommandLine cli = createCommandLine(); | |
46 cli.addParameter("branches"); | |
47 ExecResult res = runCommand(cli); | |
48 String stdout = res.getStdout(); | |
49 Map<String, ChangeSet> result = new HashMap<String, ChangeSet>(); | |
50 Pattern branchPattern = Pattern.compile("(.*)[\\s]+([0-9]+:[A-Za-z0-9]+).*"); | |
51 for (String line: stdout.split("[\r\n]+")) { | |
52 Matcher matcher = branchPattern.matcher(line); | |
53 if (matcher.matches()) { | |
54 String branchName = matcher.group(1).trim(); | |
55 String changeId = matcher.group(2).trim(); | |
56 result.put(branchName, new ChangeSet(changeId)); | |
57 } | |
58 } | |
59 return result; | |
60 } | |
61 } |