mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
added repository property to change the encoding of a single mercurial repository
This commit is contained in:
@@ -38,7 +38,7 @@ 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 com.google.common.base.Strings;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -61,6 +61,9 @@ import java.nio.charset.Charset;
|
|||||||
public class HgCommandContext implements Closeable
|
public class HgCommandContext implements Closeable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private static final String PROPERTY_ENCODING = "hg.encoding";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the logger for HgCommandContext
|
* the logger for HgCommandContext
|
||||||
*/
|
*/
|
||||||
@@ -74,12 +77,20 @@ public class HgCommandContext implements Closeable
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param config
|
* @param config
|
||||||
|
* @param repository
|
||||||
* @param directory
|
* @param directory
|
||||||
*/
|
*/
|
||||||
public HgCommandContext(HgConfig config, File directory)
|
HgCommandContext(HgConfig config, sonia.scm.repository.Repository repository,
|
||||||
|
File directory)
|
||||||
{
|
{
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
|
encoding = repository.getProperty(PROPERTY_ENCODING);
|
||||||
|
|
||||||
|
if (Strings.isNullOrEmpty(encoding))
|
||||||
|
{
|
||||||
|
encoding = config.getEncoding();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
@@ -145,6 +156,9 @@ public class HgCommandContext implements Closeable
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
private File directory;
|
private File directory;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private String encoding;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private Repository repository;
|
private Repository repository;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
|||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
this.repositoryDirectory = handler.getDirectory(repository);
|
this.repositoryDirectory = handler.getDirectory(repository);
|
||||||
this.context = new HgCommandContext(handler.getConfig(),
|
this.context = new HgCommandContext(handler.getConfig(), repository,
|
||||||
repositoryDirectory);
|
repositoryDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ import sonia.scm.io.FileSystem;
|
|||||||
import sonia.scm.repository.HgContextProvider;
|
import sonia.scm.repository.HgContextProvider;
|
||||||
import sonia.scm.repository.HgRepositoryHandler;
|
import sonia.scm.repository.HgRepositoryHandler;
|
||||||
import sonia.scm.repository.HgTestUtil;
|
import sonia.scm.repository.HgTestUtil;
|
||||||
|
import sonia.scm.repository.Repository;
|
||||||
|
import sonia.scm.repository.RepositoryTestData;
|
||||||
import sonia.scm.repository.TempSCMContextProvider;
|
import sonia.scm.repository.TempSCMContextProvider;
|
||||||
import sonia.scm.store.MemoryStoreFactory;
|
import sonia.scm.store.MemoryStoreFactory;
|
||||||
|
|
||||||
@@ -99,7 +101,8 @@ public class AbstractHgCommandTestBase extends ZippedRepositoryTestBase
|
|||||||
|
|
||||||
HgTestUtil.checkForSkip(handler);
|
HgTestUtil.checkForSkip(handler);
|
||||||
|
|
||||||
cmdContext = new HgCommandContext(handler.getConfig(), repositoryDirectory);
|
cmdContext = new HgCommandContext(handler.getConfig(),
|
||||||
|
RepositoryTestData.createHeartOfGold(), repositoryDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user