Mercurial > hg > mercurial
changeset 248:20817ebd1a05 Eluru-6.0.x
Fix TW-16278
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Tue, 19 Apr 2011 18:40:40 +0400 |
parents | dbf671db463f |
children | 7a42da852b77 |
files | mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java |
diffstat | 1 files changed, 29 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Tue Apr 19 18:35:37 2011 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Tue Apr 19 18:40:40 2011 +0400 @@ -27,6 +27,7 @@ import jetbrains.buildServer.util.filters.Filter; import jetbrains.buildServer.util.filters.FilterUtil; import jetbrains.buildServer.vcs.*; +import jetbrains.buildServer.vcs.impl.VcsRootImpl; import jetbrains.buildServer.vcs.patches.PatchBuilder; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -626,27 +627,28 @@ } public String label(@NotNull String label, @NotNull String version, @NotNull VcsRoot root, @NotNull CheckoutRules checkoutRules) throws VcsException { - syncClonedRepository(root); - - Settings settings = createSettings(root); + File tmpDir = null; + try { + tmpDir = createLabelingTmpDir(); + ((VcsRootImpl) root).addProperty(Constants.SERVER_CLONE_PATH_PROP, tmpDir.getAbsolutePath()); - // I do not know why but hg tag does not work correctly if - // update command was not invoked for the current repo - // in such case if there were no tags before Mercurial attempts to - // create new head when tag is pushed to the parent repository - UpdateCommand uc = new UpdateCommand(settings); - uc.execute(); + syncClonedRepository(root); + Settings settings = createSettings(root); + new UpdateCommand(settings).execute(); - String fixedTagname = fixTagName(label); - TagCommand tc = new TagCommand(settings); - tc.setRevId(new ChangeSet(version).getId()); - tc.setTag(fixedTagname); - tc.execute(); + String fixedTagname = fixTagName(label); + TagCommand tc = new TagCommand(settings); + tc.setRevId(new ChangeSet(version).getId()); + tc.setTag(fixedTagname); + tc.execute(); - PushCommand pc = new PushCommand(settings); -// pc.setForce(true); - pc.execute(); - return fixedTagname; + PushCommand pc = new PushCommand(settings); + pc.execute(); + return fixedTagname; + } finally { + if (tmpDir != null) + FileUtil.delete(tmpDir); + } } private String fixTagName(final String label) { @@ -690,4 +692,13 @@ public boolean isAgentSideCheckoutAvailable() { return true; } + + + private File createLabelingTmpDir() throws VcsException { + try { + return FileUtil.createTempDirectory("mercurial", "label"); + } catch (IOException e) { + throw new VcsException("Unable to create temporary directory"); + } + } }