mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
fix wrong mercurial changeset ids during hooks
This commit is contained in:
@@ -68,6 +68,9 @@ import javax.xml.bind.JAXBException;
|
|||||||
public class AbstractHgHandler
|
public class AbstractHgHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
protected static final String ENV_ID_REVISION = "SCM_ID_REVISION";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
protected static final String ENV_NODE = "HG_NODE";
|
protected static final String ENV_NODE = "HG_NODE";
|
||||||
|
|
||||||
@@ -126,7 +129,7 @@ public class AbstractHgHandler
|
|||||||
* @param repositoryDirectory
|
* @param repositoryDirectory
|
||||||
*/
|
*/
|
||||||
protected AbstractHgHandler(HgRepositoryHandler handler, HgContext context,
|
protected AbstractHgHandler(HgRepositoryHandler handler, HgContext context,
|
||||||
Repository repository)
|
Repository repository)
|
||||||
{
|
{
|
||||||
this(handler, context, repository, handler.getDirectory(repository));
|
this(handler, context, repository, handler.getDirectory(repository));
|
||||||
}
|
}
|
||||||
@@ -142,7 +145,7 @@ public class AbstractHgHandler
|
|||||||
* @param repositoryDirectory
|
* @param repositoryDirectory
|
||||||
*/
|
*/
|
||||||
protected AbstractHgHandler(HgRepositoryHandler handler, HgContext context,
|
protected AbstractHgHandler(HgRepositoryHandler handler, HgContext context,
|
||||||
Repository repository, File repositoryDirectory)
|
Repository repository, File repositoryDirectory)
|
||||||
{
|
{
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@@ -198,8 +201,8 @@ public class AbstractHgHandler
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected Process createHgProcess(Map<String, String> extraEnv,
|
protected Process createHgProcess(Map<String, String> extraEnv,
|
||||||
String... args)
|
String... args)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
return createProcess(extraEnv, handler.getConfig().getHgBinary(), args);
|
return createProcess(extraEnv, handler.getConfig().getHgBinary(), args);
|
||||||
}
|
}
|
||||||
@@ -216,12 +219,11 @@ public class AbstractHgHandler
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected Process createScriptProcess(HgPythonScript script,
|
protected Process createScriptProcess(HgPythonScript script,
|
||||||
Map<String, String> extraEnv)
|
Map<String, String> extraEnv)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
return createProcess(
|
return createProcess(extraEnv, handler.getConfig().getPythonBinary(),
|
||||||
extraEnv, handler.getConfig().getPythonBinary(),
|
script.getFile(SCMContext.getContext()).getAbsolutePath());
|
||||||
script.getFile(SCMContext.getContext()).getAbsolutePath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,11 +275,11 @@ public class AbstractHgHandler
|
|||||||
* @throws RepositoryException
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
protected <T> T getResultFromScript(Class<T> resultType,
|
protected <T> T getResultFromScript(Class<T> resultType,
|
||||||
HgPythonScript script)
|
HgPythonScript script)
|
||||||
throws IOException, RepositoryException
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
return getResultFromScript(resultType, script,
|
return getResultFromScript(resultType, script,
|
||||||
new HashMap<String, String>());
|
new HashMap<String, String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -295,8 +297,8 @@ public class AbstractHgHandler
|
|||||||
* @throws RepositoryException
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
protected <T> T getResultFromScript(Class<T> resultType,
|
protected <T> T getResultFromScript(Class<T> resultType,
|
||||||
HgPythonScript script, Map<String, String> extraEnv)
|
HgPythonScript script, Map<String, String> extraEnv)
|
||||||
throws IOException, RepositoryException
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
Process p = createScriptProcess(script, extraEnv);
|
Process p = createScriptProcess(script, extraEnv);
|
||||||
T result = null;
|
T result = null;
|
||||||
@@ -341,8 +343,8 @@ public class AbstractHgHandler
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private Process createProcess(Map<String, String> extraEnv, String cmd,
|
private Process createProcess(Map<String, String> extraEnv, String cmd,
|
||||||
String... args)
|
String... args)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
HgConfig config = handler.getConfig();
|
HgConfig config = handler.getConfig();
|
||||||
List<String> cmdList = new ArrayList<String>();
|
List<String> cmdList = new ArrayList<String>();
|
||||||
@@ -383,6 +385,12 @@ public class AbstractHgHandler
|
|||||||
env.put(ENV_PYTHONIOENCODING, ENCODING);
|
env.put(ENV_PYTHONIOENCODING, ENCODING);
|
||||||
env.put(ENV_HGENCODING, ENCODING);
|
env.put(ENV_HGENCODING, ENCODING);
|
||||||
|
|
||||||
|
//J-
|
||||||
|
env.put(ENV_ID_REVISION,
|
||||||
|
String.valueOf(handler.getConfig().isShowRevisionInId())
|
||||||
|
);
|
||||||
|
//J+
|
||||||
|
|
||||||
if (context.isSystemEnvironment())
|
if (context.isSystemEnvironment())
|
||||||
{
|
{
|
||||||
env.putAll(System.getenv());
|
env.putAll(System.getenv());
|
||||||
@@ -393,7 +401,7 @@ public class AbstractHgHandler
|
|||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("enable hg pending for {}",
|
logger.debug("enable hg pending for {}",
|
||||||
repositoryDirectory.getAbsolutePath());
|
repositoryDirectory.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
env.put(ENV_PENDING, repositoryDirectory.getAbsolutePath());
|
env.put(ENV_PENDING, repositoryDirectory.getAbsolutePath());
|
||||||
@@ -413,7 +421,7 @@ public class AbstractHgHandler
|
|||||||
StringBuilder msg = new StringBuilder("start process in directory '");
|
StringBuilder msg = new StringBuilder("start process in directory '");
|
||||||
|
|
||||||
msg.append(repositoryDirectory.getAbsolutePath()).append(
|
msg.append(repositoryDirectory.getAbsolutePath()).append(
|
||||||
"' with env: \n");
|
"' with env: \n");
|
||||||
|
|
||||||
for (Map.Entry<String, String> e : env.entrySet())
|
for (Map.Entry<String, String> e : env.entrySet())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,7 +75,10 @@ def appendWrappedListNodes(doc, parentNode, wrapperName, name, values):
|
|||||||
appendListNodes(doc, wrapperNode, name, values)
|
appendListNodes(doc, wrapperNode, name, values)
|
||||||
|
|
||||||
def getId(ctx):
|
def getId(ctx):
|
||||||
return str(ctx.rev()) + ':' + hex(ctx.node()[:6])
|
id = ''
|
||||||
|
if os.environ['SCM_ID_REVISION'] == 'true':
|
||||||
|
id = str(ctx.rev()) + ':'
|
||||||
|
return id + hex(ctx.node())
|
||||||
|
|
||||||
def appendAuthorNodes(doc, parentNode, ctx):
|
def appendAuthorNodes(doc, parentNode, ctx):
|
||||||
authorName = ctx.user()
|
authorName = ctx.user()
|
||||||
|
|||||||
Reference in New Issue
Block a user