From fb9c6dea4dd67433943a3769317b891a80817c29 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sat, 24 May 2014 01:00:19 +0100 Subject: 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. --- src/svn.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'src/svn.cpp') 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 allMatchRules; - RepositoryHash repositories; + RepositoryHash *repositories; IdentityHash identities; QString userdomain; @@ -119,7 +119,7 @@ void Svn::setMatchRules(const QList &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 transactions; QList 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("."); -- cgit v1.2.1