aboutsummaryrefslogtreecommitdiffstats
path: root/src/svn.cpp
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-05-24 01:00:19 +0100
committerColin Guthrie <colin@mageia.org>2014-05-24 01:00:19 +0100
commitfb9c6dea4dd67433943a3769317b891a80817c29 (patch)
treef1a3a6253431a632b6ea5e282324987d8445fa43 /src/svn.cpp
parent539de0386876ed470f2ae6be90a98421493b3c90 (diff)
downloadsvn2git-fb9c6dea4dd67433943a3769317b891a80817c29.tar
svn2git-fb9c6dea4dd67433943a3769317b891a80817c29.tar.gz
svn2git-fb9c6dea4dd67433943a3769317b891a80817c29.tar.bz2
svn2git-fb9c6dea4dd67433943a3769317b891a80817c29.tar.xz
svn2git-fb9c6dea4dd67433943a3769317b891a80817c29.zip
Add the ability to autocreate repositories.
In Mageia, we have 13k+ packages and have very strict repo layout. Due to this we want to autocreate repositories when we import packages from subversion to git. This does not really support reloading and continuing etc. but hopefully that is sufficient for our import.
Diffstat (limited to 'src/svn.cpp')
-rw-r--r--src/svn.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/svn.cpp b/src/svn.cpp
index b2fe2a2..f63219b 100644
--- a/src/svn.cpp
+++ b/src/svn.cpp
@@ -75,7 +75,7 @@ class SvnPrivate
{
public:
QList<MatchRuleList> allMatchRules;
- RepositoryHash repositories;
+ RepositoryHash *repositories;
IdentityHash identities;
QString userdomain;
@@ -119,7 +119,7 @@ void Svn::setMatchRules(const QList<MatchRuleList> &allMatchRules)
d->allMatchRules = allMatchRules;
}
-void Svn::setRepositories(const RepositoryHash &repositories)
+void Svn::setRepositories(RepositoryHash *repositories)
{
d->repositories = repositories;
}
@@ -145,7 +145,7 @@ bool Svn::exportRevision(int revnum)
}
SvnPrivate::SvnPrivate(const QString &pathToRepository)
- : global_pool(NULL)
+ : repositories(NULL), global_pool(NULL)
{
if( openRepository(pathToRepository) != EXIT_SUCCESS) {
qCritical() << "Failed to open repository";
@@ -398,7 +398,7 @@ public:
AprAutoPool pool;
QHash<QString, Repository::Transaction *> transactions;
QList<MatchRuleList> allMatchRules;
- RepositoryHash repositories;
+ RepositoryHash *repositories;
IdentityHash identities;
QString userdomain;
@@ -415,7 +415,7 @@ public:
bool needCommit;
SvnRevision(int revision, svn_fs_t *f, apr_pool_t *parent_pool)
- : pool(parent_pool), fs(f), fs_root(0), revnum(revision), propsFetched(false)
+ : repositories(NULL), pool(parent_pool), fs(f), fs_root(0), revnum(revision), propsFetched(false)
{
ruledebug = CommandLineParser::instance()->contains( QLatin1String("debug-rules"));
}
@@ -542,7 +542,7 @@ int SvnRevision::commit()
// now create the commit
if (fetchRevProps() != EXIT_SUCCESS)
return EXIT_FAILURE;
- foreach (Repository *repo, repositories.values()) {
+ foreach (Repository *repo, repositories->values()) {
repo->commit();
}
@@ -686,12 +686,27 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *cha
QString svnprefix, repository, branch, path;
splitPathName(rule, current, &svnprefix, &repository, &branch, &path);
- Repository *repo = repositories.value(repository, 0);
+ Repository *repo = repositories->value(repository, 0);
if (!repo) {
- if (change->change_kind != svn_fs_path_change_delete)
+ if (change->change_kind != svn_fs_path_change_delete) {
+ // Attempt to auto create the repo
+ qWarning() << "Auto-creating repository" << repository << "with branch"
+ << branch << "at revision" << revnum << "due to rule match";
+
+ repo = new Repository(repository, branch, revnum);
+ if (!repo)
+ return EXIT_FAILURE;
+ repositories->insert(repository, repo);
+
+ //repo->setupIncremental(INT_MAX);
+ }
+
+ if (!repo) {
qCritical() << "Rule" << rule
<< "references unknown repository" << repository;
- return EXIT_FAILURE;
+
+ return EXIT_FAILURE;
+ }
}
printf(".");