modify metadata.xml only if needed

introduce a defaultRepositoryDirectory in the XmlRepositoryDatabase
Bugfix: modify repository with changed location
This commit is contained in:
Mohamed Karray
2018-11-21 12:01:13 +01:00
parent 01f45aaf8c
commit bb1c84ba24
14 changed files with 128 additions and 124 deletions

View File

@@ -66,7 +66,6 @@ public class HgRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
private com.google.inject.Provider<HgContext> provider;
RepositoryLocationResolver repositoryLocationResolver ;
private Path repoDir;
@Override
protected void checkDirectory(File directory) {
@@ -84,17 +83,14 @@ public class HgRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
@Override
protected RepositoryHandler createRepositoryHandler(ConfigurationStoreFactory factory,
File directory) throws RepositoryPathNotFoundException {
File directory) {
DefaultFileSystem fileSystem = new DefaultFileSystem();
PathBasedRepositoryDAO repoDao = mock(PathBasedRepositoryDAO.class);
repositoryLocationResolver = new RepositoryLocationResolver(repoDao, new InitialRepositoryLocationResolver(contextProvider,fileSystem));
HgRepositoryHandler handler = new HgRepositoryHandler(factory,
new DefaultFileSystem(),
new HgContextProvider(), repositoryLocationResolver);
handler.init(contextProvider);
repoDir = directory.toPath();
when(repoDao.getPath(any())).thenReturn(repoDir);
HgTestUtil.checkForSkip(handler);
return handler;
@@ -110,8 +106,8 @@ public class HgRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
hgConfig.setPythonBinary("python");
repositoryHandler.setConfig(hgConfig);
Repository repository = new Repository("id", "git", "Space", "Name");
initRepository();
File path = repositoryHandler.getDirectory(repository);
assertEquals(repoDir.toString()+File.separator+InitialRepositoryLocationResolver.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
assertEquals(repoPath.toString()+File.separator+InitialRepositoryLocationResolver.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
}
}

View File

@@ -96,7 +96,7 @@ public final class HgTestUtil
*
* @return
*/
public static HgRepositoryHandler createHandler(File directory) throws RepositoryPathNotFoundException {
public static HgRepositoryHandler createHandler(File directory) {
TempSCMContextProvider context =
(TempSCMContextProvider) SCMContext.getContext();