merge with default branch

This commit is contained in:
Sebastian Sdorra
2011-11-19 13:02:05 +01:00
320 changed files with 7673 additions and 484 deletions

View File

@@ -399,6 +399,7 @@ public class AbstractHgHandler
}
msg.append("]");
logger.debug(msg.toString());
}
ProcessBuilder pb = new ProcessBuilder(cmdList);

View File

@@ -35,7 +35,11 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.Util;
import sonia.scm.web.HgUtil;
//~--- JDK imports ------------------------------------------------------------
@@ -58,6 +62,10 @@ public class HgChangesetViewer extends AbstractHgHandler
/** Field description */
public static final String RESOURCE_LOG = "/sonia/scm/hglog.py";
/** the logger for HgChangesetViewer */
private static final Logger logger =
LoggerFactory.getLogger(HgChangesetViewer.class);
//~--- constructors ---------------------------------------------------------
/**
@@ -110,14 +118,55 @@ public class HgChangesetViewer extends AbstractHgHandler
public ChangesetPagingResult getChangesets(int start, int max)
throws IOException, RepositoryException
{
return getChangesets(String.valueOf(start), String.valueOf(max), null,
null);
if (logger.isDebugEnabled())
{
logger.debug("fetch changesets. start: {}, max: {}", start, max);
}
return getChangesets(null, null, String.valueOf(start),
String.valueOf(max), null, null);
}
/**
* Method description
*
*
* @param path
* @param revision
* @param start
* @param max
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
@Override
public ChangesetPagingResult getChangesets(String path, String revision,
int start, int max)
throws IOException, RepositoryException
{
revision = HgUtil.getRevision(revision);
if (logger.isDebugEnabled())
{
logger.debug(
"fetch changesets for path {} and revision {}. start: {}, max: {}",
new Object[] { path,
revision, start, max });
}
return getChangesets(path, revision, String.valueOf(start),
String.valueOf(max), null, null);
}
/**
* Method description
*
*
*
* @param path
* @param revision
* @param pageStart
* @param pageLimit
* @param revisionStart
@@ -128,12 +177,15 @@ public class HgChangesetViewer extends AbstractHgHandler
* @throws IOException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(String pageStart,
String pageLimit, String revisionStart, String revisionEnd)
public ChangesetPagingResult getChangesets(String path, String revision,
String pageStart, String pageLimit, String revisionStart,
String revisionEnd)
throws IOException, RepositoryException
{
Map<String, String> env = new HashMap<String, String>();
env.put(ENV_PATH, Util.nonNull(path));
env.put(ENV_REVISION, Util.nonNull(revision));
env.put(ENV_PAGE_START, Util.nonNull(pageStart));
env.put(ENV_PAGE_LIMIT, Util.nonNull(pageLimit));
env.put(ENV_REVISION_START, Util.nonNull(revisionStart));
@@ -157,6 +209,12 @@ public class HgChangesetViewer extends AbstractHgHandler
public ChangesetPagingResult getChangesets(String startNode, String endNode)
throws IOException, RepositoryException
{
return getChangesets(null, null, startNode, endNode);
if (logger.isDebugEnabled())
{
logger.debug("fetch changesets. start-node: {}, end-node: {}", startNode,
endNode);
}
return getChangesets(null, null, null, null, startNode, endNode);
}
}

View File

@@ -41,9 +41,12 @@ import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.ConfigChangedListener;
import sonia.scm.SCMContextProvider;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.io.RegexResourceProcessor;
import sonia.scm.io.ResourceProcessor;
import sonia.scm.util.HttpUtil;
import sonia.scm.util.IOUtil;
import sonia.scm.web.HgWebConfigWriter;
@@ -64,7 +67,7 @@ import javax.servlet.http.HttpServletRequest;
* @author Sebastian Sdorra
*/
@Singleton
public class HgHookManager
public class HgHookManager implements ConfigChangedListener<ScmConfiguration>
{
/** Field description */
@@ -81,15 +84,31 @@ public class HgHookManager
*
*
* @param context
* @param configuration
*/
@Inject
public HgHookManager(SCMContextProvider context)
public HgHookManager(SCMContextProvider context,
ScmConfiguration configuration)
{
this.context = context;
this.configuration = configuration;
this.configuration.addListener(this);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param config
*/
@Override
public void configChanged(ScmConfiguration config)
{
this.changed = true;
}
/**
* TODO check if file exists
*
@@ -106,10 +125,7 @@ public class HgHookManager
{
if (isScriptWriteAble())
{
StringBuilder url = new StringBuilder(request.getScheme());
url.append("://localhost:").append(request.getServerPort());
url.append(request.getContextPath()).append("/hook/hg/");
String url = createUrl(request);
if (hgHookScript == null)
{
@@ -121,10 +137,12 @@ public class HgHookManager
if (logger.isDebugEnabled())
{
logger.debug("write hg hook script to '{}'", hgHookScript);
logger.debug("write hg hook script for '{}' to '{}'", url,
hgHookScript);
}
writeScript(hgHookScript, url.toString());
changed = false;
}
}
}
@@ -158,6 +176,35 @@ public class HgHookManager
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param request
*
* @return
*/
private String createUrl(HttpServletRequest request)
{
String url = null;
if (configuration.isForceBaseUrl())
{
url = HttpUtil.getUriWithoutEndSeperator(
configuration.getBaseUrl()).concat("/hook/hg/");
}
else
{
StringBuilder sb = new StringBuilder(request.getScheme());
sb.append("://localhost:").append(request.getLocalPort());
sb.append(request.getContextPath()).append("/hook/hg/");
url = sb.toString();
}
return url;
}
/**
* Method description
*
@@ -202,14 +249,20 @@ public class HgHookManager
*/
private boolean isScriptWriteAble()
{
return (hgHookScript == null) ||!hgHookScript.exists();
return (hgHookScript == null) ||!hgHookScript.exists() || changed;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private boolean changed = false;
/** Field description */
private String challenge = UUID.randomUUID().toString();
/** Field description */
private ScmConfiguration configuration;
/** Field description */
private SCMContextProvider context;