Mercurial > hg > mercurial
changeset 681:feb909e10f22
Merge branch Gaya-8.0.x
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 29 Nov 2013 15:36:26 +0400 |
parents | 1da36037196d (current diff) 03a544f9eae1 (diff) |
children | c0b08dd02418 |
files | |
diffstat | 2 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java Tue Nov 26 15:35:11 2013 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java Fri Nov 29 15:36:26 2013 +0400 @@ -53,6 +53,8 @@ try { URI parentURI = new URI(parentRepoUrl); URI subrepoAbsUrl = parentURI.resolve(url()); + if (isSsh(subrepoAbsUrl) && isPathFromRoot(parentURI)) + return getUrlWithPathFromRoot(subrepoAbsUrl); return subrepoAbsUrl.toString(); } catch (URISyntaxException e) { return parentRepoUrl + url(); @@ -61,6 +63,25 @@ } } + private boolean isSsh(@NotNull URI uri) { + return "ssh".equals(uri.getScheme()); + } + + private boolean isPathFromRoot(@NotNull URI uri) { + return uri.getPath() != null && uri.getPath().startsWith("//"); + } + + @NotNull + private String getUrlWithPathFromRoot(@NotNull URI uri) throws URISyntaxException { + return new URI(uri.getScheme(), + uri.getUserInfo(), + uri.getHost(), + uri.getPort(), + "/" + uri.getPath(), + uri.getQuery(), + uri.getFragment()).toString(); + } + @Override public String toString() { return myPath + " = " + myUrl + "#" + myRevision;
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepoTest.java Tue Nov 26 15:35:11 2013 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepoTest.java Fri Nov 29 15:36:26 2013 +0400 @@ -9,12 +9,15 @@ public class SubRepoTest { public void url_resolution() throws Exception { + //http://www.selenic.com/mercurial/hg.1.html#urls 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")); + assertEquals("ssh://acme.org//subrepo", subrepoWithUrl("../subrepo").resolveUrl("ssh://acme.org//mainrepo")); + assertEquals("ssh://acme.org/subrepo", subrepoWithUrl("../subrepo").resolveUrl("ssh://acme.org/mainrepo")); } private SubRepo subrepoWithUrl(@NotNull String subrepoUrl) {