Mercurial > hg > mercurial
annotate mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java @ 57:99e757f2527b
branches support
author | Pavel.Sher |
---|---|
date | Sun, 26 Oct 2008 16:23:50 +0300 |
parents | 45366338965b |
children | d1ed856e38ea |
rev | line source |
---|---|
25 | 1 /* |
2 * Copyright 2000-2007 JetBrains s.r.o. | |
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 */ | |
0 | 16 package jetbrains.buildServer.buildTriggers.vcs.mercurial; |
17 | |
48 | 18 import jetbrains.buildServer.AgentSideCheckoutAbility; |
0 | 19 import jetbrains.buildServer.CollectChangesByIncludeRule; |
20 import jetbrains.buildServer.Used; | |
21 import jetbrains.buildServer.buildTriggers.vcs.AbstractVcsPropertiesProcessor; | |
22 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.*; | |
23 import jetbrains.buildServer.log.Loggers; | |
24 import jetbrains.buildServer.serverSide.InvalidProperty; | |
25 import jetbrains.buildServer.serverSide.PropertiesProcessor; | |
21 | 26 import jetbrains.buildServer.serverSide.SBuildServer; |
0 | 27 import jetbrains.buildServer.serverSide.ServerPaths; |
28 import jetbrains.buildServer.util.FileUtil; | |
29 import jetbrains.buildServer.vcs.*; | |
30 import jetbrains.buildServer.vcs.patches.PatchBuilder; | |
31 import org.jetbrains.annotations.NotNull; | |
32 import org.jetbrains.annotations.Nullable; | |
33 | |
1 | 34 import java.io.File; |
35 import java.io.FileFilter; | |
36 import java.io.FileInputStream; | |
37 import java.io.IOException; | |
38 import java.util.*; | |
21 | 39 import java.util.concurrent.ConcurrentHashMap; |
40 import java.util.concurrent.ConcurrentMap; | |
41 import java.util.concurrent.TimeUnit; | |
42 import java.util.concurrent.locks.Lock; | |
43 import java.util.concurrent.locks.ReentrantLock; | |
1 | 44 |
19 | 45 /** |
46 * Mercurial VCS plugin for TeamCity works as follows: | |
47 * <ul> | |
48 * <li>clones repository to internal storage | |
49 * <li>before any operation with working copy of repository pulls changes from the original repository | |
50 * <li>executes corresponding hg command | |
51 * </ul> | |
52 * | |
57 | 53 * <p>Working copy of repository is created in the $TEAMCITY_DATA_PATH/system/caches/hg_<hash code> folder. |
19 | 54 * <p>Personal builds (remote runs) are not yet supported, they require corresponding functionality from the IDE. |
55 */ | |
48 | 56 public class MercurialVcsSupport extends VcsSupport implements CollectChangesByIncludeRule, LabelingSupport, AgentSideCheckoutAbility { |
21 | 57 private ConcurrentMap<String, Lock> myWorkDirLocks= new ConcurrentHashMap<String, Lock>(); |
58 private static final int OLD_WORK_DIRS_CLEANUP_PERIOD = 600; | |
59 private VcsManager myVcsManager; | |
27
7944e8985ebd
prepare modules structure for agent side checkout
Pavel.Sher
parents:
25
diff
changeset
|
60 private File myDefaultWorkFolderParent; |
0 | 61 |
21 | 62 public MercurialVcsSupport(@NotNull final VcsManager vcsManager, |
63 @NotNull ServerPaths paths, | |
64 @NotNull SBuildServer server) { | |
0 | 65 vcsManager.registerVcsSupport(this); |
21 | 66 myVcsManager = vcsManager; |
67 server.getExecutor().scheduleAtFixedRate(new Runnable() { | |
68 public void run() { | |
69 removeOldWorkFolders(); | |
70 } | |
71 }, 0, OLD_WORK_DIRS_CLEANUP_PERIOD, TimeUnit.SECONDS); | |
27
7944e8985ebd
prepare modules structure for agent side checkout
Pavel.Sher
parents:
25
diff
changeset
|
72 myDefaultWorkFolderParent = new File(paths.getCachesDir()); |
0 | 73 } |
74 | |
75 public List<ModificationData> collectBuildChanges(final VcsRoot root, | |
76 @NotNull final String fromVersion, | |
77 @NotNull final String currentVersion, | |
78 final CheckoutRules checkoutRules) throws VcsException { | |
44 | 79 syncClonedRepository(root); |
0 | 80 return VcsSupportUtil.collectBuildChanges(root, fromVersion, currentVersion, checkoutRules, this); |
81 } | |
82 | |
83 public List<ModificationData> collectBuildChanges(final VcsRoot root, | |
84 final String fromVersion, | |
85 final String currentVersion, | |
86 final IncludeRule includeRule) throws VcsException { | |
19 | 87 // first obtain changes between specified versions |
0 | 88 List<ModificationData> result = new ArrayList<ModificationData>(); |
44 | 89 Settings settings = createSettings(root); |
0 | 90 LogCommand lc = new LogCommand(settings); |
57 | 91 String fromId = new ChangeSet(fromVersion).getId(); |
92 lc.setFromRevId(fromId); | |
0 | 93 lc.setToRevId(new ChangeSet(currentVersion).getId()); |
94 List<ChangeSet> changeSets = lc.execute(); | |
95 if (changeSets.isEmpty()) { | |
96 return result; | |
97 } | |
98 | |
19 | 99 // invoke status command for each changeset and determine what files were modified in these changesets |
0 | 100 StatusCommand st = new StatusCommand(settings); |
57 | 101 ChangeSet prev = new ChangeSet(fromVersion); |
102 for (int i=0; i<changeSets.size(); i++) { | |
103 ChangeSet cur = changeSets.get(i); | |
104 if (cur.getId().equals(fromId)) continue; // skip already reported changeset | |
105 | |
0 | 106 st.setFromRevId(prev.getId()); |
107 st.setToRevId(cur.getId()); | |
108 List<ModifiedFile> modifiedFiles = st.execute(); | |
19 | 109 // changeset full version will be set into VcsChange structure and |
20 | 110 // stored in database (note that getContent method will be invoked with this version) |
0 | 111 List<VcsChange> files = toVcsChanges(modifiedFiles, prev.getFullVersion(), cur.getFullVersion(), includeRule); |
112 if (files.isEmpty()) continue; | |
113 ModificationData md = new ModificationData(cur.getTimestamp(), files, cur.getSummary(), cur.getUser(), root, cur.getFullVersion(), cur.getFullVersion()); | |
114 result.add(md); | |
115 prev = cur; | |
116 } | |
117 | |
118 return result; | |
119 } | |
120 | |
121 private List<VcsChange> toVcsChanges(final List<ModifiedFile> modifiedFiles, String prevVer, String curVer, final IncludeRule includeRule) { | |
122 List<VcsChange> files = new ArrayList<VcsChange>(); | |
123 for (ModifiedFile mf: modifiedFiles) { | |
21 | 124 String normalizedPath = PathUtil.normalizeSeparator(mf.getPath()); |
12 | 125 if (!normalizedPath.startsWith(includeRule.getFrom())) continue; // skip files which do not match include rule |
0 | 126 |
127 VcsChangeInfo.Type changeType = getChangeType(mf.getStatus()); | |
128 if (changeType == null) { | |
129 Loggers.VCS.warn("Unable to convert status: " + mf.getStatus() + " to VCS change type"); | |
130 changeType = VcsChangeInfo.Type.NOT_CHANGED; | |
131 } | |
12 | 132 files.add(new VcsChange(changeType, mf.getStatus().getName(), normalizedPath, normalizedPath, prevVer, curVer)); |
0 | 133 } |
134 return files; | |
135 } | |
136 | |
137 private VcsChangeInfo.Type getChangeType(final ModifiedFile.Status status) { | |
138 switch (status) { | |
139 case ADDED:return VcsChangeInfo.Type.ADDED; | |
140 case MODIFIED:return VcsChangeInfo.Type.CHANGED; | |
141 case REMOVED:return VcsChangeInfo.Type.REMOVED; | |
142 } | |
143 return null; | |
144 } | |
145 | |
146 @NotNull | |
147 public byte[] getContent(final VcsModification vcsModification, | |
148 final VcsChangeInfo change, | |
149 final VcsChangeInfo.ContentType contentType, | |
150 final VcsRoot vcsRoot) throws VcsException { | |
44 | 151 syncClonedRepository(vcsRoot); |
12 | 152 String version = contentType == VcsChangeInfo.ContentType.AFTER_CHANGE ? change.getAfterChangeRevisionNumber() : change.getBeforeChangeRevisionNumber(); |
153 return getContent(change.getRelativeFileName(), vcsRoot, version); | |
0 | 154 } |
155 | |
156 @NotNull | |
12 | 157 public byte[] getContent(final String filePath, final VcsRoot vcsRoot, final String version) throws VcsException { |
44 | 158 syncClonedRepository(vcsRoot); |
159 Settings settings = createSettings(vcsRoot); | |
12 | 160 CatCommand cc = new CatCommand(settings); |
161 ChangeSet cs = new ChangeSet(version); | |
162 cc.setRevId(cs.getId()); | |
163 File parentDir = cc.execute(Collections.singletonList(filePath)); | |
30 | 164 try { |
165 File file = new File(parentDir, filePath); | |
166 if (file.isFile()) { | |
167 try { | |
168 return FileUtil.loadFileBytes(file); | |
169 } catch (IOException e) { | |
170 throw new VcsException("Failed to load content of file: " + file.getAbsolutePath(), e); | |
171 } | |
172 } else { | |
173 Loggers.VCS.warn("Unable to obtain content of the file: " + filePath); | |
12 | 174 } |
30 | 175 } finally { |
176 FileUtil.delete(parentDir); | |
12 | 177 } |
0 | 178 return new byte[0]; |
179 } | |
180 | |
181 public String getName() { | |
28
a7cab5083ada
libraries moved on top level, dummy implementation of agent side checkout interface
Pavel.Sher
parents:
27
diff
changeset
|
182 return Constants.VCS_NAME; |
0 | 183 } |
184 | |
185 @Used("jsp") | |
186 public String getDisplayName() { | |
187 return "Mercurial"; | |
188 } | |
189 | |
190 @Nullable | |
191 public PropertiesProcessor getVcsPropertiesProcessor() { | |
192 return new AbstractVcsPropertiesProcessor() { | |
193 public Collection<InvalidProperty> process(final Map<String, String> properties) { | |
194 List<InvalidProperty> result = new ArrayList<InvalidProperty>(); | |
195 if (isEmpty(properties.get(Constants.HG_COMMAND_PATH_PROP))) { | |
196 result.add(new InvalidProperty(Constants.HG_COMMAND_PATH_PROP, "Path to 'hg' command must be specified")); | |
197 } | |
198 if (isEmpty(properties.get(Constants.REPOSITORY_PROP))) { | |
199 result.add(new InvalidProperty(Constants.REPOSITORY_PROP, "Repository must be specified")); | |
200 } | |
201 return result; | |
202 } | |
203 }; | |
204 } | |
205 | |
206 public String getVcsSettingsJspFilePath() { | |
207 return "mercurialSettings.jsp"; | |
208 } | |
209 | |
210 @NotNull | |
211 public String getCurrentVersion(final VcsRoot root) throws VcsException { | |
19 | 212 // we will return full version of the most recent change as current version |
44 | 213 syncClonedRepository(root); |
214 Settings settings = createSettings(root); | |
57 | 215 BranchesCommand branches = new BranchesCommand(settings); |
216 Map<String, ChangeSet> result = branches.execute(); | |
217 if (!result.containsKey(settings.getBranchName())) { | |
218 throw new VcsException("Unable to find current version for the branch: " + settings.getBranchName()); | |
219 } | |
220 | |
221 return result.get(settings.getBranchName()).getFullVersion(); | |
0 | 222 } |
223 | |
224 public String describeVcsRoot(final VcsRoot vcsRoot) { | |
225 return "mercurial: " + vcsRoot.getProperty(Constants.REPOSITORY_PROP); | |
226 } | |
227 | |
228 public boolean isTestConnectionSupported() { | |
16
7aa397165fa0
identify command added, test connection now uses identify command
Pavel.Sher
parents:
13
diff
changeset
|
229 return true; |
0 | 230 } |
231 | |
232 @Nullable | |
233 public String testConnection(final VcsRoot vcsRoot) throws VcsException { | |
44 | 234 Settings settings = createSettings(vcsRoot); |
16
7aa397165fa0
identify command added, test connection now uses identify command
Pavel.Sher
parents:
13
diff
changeset
|
235 IdentifyCommand id = new IdentifyCommand(settings); |
7aa397165fa0
identify command added, test connection now uses identify command
Pavel.Sher
parents:
13
diff
changeset
|
236 StringBuilder res = new StringBuilder(); |
17 | 237 res.append(quoteIfNeeded(settings.getHgCommandPath())); |
238 res.append(" identify "); | |
239 res.append(quoteIfNeeded(settings.getRepository())); | |
16
7aa397165fa0
identify command added, test connection now uses identify command
Pavel.Sher
parents:
13
diff
changeset
|
240 res.append('\n').append(id.execute()); |
7aa397165fa0
identify command added, test connection now uses identify command
Pavel.Sher
parents:
13
diff
changeset
|
241 return res.toString(); |
0 | 242 } |
243 | |
17 | 244 private String quoteIfNeeded(@NotNull String str) { |
245 if (str.indexOf(' ') != -1) { | |
246 return "\"" + str + "\""; | |
247 } | |
248 | |
249 return str; | |
250 } | |
251 | |
0 | 252 @Nullable |
253 public Map<String, String> getDefaultVcsProperties() { | |
19 | 254 return Collections.singletonMap(Constants.HG_COMMAND_PATH_PROP, "hg"); |
0 | 255 } |
256 | |
257 public String getVersionDisplayName(final String version, final VcsRoot root) throws VcsException { | |
56 | 258 int colon = version.indexOf(':'); |
259 if (colon == -1) return version; | |
260 return version.substring(colon+1); | |
0 | 261 } |
262 | |
263 @NotNull | |
264 public Comparator<String> getVersionComparator() { | |
19 | 265 // comparator is called when TeamCity needs to sort modifications in the order of their appearance, |
266 // currently we sort changes by revision number, not sure however that this is a good idea, | |
267 // probably it would be better to sort them by timestamp (and to add timestamp into the version). | |
0 | 268 return new Comparator<String>() { |
269 public int compare(final String o1, final String o2) { | |
270 try { | |
271 return new ChangeSet(o1).getRevNumber() - new ChangeSet(o2).getRevNumber(); | |
272 } catch (Exception e) { | |
273 return 1; | |
274 } | |
275 } | |
276 }; | |
277 } | |
278 | |
279 public void buildPatch(final VcsRoot root, | |
280 @Nullable final String fromVersion, | |
281 @NotNull final String toVersion, | |
282 final PatchBuilder builder, | |
283 final CheckoutRules checkoutRules) throws IOException, VcsException { | |
44 | 284 syncClonedRepository(root); |
285 Settings settings = createSettings(root); | |
0 | 286 if (fromVersion == null) { |
287 buildFullPatch(settings, new ChangeSet(toVersion), builder); | |
288 } else { | |
289 buildIncrementalPatch(settings, new ChangeSet(fromVersion), new ChangeSet(toVersion), builder); | |
290 } | |
291 } | |
292 | |
19 | 293 // builds patch from version to version |
0 | 294 private void buildIncrementalPatch(final Settings settings, @NotNull final ChangeSet fromVer, @NotNull final ChangeSet toVer, final PatchBuilder builder) |
295 throws VcsException, IOException { | |
296 StatusCommand st = new StatusCommand(settings); | |
297 st.setFromRevId(fromVer.getId()); | |
298 st.setToRevId(toVer.getId()); | |
299 List<ModifiedFile> modifiedFiles = st.execute(); | |
300 List<String> notDeletedFiles = new ArrayList<String>(); | |
301 for (ModifiedFile f: modifiedFiles) { | |
302 if (f.getStatus() != ModifiedFile.Status.REMOVED) { | |
303 notDeletedFiles.add(f.getPath()); | |
304 } | |
305 } | |
306 | |
47
c785bc4c5f39
minor fix: do not call cat command if there are no files to export
Pavel.Sher
parents:
46
diff
changeset
|
307 if (notDeletedFiles.isEmpty()) return; |
c785bc4c5f39
minor fix: do not call cat command if there are no files to export
Pavel.Sher
parents:
46
diff
changeset
|
308 |
0 | 309 CatCommand cc = new CatCommand(settings); |
310 cc.setRevId(toVer.getId()); | |
311 File parentDir = cc.execute(notDeletedFiles); | |
312 | |
313 try { | |
314 for (ModifiedFile f: modifiedFiles) { | |
315 final File virtualFile = new File(f.getPath()); | |
316 if (f.getStatus() == ModifiedFile.Status.REMOVED) { | |
317 builder.deleteFile(virtualFile, true); | |
318 } else { | |
319 File realFile = new File(parentDir, f.getPath()); | |
320 FileInputStream is = new FileInputStream(realFile); | |
321 try { | |
11 | 322 builder.changeOrCreateBinaryFile(virtualFile, null, is, realFile.length()); |
0 | 323 } finally { |
324 is.close(); | |
325 } | |
326 } | |
327 } | |
328 } finally { | |
329 FileUtil.delete(parentDir); | |
330 } | |
331 } | |
332 | |
19 | 333 // builds patch by exporting files using specified version |
0 | 334 private void buildFullPatch(final Settings settings, @NotNull final ChangeSet toVer, final PatchBuilder builder) |
335 throws IOException, VcsException { | |
336 CloneCommand cl = new CloneCommand(settings); | |
57 | 337 // clone from the local repository |
338 cl.setRepositoryPath(settings.getLocalRepositoryDir().getAbsolutePath()); | |
0 | 339 cl.setToId(toVer.getId()); |
57 | 340 cl.setUpdateWorkingDir(false); |
0 | 341 File tempDir = FileUtil.createTempDirectory("mercurial", toVer.getId()); |
342 try { | |
343 final File repRoot = new File(tempDir, "rep"); | |
344 cl.setDestDir(repRoot.getAbsolutePath()); | |
345 cl.execute(); | |
57 | 346 |
347 UpdateCommand up = new UpdateCommand(settings); | |
348 up.setWorkDirectory(repRoot.getAbsolutePath()); | |
349 up.setToId(toVer.getId()); | |
350 up.execute(); | |
351 | |
0 | 352 buildPatchFromDirectory(builder, repRoot, new FileFilter() { |
353 public boolean accept(final File file) { | |
354 return !(file.isDirectory() && ".hg".equals(file.getName())); | |
355 } | |
356 }); | |
357 } finally { | |
358 FileUtil.delete(tempDir); | |
359 } | |
360 } | |
361 | |
362 private void buildPatchFromDirectory(final PatchBuilder builder, final File repRoot, final FileFilter filter) throws IOException { | |
363 buildPatchFromDirectory(repRoot, builder, repRoot, filter); | |
364 } | |
365 | |
366 private void buildPatchFromDirectory(File curDir, final PatchBuilder builder, final File repRoot, final FileFilter filter) throws IOException { | |
367 File[] files = curDir.listFiles(filter); | |
368 if (files != null) { | |
369 for (File realFile: files) { | |
370 String relPath = realFile.getAbsolutePath().substring(repRoot.getAbsolutePath().length()); | |
371 final File virtualFile = new File(relPath); | |
372 if (realFile.isDirectory()) { | |
373 builder.createDirectory(virtualFile); | |
374 buildPatchFromDirectory(realFile, builder, repRoot, filter); | |
375 } else { | |
376 final FileInputStream is = new FileInputStream(realFile); | |
377 try { | |
378 builder.createBinaryFile(virtualFile, null, is, realFile.length()); | |
379 } finally { | |
380 is.close(); | |
381 } | |
382 } | |
383 } | |
384 } | |
385 } | |
386 | |
19 | 387 // updates current working copy of repository by pulling changes from the repository specified in VCS root |
44 | 388 private void syncClonedRepository(final VcsRoot root) throws VcsException { |
389 Settings settings = createSettings(root); | |
57 | 390 File workDir = settings.getLocalRepositoryDir(); |
21 | 391 lockWorkDir(workDir); |
392 try { | |
29 | 393 if (settings.hasCopyOfRepository()) { |
0 | 394 // update |
8 | 395 PullCommand pull = new PullCommand(settings); |
396 pull.execute(); | |
0 | 397 } else { |
398 // clone | |
399 CloneCommand cl = new CloneCommand(settings); | |
22 | 400 cl.setDestDir(workDir.getAbsolutePath()); |
18 | 401 cl.setUpdateWorkingDir(false); |
0 | 402 cl.execute(); |
403 } | |
21 | 404 } finally { |
405 unlockWorkDir(workDir); | |
0 | 406 } |
407 } | |
408 | |
44 | 409 @Override |
410 public LabelingSupport getLabelingSupport() { | |
411 return this; | |
412 } | |
413 | |
22 | 414 private void lockWorkDir(@NotNull File workDir) { |
21 | 415 getWorkDirLock(workDir).lock(); |
416 } | |
417 | |
22 | 418 private void unlockWorkDir(@NotNull File workDir) { |
21 | 419 getWorkDirLock(workDir).unlock(); |
420 } | |
421 | |
31 | 422 @Override |
423 public boolean ignoreServerCachesFor(final VcsRoot root) { | |
424 // since a copy of repository for each VCS root is already stored on disk | |
425 // we do not need separate cache for our patches | |
426 return true; | |
427 } | |
428 | |
22 | 429 private Lock getWorkDirLock(final File workDir) { |
430 String path = workDir.getAbsolutePath(); | |
431 Lock lock = myWorkDirLocks.get(path); | |
21 | 432 if (lock == null) { |
433 lock = new ReentrantLock(); | |
22 | 434 Lock curLock = myWorkDirLocks.putIfAbsent(path, lock); |
21 | 435 if (curLock != null) { |
436 lock = curLock; | |
437 } | |
438 } | |
439 return lock; | |
440 } | |
441 | |
23 | 442 private void removeOldWorkFolders() { |
29 | 443 File workFoldersParent = new File(myDefaultWorkFolderParent, "mercurial"); |
23 | 444 if (!workFoldersParent.isDirectory()) return; |
445 | |
446 Set<File> workDirs = new HashSet<File>(); | |
447 File[] files = workFoldersParent.listFiles(new FileFilter() { | |
448 public boolean accept(final File file) { | |
449 return file.isDirectory() && file.getName().startsWith(Settings.DEFAULT_WORK_DIR_PREFIX); | |
450 } | |
451 }); | |
452 if (files != null) { | |
453 for (File f: files) { | |
46 | 454 workDirs.add(PathUtil.getCanonicalFile(f)); |
23 | 455 } |
456 } | |
457 | |
458 for (VcsRoot vcsRoot: myVcsManager.getAllRegisteredVcsRoots()) { | |
459 if (getName().equals(vcsRoot.getVcsName())) { | |
44 | 460 Settings s = createSettings(vcsRoot); |
57 | 461 workDirs.remove(PathUtil.getCanonicalFile(s.getLocalRepositoryDir())); |
23 | 462 } |
463 } | |
464 | |
465 for (File f: workDirs) { | |
466 lockWorkDir(f); | |
467 try { | |
468 FileUtil.delete(f); | |
469 } finally { | |
470 unlockWorkDir(f); | |
471 } | |
472 } | |
473 } | |
44 | 474 |
475 public String label(@NotNull String label, @NotNull String version, @NotNull VcsRoot root, @NotNull CheckoutRules checkoutRules) throws VcsException { | |
476 syncClonedRepository(root); | |
477 | |
478 Settings settings = createSettings(root); | |
479 | |
480 // I do not know why but hg tag does not work correctly if | |
481 // update command was not invoked for the current repo | |
482 // in such case if there were no tags before Mercurial attempts to | |
483 // create new head when tag is pushed to the parent repository | |
484 UpdateCommand uc = new UpdateCommand(settings); | |
485 uc.execute(); | |
486 | |
487 String fixedTagname = fixTagName(label); | |
488 TagCommand tc = new TagCommand(settings); | |
489 tc.setRevId(new ChangeSet(version).getId()); | |
490 tc.setTag(fixedTagname); | |
491 tc.execute(); | |
492 | |
493 PushCommand pc = new PushCommand(settings); | |
57 | 494 pc.setForce(true); |
44 | 495 pc.execute(); |
496 return fixedTagname; | |
497 } | |
498 | |
499 private String fixTagName(final String label) { | |
500 // according to Mercurial documentation http://hgbook.red-bean.com/hgbookch8.html#x12-1570008 | |
501 // tag name must not contain: | |
502 // Colon (ASCII 58, “:”) | |
503 // Carriage return (ASCII 13, “\r”) | |
504 // Newline (ASCII 10, “\n”) | |
505 // all these characters will be replaced with _ (underscore) | |
506 return label.replace(':', '_').replace('\r', '_').replace('\n', '_'); | |
507 } | |
508 | |
509 private Settings createSettings(final VcsRoot root) { | |
510 return new Settings(myDefaultWorkFolderParent, root); | |
511 } | |
48 | 512 |
513 public boolean isAgentSideCheckoutAvailable() { | |
514 return true; | |
515 } | |
0 | 516 } |