Mercurial > hg > mercurial
changeset 900:b83484e825b7
TW-36401 ability to disable custom clone dir even if it specified in VCS root
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Thu, 13 Nov 2014 15:24:26 +0100 |
parents | e7b716719044 |
children | d26bf03be294 |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Constants.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java mercurial-server/resources/buildServerResources/mercurialSettings.jsp mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java |
diffstat | 4 files changed, 40 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Constants.java Thu Nov 13 14:44:52 2014 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Constants.java Thu Nov 13 15:24:26 2014 +0100 @@ -42,4 +42,5 @@ String USE_AGENT_MIRRORS = "useSharedMirrors"; String SHOW_CUSTOM_CLONE_PATH = "teamcity.hg.showCustomClonePath"; + String CUSTOM_CLONE_PATH_ENABLED = "teamcity.hg.customClonePathEnabled"; }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java Thu Nov 13 14:44:52 2014 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java Thu Nov 13 15:24:26 2014 +0100 @@ -60,7 +60,7 @@ myRepository = getProperty(Constants.REPOSITORY_PROP); myHgCommandPath = getProperty(Constants.HG_COMMAND_PATH_PROP); myBranchName = getProperty(Constants.BRANCH_NAME_PROP); - myCustomClonePath = getProperty(Constants.SERVER_CLONE_PATH_PROP); + myCustomClonePath = readCustomClonePath(); myUncompressedTransfer = "true".equals(getProperty(Constants.UNCOMPRESSED_TRANSFER)); myUserForTag = getProperty(Constants.USER_FOR_TAG); myAuthSettings = new AuthSettings(getProperty(Constants.USERNAME), getProperty(Constants.PASSWORD)); @@ -196,6 +196,12 @@ return myVcsRootProperties.get(propertyName); } + private String readCustomClonePath() { + if (TeamCityProperties.getBooleanOrTrue(Constants.CUSTOM_CLONE_PATH_ENABLED)) + return getProperty(Constants.SERVER_CLONE_PATH_PROP); + return null; + } + @NotNull public String getProperty(@NotNull String propertyName, @NotNull String defaultValue) { String value = myVcsRootProperties.get(propertyName);
--- a/mercurial-server/resources/buildServerResources/mercurialSettings.jsp Thu Nov 13 14:44:52 2014 +0100 +++ b/mercurial-server/resources/buildServerResources/mercurialSettings.jsp Thu Nov 13 15:24:26 2014 +0100 @@ -28,7 +28,9 @@ } </script> <c:set var="subreposGloballyDisabled" value="<%= !TeamCityProperties.getBooleanOrTrue(Constants.GLOBAL_DETECT_SUBREPO_CHANGES) %>"/> -<c:set var="showCustomClonePath" value="<%= TeamCityProperties.getBoolean(Constants.SHOW_CUSTOM_CLONE_PATH) || !StringUtil.isEmpty(propertiesBean.getProperties().get(Constants.SERVER_CLONE_PATH_PROP))%>"/> +<c:set var="showCustomClonePath" value="<%= TeamCityProperties.getBooleanOrTrue(Constants.CUSTOM_CLONE_PATH_ENABLED) && + (TeamCityProperties.getBoolean(Constants.SHOW_CUSTOM_CLONE_PATH) + || !StringUtil.isEmpty(propertiesBean.getProperties().get(Constants.SERVER_CLONE_PATH_PROP))) %>"/> <table class="runnerFormTable"> <l:settingsGroup title="General Settings">
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java Thu Nov 13 14:44:52 2014 +0100 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java Thu Nov 13 15:24:26 2014 +0100 @@ -16,16 +16,30 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; +import jetbrains.buildServer.serverSide.BasePropertiesModel; +import jetbrains.buildServer.serverSide.TeamCityProperties; +import jetbrains.buildServer.util.TestFor; +import jetbrains.buildServer.vcs.VcsRoot; import jetbrains.buildServer.vcs.impl.VcsRootImpl; import junit.framework.TestCase; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.File; + +import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot; + /** * @author Pavel.Sher */ @Test public class HgVcsRootTest extends TestCase { + @BeforeMethod + public void setUp() throws Exception { + new TeamCityProperties() {{ setModel(new BasePropertiesModel() {});}}; + } + public void test_url_without_credentials() { VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path"); HgVcsRoot root = new HgVcsRoot(vcsRoot); @@ -103,6 +117,21 @@ assertEquals("ssh://user:pwd@ourserver.com/mercurialrepo/", root.getRepositoryUrlWithCredentials()); } + @TestFor(issues = "TW-36401") + public void test_disabling_custom_clone_dirs() throws Exception { + File cloneDir = new File(""); + VcsRoot root = vcsRoot().withCloneRepositoryTo(cloneDir).withUrl("http://some.org/repo").build(); + HgVcsRoot hgRoot1 = new HgVcsRoot(root); + assertEquals(cloneDir.getAbsolutePath(), hgRoot1.getCustomClonePath()); + try { + System.setProperty(Constants.CUSTOM_CLONE_PATH_ENABLED, "false"); + HgVcsRoot hgRoot2 = new HgVcsRoot(root); + assertNull(hgRoot2.getCustomClonePath()); + } finally { + System.getProperties().remove(Constants.CUSTOM_CLONE_PATH_ENABLED); + } + } + private VcsRootImpl createVcsRoot(String url) { return createVcsRoot(url, "user", "pwd"); }