mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +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
|
||||
*
|
||||
@@ -116,6 +127,17 @@ public class HgConfig extends SimpleRepositoryConfig
|
||||
|
||||
//~--- 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);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
|
||||
useOptimizedBytecodeText: 'Optimized Bytecode (.pyo)',
|
||||
configWizardText: 'Start Configuration Wizard',
|
||||
configWizardLabelText: 'Start Configuration Wizard',
|
||||
encodingText: 'Encoding',
|
||||
disabledText: 'Disabled',
|
||||
|
||||
// helpText
|
||||
@@ -51,6 +52,7 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
|
||||
pythonPathHelpText: 'Python Module Search Path (PYTHONPATH).',
|
||||
repositoryDirectoryHelpText: 'Location of the Mercurial repositories.',
|
||||
useOptimizedBytecodeHelpText: 'Use the Python "-O" switch.',
|
||||
encodingHelpText: 'Repository Encoding.',
|
||||
disabledHelpText: 'Enable or disable the Mercurial plugin. \n\
|
||||
Note you have to reload the page, after changing this value.',
|
||||
|
||||
@@ -81,6 +83,12 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
|
||||
fieldLabel: this.repositoryDirectoryText,
|
||||
helpText: this.repositoryDirectoryHelpText,
|
||||
allowBlank : false
|
||||
},{
|
||||
xtype: 'textfield',
|
||||
name: 'encoding',
|
||||
fieldLabel: this.encodingText,
|
||||
helpText: this.encodingHelpText,
|
||||
allowBlank : false
|
||||
},{
|
||||
xtype: 'checkbox',
|
||||
name: 'useOptimizedBytecode',
|
||||
|
||||
Reference in New Issue
Block a user