mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 02:55:56 +01:00
store svn uuid on repository creation
This commit is contained in:
@@ -42,8 +42,10 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
import org.tmatesoft.svn.core.internal.io.fs.FSHooks;
|
||||
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
|
||||
import org.tmatesoft.svn.core.io.SVNRepository;
|
||||
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
|
||||
|
||||
import sonia.scm.Type;
|
||||
@@ -51,6 +53,7 @@ import sonia.scm.io.FileSystem;
|
||||
import sonia.scm.plugin.ext.Extension;
|
||||
import sonia.scm.store.StoreFactory;
|
||||
import sonia.scm.util.AssertUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -67,6 +70,9 @@ public class SvnRepositoryHandler
|
||||
extends AbstractSimpleRepositoryHandler<SvnConfig>
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String PROPERTY_UUID = "svn.uuid";
|
||||
|
||||
/** Field description */
|
||||
public static final String RESOURCE_VERSION =
|
||||
"/sonia/scm/version/scm-svn-plugin";
|
||||
@@ -291,16 +297,42 @@ public class SvnRepositoryHandler
|
||||
logger.debug(log.toString());
|
||||
}
|
||||
|
||||
SVNRepository svnRepository = null;
|
||||
|
||||
try
|
||||
{
|
||||
SVNRepositoryFactory.createLocalRepository(directory, null, true, false,
|
||||
comp.isPre14Compatible(), comp.isPre15Compatible(),
|
||||
comp.isPre16Compatible());
|
||||
SVNURL url = SVNRepositoryFactory.createLocalRepository(directory, null,
|
||||
true, false, comp.isPre14Compatible(),
|
||||
comp.isPre15Compatible(), comp.isPre16Compatible());
|
||||
|
||||
svnRepository = SVNRepositoryFactory.create(url);
|
||||
|
||||
String uuid = svnRepository.getRepositoryUUID(true);
|
||||
|
||||
if (Util.isNotEmpty(uuid))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("store repository uuid {} for {}", uuid,
|
||||
repository.getName());
|
||||
}
|
||||
|
||||
repository.setProperty(PROPERTY_UUID, uuid);
|
||||
}
|
||||
else if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("could not read repository uuid for {}",
|
||||
repository.getName());
|
||||
}
|
||||
}
|
||||
catch (SVNException ex)
|
||||
{
|
||||
throw new RepositoryException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
SvnUtil.closeSession(svnRepository);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,6 +37,7 @@ package sonia.scm.repository;
|
||||
|
||||
import org.tmatesoft.svn.core.SVNLogEntry;
|
||||
import org.tmatesoft.svn.core.SVNLogEntryPath;
|
||||
import org.tmatesoft.svn.core.io.SVNRepository;
|
||||
import org.tmatesoft.svn.core.wc.admin.SVNChangeEntry;
|
||||
|
||||
import sonia.scm.util.Util;
|
||||
@@ -44,6 +45,8 @@ import sonia.scm.util.Util;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -108,6 +111,29 @@ public class SvnUtil
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*/
|
||||
public static void closeSession(SVNRepository repository)
|
||||
{
|
||||
if (repository != null)
|
||||
{
|
||||
try {
|
||||
repository.closeSession();
|
||||
} catch (Exception ex){
|
||||
logger.error("could not close svn repository session");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* the logger for SvnUtil
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(SvnUtil.class);
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user