mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
improve performance of mercurial changesetviewer
This commit is contained in:
@@ -39,7 +39,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.SCMContext;
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.HgConfig;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
@@ -53,6 +52,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
@@ -96,16 +96,15 @@ public class HgUtil
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @param repository
|
||||
* @param revision
|
||||
* @param path
|
||||
* @param directory
|
||||
* @param extraEnv
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Process createPythonProcess(HgRepositoryHandler handler,
|
||||
Repository repository, String revision, String path)
|
||||
File directory, Map<String, String> extraEnv)
|
||||
throws IOException
|
||||
{
|
||||
HgConfig config = handler.getConfig();
|
||||
@@ -113,12 +112,8 @@ public class HgUtil
|
||||
Map<String, String> env = pb.environment();
|
||||
|
||||
env.put(ENV_PYTHON_PATH, Util.nonNull(config.getPythonPath()));
|
||||
|
||||
String directory = handler.getDirectory(repository).getAbsolutePath();
|
||||
|
||||
env.put(ENV_REPOSITORY_PATH, directory);
|
||||
env.put(ENV_REVISION, getRevision(revision));
|
||||
env.put(ENV_PATH, Util.nonNull(path));
|
||||
env.put(ENV_REPOSITORY_PATH, directory.getAbsolutePath());
|
||||
env.putAll(extraEnv);
|
||||
|
||||
return pb.start();
|
||||
}
|
||||
@@ -145,21 +140,6 @@ public class HgUtil
|
||||
return new File(cgiDirectory, CGI_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param revision
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getRevision(String revision)
|
||||
{
|
||||
return Util.isEmpty(revision)
|
||||
? REVISION_TIP
|
||||
: revision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -168,23 +148,21 @@ public class HgUtil
|
||||
* @param context
|
||||
* @param scriptResource
|
||||
* @param handler
|
||||
* @param repository
|
||||
* @param revision
|
||||
* @param path
|
||||
* @param directory
|
||||
* @param extraEnv
|
||||
* @param <T>
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static <T> T getResultFromScript(Class<T> resultType, JAXBContext context,
|
||||
String scriptResource,
|
||||
HgRepositoryHandler handler,
|
||||
Repository repository, String revision,
|
||||
String path)
|
||||
public static <T> T getResultFromScript(Class<T> resultType,
|
||||
JAXBContext context, String scriptResource,
|
||||
HgRepositoryHandler handler, File directory,
|
||||
Map<String, String> extraEnv)
|
||||
throws IOException
|
||||
{
|
||||
Process p = createPythonProcess(handler, repository, revision, path);
|
||||
Process p = createPythonProcess(handler, directory, extraEnv);
|
||||
T result = null;
|
||||
InputStream resource = null;
|
||||
InputStream input = null;
|
||||
@@ -213,4 +191,79 @@ public class HgUtil
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param resultType
|
||||
* @param context
|
||||
* @param scriptResource
|
||||
* @param handler
|
||||
* @param repository
|
||||
* @param extraEnv
|
||||
* @param <T>
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static <T> T getResultFromScript(Class<T> resultType,
|
||||
JAXBContext context, String scriptResource,
|
||||
HgRepositoryHandler handler, Repository repository,
|
||||
Map<String, String> extraEnv)
|
||||
throws IOException
|
||||
{
|
||||
File directory = handler.getDirectory(repository);
|
||||
|
||||
return getResultFromScript(resultType, context, scriptResource, handler,
|
||||
directory, extraEnv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param resultType
|
||||
* @param context
|
||||
* @param scriptResource
|
||||
* @param handler
|
||||
* @param repository
|
||||
* @param revision
|
||||
* @param path
|
||||
* @param <T>
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static <T> T getResultFromScript(Class<T> resultType,
|
||||
JAXBContext context, String scriptResource,
|
||||
HgRepositoryHandler handler, Repository repository, String revision,
|
||||
String path)
|
||||
throws IOException
|
||||
{
|
||||
Map<String, String> extraEnv = new HashMap<String, String>();
|
||||
|
||||
extraEnv.put(ENV_REVISION, getRevision(revision));
|
||||
extraEnv.put(ENV_PATH, Util.nonNull(path));
|
||||
|
||||
return getResultFromScript(resultType, context, scriptResource, handler,
|
||||
repository, extraEnv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param revision
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getRevision(String revision)
|
||||
{
|
||||
return Util.isEmpty(revision)
|
||||
? REVISION_TIP
|
||||
: revision;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user