Mercurial > hg > mercurial
changeset 599:109d7d3cdc8f
TW-28512 support subrepos nested inside the main repo
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Wed, 22 May 2013 12:35:08 +0400 |
parents | b3a18fa08362 |
children | 6c480513e5c2 |
files | mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepoTest.java mercurial-tests/src/testng.xml |
diffstat | 4 files changed, 32 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java Fri May 10 21:28:24 2013 +0200 +++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java Wed May 22 12:35:08 2013 +0400 @@ -165,7 +165,7 @@ String subrepoUrl; try { subrepoUrl = subrepoConfig.resolveUrl(parentRepositoryUrl); - if (myUseLocalMirrors && subrepoConfig.vcsType() == SubRepo.VcsType.hg && !SubRepo.isRelativeUrl(subrepoUrl)) + if (myUseLocalMirrors && subrepoConfig.vcsType() == SubRepo.VcsType.hg && !isRelativeUrl(subrepoUrl)) syncSubrepo(subrepository, subrepoUrl, subrepoConfig.revision()); } catch (URISyntaxException e) { myLogger.warning("Failed to resolve subrepo url '" + subrepoConfig.url() + "': " + e.getMessage()); @@ -175,6 +175,10 @@ } } + private boolean isRelativeUrl(@NotNull String url) { + return url.startsWith("."); + } + private void syncSubrepo(@NotNull HgRepo subrepository, @NotNull String url, @NotNull String revision) throws VcsException, IOException { if (!subrepository.isValidRepository() || !subrepository.containsRevision(revision)) { updateLocalMirror(url, revision);
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java Fri May 10 21:28:24 2013 +0200 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java Wed May 22 12:35:08 2013 +0400 @@ -43,21 +43,11 @@ return myVcsType; } - public boolean isRelative() { - return isRelativeUrl(myUrl); - } - - public static boolean isRelativeUrl(@NotNull String url) { - return url.startsWith(".."); - } - public boolean hasDifferentUrlThan(@NotNull SubRepo other) { return !myUrl.equals(other.url()); } public String resolveUrl(@NotNull String parentRepoUrl) throws URISyntaxException { - if (!isRelative()) - return url(); if (!parentRepoUrl.endsWith("/")) parentRepoUrl = parentRepoUrl + "/"; try { @@ -66,6 +56,8 @@ return subrepoAbsUrl.toString(); } catch (URISyntaxException e) { return parentRepoUrl + url(); + } catch (IllegalArgumentException e) { + return url(); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepoTest.java Wed May 22 12:35:08 2013 +0400 @@ -0,0 +1,24 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial; + +import org.jetbrains.annotations.NotNull; +import org.testng.annotations.Test; + +import static org.testng.AssertJUnit.assertEquals; + +@Test +public class SubRepoTest { + + public void url_resolution() throws Exception { + assertEquals("http://acme.org/subrepo", subrepoWithUrl("../subrepo").resolveUrl("http://acme.org/mainrepo")); + assertEquals("http://acme.org/mainrepo/subrepo", subrepoWithUrl("./subrepo").resolveUrl("http://acme.org/mainrepo")); + assertEquals("http://acme.org/mainrepo/subrepo", subrepoWithUrl("subrepo").resolveUrl("http://acme.org/mainrepo")); + assertEquals("http://some.org/subrepo", subrepoWithUrl("http://some.org/subrepo").resolveUrl("http://acme.org/mainrepo")); + assertEquals("c:/subrepo", subrepoWithUrl("c:/subrepo").resolveUrl("http://acme.org/mainrepo")); + assertEquals("c:\\subrepo", subrepoWithUrl("c:\\subrepo").resolveUrl("http://acme.org/mainrepo")); + } + + private SubRepo subrepoWithUrl(@NotNull String subrepoUrl) { + return new SubRepo("some/path", subrepoUrl, "some_revision"); + } + +}
--- a/mercurial-tests/src/testng.xml Fri May 10 21:28:24 2013 +0200 +++ b/mercurial-tests/src/testng.xml Wed May 22 12:35:08 2013 +0400 @@ -31,6 +31,7 @@ <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgRepoTest"/> <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialXmlLogParserTest"/> <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgVcsRootFactoryTest"/> + <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.SubRepoTest"/> </classes> </test> </suite>