changeset 733:5211baefb5ec

Handle windows paths in subrepo resolving
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Thu, 16 Jan 2014 13:56:33 +0100
parents 31a1aca3305c
children a75aae928f79
files mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java	Tue Jan 14 12:45:10 2014 +0100
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java	Thu Jan 16 13:56:33 2014 +0100
@@ -17,8 +17,11 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.WrongSubrepoUrlException;
+import jetbrains.buildServer.util.FileUtil;
 import org.jetbrains.annotations.NotNull;
 
+import java.io.File;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 
@@ -73,7 +76,6 @@
 
   @NotNull
   public String resolveUrl(@NotNull String parentRepoUrl) throws WrongSubrepoUrlException {
-    //TODO: Handle paths on windows. Those paths are not papable for URL
     if (!parentRepoUrl.endsWith("/"))
       parentRepoUrl = parentRepoUrl + "/";
     try {
@@ -83,6 +85,14 @@
         return getUrlWithPathFromRoot(subrepoAbsUrl);
       return subrepoAbsUrl.toString();
     } catch (Exception e) {
+      File parentRepoDir = new File(parentRepoUrl);
+      if (parentRepoDir.isDirectory()) {//handle windows paths
+        try {
+          return FileUtil.resolvePath(parentRepoDir, url()).getCanonicalPath();
+        } catch (IOException e1) {
+          throw new WrongSubrepoUrlException(parentRepoUrl, url(), e);
+        }
+      }
       throw new WrongSubrepoUrlException(parentRepoUrl, url(), e);
     }
   }