mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
register pretxnchangegroup hooks for existing mercurial repositories
This commit is contained in:
@@ -78,7 +78,7 @@ public class HgRepositoryHandler
|
|||||||
{
|
{
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String PATH_HOOK1_6 = ".hook-1.6";
|
public static final String PATH_HOOK = ".hook-1.8";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String TYPE_DISPLAYNAME = "Mercurial";
|
public static final String TYPE_DISPLAYNAME = "Mercurial";
|
||||||
@@ -352,7 +352,6 @@ public class HgRepositoryHandler
|
|||||||
webSection.setParameter("allow_push", "*");
|
webSection.setParameter("allow_push", "*");
|
||||||
hgrc.addSection(webSection);
|
hgrc.addSection(webSection);
|
||||||
|
|
||||||
|
|
||||||
// register hooks
|
// register hooks
|
||||||
INISection hooksSection = new INISection("hooks");
|
INISection hooksSection = new INISection("hooks");
|
||||||
|
|
||||||
@@ -382,6 +381,36 @@ public class HgRepositoryHandler
|
|||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repositoryName
|
||||||
|
* @param hooks
|
||||||
|
* @param hookName
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean appendHook(String repositoryName, INISection hooks,
|
||||||
|
String hookName)
|
||||||
|
{
|
||||||
|
boolean write = false;
|
||||||
|
String hook = hooks.getParameter(hookName);
|
||||||
|
|
||||||
|
if (Util.isEmpty(hook))
|
||||||
|
{
|
||||||
|
if (logger.isInfoEnabled())
|
||||||
|
{
|
||||||
|
logger.info("register missing {} hook for respository {}", hookName,
|
||||||
|
repositoryName);
|
||||||
|
}
|
||||||
|
|
||||||
|
hooks.setParameter(hookName, "python:scmhooks.callback");
|
||||||
|
}
|
||||||
|
|
||||||
|
return write;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -430,18 +459,21 @@ public class HgRepositoryHandler
|
|||||||
c.addSection(hooks);
|
c.addSection(hooks);
|
||||||
}
|
}
|
||||||
|
|
||||||
String hook = hooks.getParameter("changegroup.scm");
|
String repositoryName = repositoryDir.getName();
|
||||||
|
boolean write = false;
|
||||||
|
|
||||||
if (Util.isEmpty(hook))
|
if (appendHook(repositoryName, hooks, "changegroup.scm"))
|
||||||
{
|
{
|
||||||
if (logger.isInfoEnabled())
|
write = true;
|
||||||
{
|
}
|
||||||
logger.info("register missing hg hook for respository {}",
|
|
||||||
repositoryDir.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
hooks.setParameter("changegroup.scm", "python:scmhooks.callback");
|
if (appendHook(repositoryName, hooks, "pretxnchangegroup.scm"))
|
||||||
|
{
|
||||||
|
write = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (write)
|
||||||
|
{
|
||||||
INIConfigurationWriter writer = new INIConfigurationWriter();
|
INIConfigurationWriter writer = new INIConfigurationWriter();
|
||||||
|
|
||||||
writer.write(c, hgrc);
|
writer.write(c, hgrc);
|
||||||
@@ -472,7 +504,7 @@ public class HgRepositoryHandler
|
|||||||
|
|
||||||
if (repositoryDirectroy.exists())
|
if (repositoryDirectroy.exists())
|
||||||
{
|
{
|
||||||
File lockFile = new File(repositoryDirectroy, PATH_HOOK1_6);
|
File lockFile = new File(repositoryDirectroy, PATH_HOOK);
|
||||||
|
|
||||||
if (!lockFile.exists())
|
if (!lockFile.exists())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user