aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-06-16 21:55:45 +0100
committerColin Guthrie <colin@mageia.org>2014-06-16 21:55:45 +0100
commit537bb357f89cf534acb7a656abd6b32130bb5349 (patch)
treebfdf231aa1047ac15200c4820180db95d784c6b0
parenta8f714b1d6a99b454ae674ac6f0e72d329456f7b (diff)
downloadsvn2git-537bb357f89cf534acb7a656abd6b32130bb5349.tar
svn2git-537bb357f89cf534acb7a656abd6b32130bb5349.tar.gz
svn2git-537bb357f89cf534acb7a656abd6b32130bb5349.tar.bz2
svn2git-537bb357f89cf534acb7a656abd6b32130bb5349.tar.xz
svn2git-537bb357f89cf534acb7a656abd6b32130bb5349.zip
main: Load repository logs from the directories found
-rw-r--r--README.md2
-rw-r--r--src/main.cpp55
2 files changed, 56 insertions, 1 deletions
diff --git a/README.md b/README.md
index 39e8167..364bbed 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ Question: Handling renames (what do to generally as updates to old branches... s
## TODO
-1. Read repository information from files on startup (to reinitialise repos)
+1. ~~Read repository information from files on startup (to reinitialise repos)~~
2. Implement upper limit on fastimport processes that run concurrently (we'll need lots of them so this might get overwhelming!)
3. Track repo renames better to allow for cauldron renames but mgaN-1 updates (also maintain state on disk and read on startup)
4. Handle resurrections/renames from non rev-1 revisions (i.e. a simple, atomic svn mv works fine, but an svn cp -r xxxx to resurrect and old package (or restore from obsolete) will not work... restoring from obsolete is tricky as we may need to migrate changes fully in the commit (undoing changes that were made after the revision we want to restore))
diff --git a/src/main.cpp b/src/main.cpp
index e917549..296584c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -17,6 +17,7 @@
#include <QCoreApplication>
#include <QFile>
+#include <QDir>
#include <QStringList>
#include <QTextStream>
#include <QDebug>
@@ -231,6 +232,60 @@ int main(int argc, char **argv)
min_rev = repo_next;
}
+
+ if (!rulesList.allRepositories().count()) {
+
+ qDebug() << "No repositories defined, assuming dynamic repository creation and looking for repo folders";
+
+ retry2:
+ min_rev = 1;
+
+ QDir dir;
+ dir.setFilter(QDir::Dirs | QDir::NoSymLinks | QDir::NoDot | QDir::NoDotDot);
+
+ QStringList list = dir.entryList();
+ for (int i = 0; i < list.size(); ++i) {
+ QString reponame = list.at(i);
+ if (!QFile::exists(reponame + "/marks-" + reponame))
+ continue;
+
+ //qDebug() << "Found repo" << reponame;
+
+ // The 0 revision will be configured appropriatly via setupIncremental()...
+ Repository *repo = new Repository(reponame, "master", 0);
+ if (!repo)
+ return EXIT_FAILURE;
+ repositories.insert(reponame, repo);
+
+ int repo_next = repo->setupIncremental(cutoff);
+
+ /*
+ * cutoff < resume_from => error exit eventually
+ * repo_next == cutoff => probably truncated log
+ */
+ if (cutoff < resume_from && repo_next == cutoff)
+ /*
+ * Restore the log file so we fail the next time
+ * svn2git is invoked with the same arguments
+ */
+ repo->restoreLog();
+
+ if (cutoff < min_rev)
+ /*
+ * We've rewound before the last revision of some
+ * repository that we've already seen. Start over
+ * from the beginning. (since cutoff is decreasing,
+ * we're sure we'll make forward progress eventually)
+ */
+ goto retry2;
+
+ if (min_rev < repo_next)
+ min_rev = repo_next;
+ }
+ }
+
+ qDebug() << "Loaded" << repositories.count() << "repositories; resuming from revision" << min_rev;
+
if (cutoff < resume_from) {
qCritical() << "Cannot resume from" << resume_from
<< "as there are errors in revision" << cutoff;