mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
allow configuration of mercurial repository encoding
This commit is contained in:
@@ -57,6 +57,17 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getEncoding()
|
||||
{
|
||||
return encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -111,11 +122,22 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
public boolean isValid()
|
||||
{
|
||||
return super.isValid() && Util.isNotEmpty(hgBinary)
|
||||
&& Util.isNotEmpty(pythonBinary);
|
||||
&& Util.isNotEmpty(pythonBinary);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param encoding
|
||||
*/
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -162,6 +184,9 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String encoding = "UTF-8";
|
||||
|
||||
/** Field description */
|
||||
private String hgBinary;
|
||||
|
||||
|
||||
@@ -38,6 +38,11 @@ package sonia.scm.repository.spi;
|
||||
import com.aragost.javahg.Repository;
|
||||
import com.aragost.javahg.RepositoryConfiguration;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.HgConfig;
|
||||
import sonia.scm.repository.spi.javahg.HgFileviewExtension;
|
||||
|
||||
@@ -47,6 +52,8 @@ import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -54,6 +61,14 @@ import java.io.IOException;
|
||||
public class HgCommandContext implements Closeable
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for HgCommandContext
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(HgCommandContext.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
@@ -99,6 +114,22 @@ public class HgCommandContext implements Closeable
|
||||
|
||||
repoConfiguration.addExtension(HgFileviewExtension.class);
|
||||
|
||||
try
|
||||
{
|
||||
Charset charset = Charset.forName(config.getEncoding());
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("set encoding {} for mercurial", config.getEncoding());
|
||||
}
|
||||
|
||||
repoConfiguration.setEncoding(charset);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
logger.error("could not set encoding for mercurial", ex);
|
||||
}
|
||||
|
||||
repoConfiguration.setHgBin(config.getHgBinary());
|
||||
repository = Repository.open(repoConfiguration, directory);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user