aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp63
1 files changed, 55 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0edf8f5..f2b189e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -19,7 +19,9 @@
#include <QFile>
#include <QStringList>
#include <QTextStream>
+#include <QDebug>
+#include <limits.h>
#include <stdio.h>
#include "CommandLineParser.h"
@@ -115,18 +117,59 @@ int main(int argc, char **argv)
Rules rules(args->optionArgument(QLatin1String("rules")));
rules.load();
- int min_rev = args->optionArgument(QLatin1String("resume-from")).toInt();
+ int resume_from = args->optionArgument(QLatin1String("resume-from")).toInt();
int max_rev = args->optionArgument(QLatin1String("max-rev")).toInt();
- if (min_rev < 1)
- min_rev = 1;
// create the repository list
QHash<QString, Repository *> repositories;
+
+ int cutoff = resume_from ? resume_from : INT_MAX;
+ retry:
+ int min_rev = 1;
foreach (Rules::Repository rule, rules.repositories()) {
- Repository *repo = new Repository(rule);
+ Repository *repo = makeRepository(rule, repositories);
+ if (!repo)
+ return EXIT_FAILURE;
repositories.insert(rule.name, 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 retry;
+
+ if (min_rev < repo_next)
+ min_rev = repo_next;
+ }
+
+ if (cutoff < resume_from) {
+ qCritical() << "Cannot resume from" << resume_from
+ << "as there are errors in revision" << cutoff;
+ return EXIT_FAILURE;
}
+ if (min_rev < resume_from)
+ qDebug() << "skipping revisions" << min_rev << "to" << resume_from - 1 << "as requested";
+
+ if (resume_from)
+ min_rev = resume_from;
+
Svn::initialize();
Svn svn(args->arguments().first());
svn.setMatchRules(rules.matchRules());
@@ -135,15 +178,19 @@ int main(int argc, char **argv)
if (max_rev < 1)
max_rev = svn.youngestRevision();
- for (int i = min_rev; i <= max_rev; ++i)
- if (!svn.exportRevision(i))
+
+ bool errors = false;
+ for (int i = min_rev; i <= max_rev; ++i) {
+ if (!svn.exportRevision(i)) {
+ errors = true;
break;
+ }
+ }
foreach (Repository *repo, repositories) {
repo->finalizeTags();
delete repo;
}
- // success
- return 0;
+ return errors ? EXIT_FAILURE : EXIT_SUCCESS;
}