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 ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getEncoding()
|
||||||
|
{
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -111,11 +122,22 @@ public class HgConfig extends SimpleRepositoryConfig
|
|||||||
public boolean isValid()
|
public boolean isValid()
|
||||||
{
|
{
|
||||||
return super.isValid() && Util.isNotEmpty(hgBinary)
|
return super.isValid() && Util.isNotEmpty(hgBinary)
|
||||||
&& Util.isNotEmpty(pythonBinary);
|
&& Util.isNotEmpty(pythonBinary);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- set methods ----------------------------------------------------------
|
//~--- set methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param encoding
|
||||||
|
*/
|
||||||
|
public void setEncoding(String encoding)
|
||||||
|
{
|
||||||
|
this.encoding = encoding;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -162,6 +184,9 @@ public class HgConfig extends SimpleRepositoryConfig
|
|||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private String encoding = "UTF-8";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private String hgBinary;
|
private String hgBinary;
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ package sonia.scm.repository.spi;
|
|||||||
import com.aragost.javahg.Repository;
|
import com.aragost.javahg.Repository;
|
||||||
import com.aragost.javahg.RepositoryConfiguration;
|
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.HgConfig;
|
||||||
import sonia.scm.repository.spi.javahg.HgFileviewExtension;
|
import sonia.scm.repository.spi.javahg.HgFileviewExtension;
|
||||||
|
|
||||||
@@ -47,6 +52,8 @@ import java.io.Closeable;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
@@ -54,6 +61,14 @@ import java.io.IOException;
|
|||||||
public class HgCommandContext implements Closeable
|
public class HgCommandContext implements Closeable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the logger for HgCommandContext
|
||||||
|
*/
|
||||||
|
private static final Logger logger =
|
||||||
|
LoggerFactory.getLogger(HgCommandContext.class);
|
||||||
|
|
||||||
|
//~--- constructors ---------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs ...
|
* Constructs ...
|
||||||
*
|
*
|
||||||
@@ -99,6 +114,22 @@ public class HgCommandContext implements Closeable
|
|||||||
|
|
||||||
repoConfiguration.addExtension(HgFileviewExtension.class);
|
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());
|
repoConfiguration.setHgBin(config.getHgBinary());
|
||||||
repository = Repository.open(repoConfiguration, directory);
|
repository = Repository.open(repoConfiguration, directory);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
|
|||||||
useOptimizedBytecodeText: 'Optimized Bytecode (.pyo)',
|
useOptimizedBytecodeText: 'Optimized Bytecode (.pyo)',
|
||||||
configWizardText: 'Start Configuration Wizard',
|
configWizardText: 'Start Configuration Wizard',
|
||||||
configWizardLabelText: 'Start Configuration Wizard',
|
configWizardLabelText: 'Start Configuration Wizard',
|
||||||
|
encodingText: 'Encoding',
|
||||||
disabledText: 'Disabled',
|
disabledText: 'Disabled',
|
||||||
|
|
||||||
// helpText
|
// helpText
|
||||||
@@ -51,6 +52,7 @@ Sonia.hg.ConfigPanel = Ext.extend(Sonia.config.ConfigForm, {
|
|||||||
pythonPathHelpText: 'Python Module Search Path (PYTHONPATH).',
|
pythonPathHelpText: 'Python Module Search Path (PYTHONPATH).',
|
||||||
repositoryDirectoryHelpText: 'Location of the Mercurial repositories.',
|
repositoryDirectoryHelpText: 'Location of the Mercurial repositories.',
|
||||||
useOptimizedBytecodeHelpText: 'Use the Python "-O" switch.',
|
useOptimizedBytecodeHelpText: 'Use the Python "-O" switch.',
|
||||||
|
encodingHelpText: 'Repository Encoding.',
|
||||||
disabledHelpText: 'Enable or disable the Mercurial plugin. \n\
|
disabledHelpText: 'Enable or disable the Mercurial plugin. \n\
|
||||||
Note you have to reload the page, after changing this value.',
|
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,
|
fieldLabel: this.repositoryDirectoryText,
|
||||||
helpText: this.repositoryDirectoryHelpText,
|
helpText: this.repositoryDirectoryHelpText,
|
||||||
allowBlank : false
|
allowBlank : false
|
||||||
|
},{
|
||||||
|
xtype: 'textfield',
|
||||||
|
name: 'encoding',
|
||||||
|
fieldLabel: this.encodingText,
|
||||||
|
helpText: this.encodingHelpText,
|
||||||
|
allowBlank : false
|
||||||
},{
|
},{
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'useOptimizedBytecode',
|
name: 'useOptimizedBytecode',
|
||||||
|
|||||||
Reference in New Issue
Block a user