fix mercurial push with symbolic links

This commit is contained in:
Sebastian Sdorra
2011-12-23 11:32:40 +01:00
parent 03c6fd51ef
commit 8bce0b4906

View File

@@ -57,6 +57,7 @@ import sonia.scm.web.security.WebSecurityContext;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
@@ -337,8 +338,18 @@ public class HgHookCallbackServlet extends HttpServlet
if (Util.isNotEmpty(path))
{
/**
* use canonical path to fix symbolic links
* https://bitbucket.org/sdorra/scm-manager/issue/82/symbolic-link-in-hg-repository-path
*/
try
{
path = new File(path).getCanonicalPath();
int directoryLength =
handler.getConfig().getRepositoryDirectory().getAbsolutePath().length();
handler.getConfig().getRepositoryDirectory().getCanonicalPath()
.length();
if (directoryLength < path.length())
{
@@ -349,6 +360,11 @@ public class HgHookCallbackServlet extends HttpServlet
logger.warn("path is shorter as the main hg repository path");
}
}
catch (IOException ex)
{
logger.error("could not find name of repository", ex);
}
}
else if (logger.isWarnEnabled())
{
logger.warn("no repository path parameter found");