mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
use new python script for hgweb
This commit is contained in:
@@ -41,14 +41,17 @@ import com.google.inject.Singleton;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import sonia.scm.SCMContext;
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.repository.HgConfig;
|
import sonia.scm.repository.HgConfig;
|
||||||
import sonia.scm.repository.HgHookManager;
|
import sonia.scm.repository.HgHookManager;
|
||||||
|
import sonia.scm.repository.HgPythonScript;
|
||||||
import sonia.scm.repository.HgRepositoryHandler;
|
import sonia.scm.repository.HgRepositoryHandler;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
import sonia.scm.repository.RepositoryProvider;
|
import sonia.scm.repository.RepositoryProvider;
|
||||||
import sonia.scm.repository.RepositoryRequestListenerUtil;
|
import sonia.scm.repository.RepositoryRequestListenerUtil;
|
||||||
import sonia.scm.util.AssertUtil;
|
import sonia.scm.util.AssertUtil;
|
||||||
|
import sonia.scm.util.Util;
|
||||||
import sonia.scm.web.cgi.CGIExecutor;
|
import sonia.scm.web.cgi.CGIExecutor;
|
||||||
import sonia.scm.web.cgi.CGIExecutorFactory;
|
import sonia.scm.web.cgi.CGIExecutorFactory;
|
||||||
import sonia.scm.web.cgi.EnvList;
|
import sonia.scm.web.cgi.EnvList;
|
||||||
@@ -75,7 +78,7 @@ public class HgCGIServlet extends HttpServlet
|
|||||||
{
|
{
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String ENV_PYTHON_PATH = "SCM_PYTHON_PATH";
|
public static final String ENV_PYTHON_PATH = "PYTHONPATH";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String ENV_REPOSITORY_NAME = "REPO_NAME";
|
public static final String ENV_REPOSITORY_NAME = "REPO_NAME";
|
||||||
@@ -135,7 +138,7 @@ public class HgCGIServlet extends HttpServlet
|
|||||||
@Override
|
@Override
|
||||||
public void init() throws ServletException
|
public void init() throws ServletException
|
||||||
{
|
{
|
||||||
command = HgUtil.getCGI();
|
command = HgPythonScript.HGWEB.getFile(SCMContext.getContext());
|
||||||
super.init();
|
super.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,16 +213,15 @@ public class HgCGIServlet extends HttpServlet
|
|||||||
{
|
{
|
||||||
String name = repository.getName();
|
String name = repository.getName();
|
||||||
File directory = handler.getDirectory(repository);
|
File directory = handler.getDirectory(repository);
|
||||||
String pythonPath = "";
|
String pythonPath = HgPythonScript.getScriptDirectory(
|
||||||
|
SCMContext.getContext()).getAbsolutePath();
|
||||||
HgConfig config = handler.getConfig();
|
HgConfig config = handler.getConfig();
|
||||||
|
|
||||||
if (config != null)
|
if (config != null)
|
||||||
{
|
{
|
||||||
pythonPath = config.getPythonPath();
|
if (Util.isNotEmpty(config.getPythonPath()))
|
||||||
|
|
||||||
if (pythonPath == null)
|
|
||||||
{
|
{
|
||||||
pythonPath = "";
|
pythonPath = pythonPath.concat(":").concat(config.getPythonPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,13 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
import os, sys
|
import os
|
||||||
pythonPath = os.environ['SCM_PYTHON_PATH']
|
from mercurial import demandimport
|
||||||
|
from mercurial.hgweb import hgweb, wsgicgi
|
||||||
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']
|
repositoryPath = os.environ['SCM_REPOSITORY_PATH']
|
||||||
|
|
||||||
from mercurial import demandimport; demandimport.enable()
|
demandimport.enable()
|
||||||
from mercurial.hgweb import hgweb, wsgicgi
|
|
||||||
application = hgweb(repositoryPath)
|
application = hgweb(repositoryPath)
|
||||||
wsgicgi.launch(application)
|
wsgicgi.launch(application)
|
||||||
|
|||||||
Reference in New Issue
Block a user