mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
fix bugs in mercurial repositoryhandler
This commit is contained in:
@@ -27,6 +27,7 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -85,6 +86,8 @@ public class HgRepositoryHandler implements RepositoryHandler
|
|||||||
public void create(Repository repository)
|
public void create(Repository repository)
|
||||||
throws RepositoryException, IOException
|
throws RepositoryException, IOException
|
||||||
{
|
{
|
||||||
|
repository.setId(UUID.randomUUID().toString());
|
||||||
|
|
||||||
File directory = getDirectory(repository);
|
File directory = getDirectory(repository);
|
||||||
|
|
||||||
if (directory.exists())
|
if (directory.exists())
|
||||||
@@ -216,17 +219,17 @@ public class HgRepositoryHandler implements RepositoryHandler
|
|||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param name
|
* @param id
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Repository get(String name)
|
public Repository get(String id)
|
||||||
{
|
{
|
||||||
Repository repository = null;
|
Repository repository = null;
|
||||||
File directory = getDirectory(name);
|
File[] directories = config.getRepositoryDirectory().listFiles();
|
||||||
|
|
||||||
if (directory.exists() && directory.isDirectory())
|
for (File directory : directories)
|
||||||
{
|
{
|
||||||
File hgDirectory = new File(directory, ".hg");
|
File hgDirectory = new File(directory, ".hg");
|
||||||
|
|
||||||
@@ -234,8 +237,17 @@ public class HgRepositoryHandler implements RepositoryHandler
|
|||||||
{
|
{
|
||||||
repository = new Repository();
|
repository = new Repository();
|
||||||
repository.setType(TYPE_NAME);
|
repository.setType(TYPE_NAME);
|
||||||
repository.setName(name);
|
repository.setName(directory.getName());
|
||||||
readHgrc(repository, hgDirectory);
|
readHgrc(repository, hgDirectory);
|
||||||
|
|
||||||
|
if (!id.equals(repository.getId()))
|
||||||
|
{
|
||||||
|
repository = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +270,7 @@ public class HgRepositoryHandler implements RepositoryHandler
|
|||||||
{
|
{
|
||||||
for (String repositoryName : repositoryNames)
|
for (String repositoryName : repositoryNames)
|
||||||
{
|
{
|
||||||
Repository repository = get(repositoryName);
|
Repository repository = buildRepository(repositoryName);
|
||||||
|
|
||||||
if (repository != null)
|
if (repository != null)
|
||||||
{
|
{
|
||||||
@@ -312,6 +324,35 @@ public class HgRepositoryHandler implements RepositoryHandler
|
|||||||
section.setParameter("allow_push", builder.getWritePermission());
|
section.setParameter("allow_push", builder.getWritePermission());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Repository buildRepository(String name)
|
||||||
|
{
|
||||||
|
Repository repository = null;
|
||||||
|
File directory = getDirectory(name);
|
||||||
|
|
||||||
|
if (directory.exists() && directory.isDirectory())
|
||||||
|
{
|
||||||
|
File hgDirectory = new File(directory, ".hg");
|
||||||
|
|
||||||
|
if (hgDirectory.exists() && hgDirectory.isDirectory())
|
||||||
|
{
|
||||||
|
repository = new Repository();
|
||||||
|
repository.setType(TYPE_NAME);
|
||||||
|
repository.setName(name);
|
||||||
|
readHgrc(repository, hgDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -412,7 +453,7 @@ public class HgRepositoryHandler implements RepositoryHandler
|
|||||||
|
|
||||||
INISection scmSection = new INISection("scm");
|
INISection scmSection = new INISection("scm");
|
||||||
|
|
||||||
section.setParameter("id", repository.getId());
|
scmSection.setParameter("id", repository.getId());
|
||||||
|
|
||||||
INIConfiguration iniConfig = new INIConfiguration();
|
INIConfiguration iniConfig = new INIConfiguration();
|
||||||
|
|
||||||
@@ -431,13 +472,13 @@ public class HgRepositoryHandler implements RepositoryHandler
|
|||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param name
|
* @param id
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private File getDirectory(String name)
|
private File getDirectory(String id)
|
||||||
{
|
{
|
||||||
return new File(config.getRepositoryDirectory(), name);
|
return new File(config.getRepositoryDirectory(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -450,7 +491,7 @@ public class HgRepositoryHandler implements RepositoryHandler
|
|||||||
*/
|
*/
|
||||||
private File getDirectory(Repository repository)
|
private File getDirectory(Repository repository)
|
||||||
{
|
{
|
||||||
return getDirectory(repository.getName());
|
return new File(config.getRepositoryDirectory(), repository.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user