mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
bug fixes for issue "#1 HTTP ERROR 500 when using hgweb on Windows"
This commit is contained in:
@@ -79,6 +79,17 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
return pythonBinary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPythonPath()
|
||||
{
|
||||
return pythonPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -116,6 +127,17 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
this.pythonBinary = pythonBinary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param pythonPath
|
||||
*/
|
||||
public void setPythonPath(String pythonPath)
|
||||
{
|
||||
this.pythonPath = pythonPath;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@@ -123,4 +145,7 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
|
||||
/** Field description */
|
||||
private String pythonBinary;
|
||||
|
||||
/** Field description */
|
||||
private String pythonPath = "";
|
||||
}
|
||||
|
||||
@@ -38,9 +38,11 @@ package sonia.scm.web;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import sonia.scm.repository.HgConfig;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryManager;
|
||||
import sonia.scm.util.AssertUtil;
|
||||
import sonia.scm.web.cgi.AbstractCGIServlet;
|
||||
import sonia.scm.web.cgi.EnvList;
|
||||
|
||||
@@ -63,6 +65,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
public class HgCGIServlet extends AbstractCGIServlet
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_PYTHON_PATH = "SCM_PYTHON_PATH";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_REPOSITORY_NAME = "REPO_NAME";
|
||||
|
||||
@@ -139,11 +144,42 @@ public class HgCGIServlet extends AbstractCGIServlet
|
||||
list.set(ENV_REPOSITORY_PATH, directory.getAbsolutePath());
|
||||
list.set(ENV_REPOSITORY_NAME, name);
|
||||
|
||||
String pythonPath = "";
|
||||
HgConfig config = handler.getConfig();
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
pythonPath = config.getPythonPath();
|
||||
|
||||
if (pythonPath == null)
|
||||
{
|
||||
pythonPath = "";
|
||||
}
|
||||
}
|
||||
|
||||
list.set(ENV_PYTHON_PATH, pythonPath);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected String getCmdPrefix()
|
||||
{
|
||||
HgConfig config = handler.getConfig();
|
||||
|
||||
AssertUtil.assertIsNotNull(config);
|
||||
|
||||
return config.getPythonBinary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -42,6 +42,10 @@ registerConfigPanel({
|
||||
fieldLabel : 'Python Binary',
|
||||
name : 'pythonBinary',
|
||||
allowBlank : false
|
||||
},{
|
||||
xtype : 'textfield',
|
||||
fieldLabel : 'Python Path',
|
||||
name : 'pythonPath'
|
||||
},{
|
||||
xtype: 'textfield',
|
||||
name: 'repositoryDirectory',
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
#!/usr/bin/env ${python}
|
||||
|
||||
import os
|
||||
import os, sys
|
||||
pythonPath = os.environ['SCM_PYTHON_PATH']
|
||||
|
||||
if len(pythonPath) > 0:
|
||||
pathParts = pythonPath.split(os.pathsep)
|
||||
for i in range(len(pathParts)):
|
||||
sys.path.insert(i, pathParts[i])
|
||||
|
||||
repositoryPath = os.environ['SCM_REPOSITORY_PATH']
|
||||
|
||||
from mercurial import demandimport; demandimport.enable()
|
||||
|
||||
@@ -82,8 +82,7 @@ public abstract class AbstractCGIServlet extends HttpServlet
|
||||
@Override
|
||||
public void init() throws ServletException
|
||||
{
|
||||
cgiRunner = new CGIRunner(getServletContext(), getCmdPrefix(),
|
||||
isExitStateIgnored());
|
||||
cgiRunner = new CGIRunner(getServletContext(), null, isExitStateIgnored());
|
||||
baseEnvironment = createBaseEnvironment();
|
||||
}
|
||||
|
||||
@@ -157,7 +156,8 @@ public abstract class AbstractCGIServlet extends HttpServlet
|
||||
throws ServletException, IOException
|
||||
{
|
||||
cgiRunner.exec(createRequestEnvironment(req, baseEnvironment),
|
||||
getCommand(req), req.getPathInfo(), req, resp);
|
||||
getCmdPrefix(), getCommand(req), req.getPathInfo(), req,
|
||||
resp);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
@@ -78,14 +78,14 @@ public class CGIRunner
|
||||
*
|
||||
*
|
||||
* @param context
|
||||
* @param cmdPrefix
|
||||
* @param defaultCmdPrefix
|
||||
* @param ignoreExitState
|
||||
*/
|
||||
public CGIRunner(ServletContext context, String cmdPrefix,
|
||||
public CGIRunner(ServletContext context, String defaultCmdPrefix,
|
||||
boolean ignoreExitState)
|
||||
{
|
||||
this.context = context;
|
||||
this.cmdPrefix = cmdPrefix;
|
||||
this.defaultCmdPrefix = defaultCmdPrefix;
|
||||
this.ignoreExitState = ignoreExitState;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@ public class CGIRunner
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param environment
|
||||
* @param command
|
||||
* @param pathInfo
|
||||
@@ -107,6 +106,28 @@ public class CGIRunner
|
||||
public void exec(EnvList environment, File command, String pathInfo,
|
||||
HttpServletRequest req, HttpServletResponse res)
|
||||
throws IOException
|
||||
{
|
||||
exec(environment, defaultCmdPrefix, command, pathInfo, req, res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param environment
|
||||
* @param cmdPrefix
|
||||
* @param command
|
||||
* @param pathInfo
|
||||
* @param req
|
||||
* @param res
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void exec(EnvList environment, String cmdPrefix, File command,
|
||||
String pathInfo, HttpServletRequest req,
|
||||
HttpServletResponse res)
|
||||
throws IOException
|
||||
{
|
||||
String path = command.getAbsolutePath();
|
||||
File dir = command.getParentFile();
|
||||
@@ -334,7 +355,7 @@ public class CGIRunner
|
||||
*/
|
||||
public String getCmdPrefix()
|
||||
{
|
||||
return cmdPrefix;
|
||||
return defaultCmdPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -369,7 +390,7 @@ public class CGIRunner
|
||||
*/
|
||||
public void setCmdPrefix(String cmdPrefix)
|
||||
{
|
||||
this.cmdPrefix = cmdPrefix;
|
||||
this.defaultCmdPrefix = cmdPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,10 +496,10 @@ public class CGIRunner
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String cmdPrefix;
|
||||
private ServletContext context;
|
||||
|
||||
/** Field description */
|
||||
private ServletContext context;
|
||||
private String defaultCmdPrefix;
|
||||
|
||||
/** Field description */
|
||||
private boolean ignoreExitState;
|
||||
|
||||
Reference in New Issue
Block a user