aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorRaja R Harinath <harinath@hurrynot.org>2010-07-11 19:08:53 +0530
committerRaja R Harinath <harinath@hurrynot.org>2010-07-11 21:01:22 +0530
commit2a7a37ff0f62f5dc06acf95d8084cd0521d6a651 (patch)
treed81e5473c68ec6945574a240d0f2ca7d0d168a43 /src/main.cpp
parentc0bc64179f96b5d2e13a905f1f6867cce3ac9558 (diff)
downloadsvn2git-2a7a37ff0f62f5dc06acf95d8084cd0521d6a651.tar
svn2git-2a7a37ff0f62f5dc06acf95d8084cd0521d6a651.tar.gz
svn2git-2a7a37ff0f62f5dc06acf95d8084cd0521d6a651.tar.bz2
svn2git-2a7a37ff0f62f5dc06acf95d8084cd0521d6a651.tar.xz
svn2git-2a7a37ff0f62f5dc06acf95d8084cd0521d6a651.zip
Make error handling of --incremental and --resume-from idempotent
When --resume-from failed in incremental mode, the log files that detected the error condition were truncated. So, if the same command line was executed again, the invocation would go through. We now restore the log files from backup when we detect we're going to fail. The restored log files may not all be the same as we originally started with, but we only truncate information that would anyway be truncated on the next successful run.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 5d0a1fc..37b8615 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -123,34 +123,50 @@ int main(int argc, char **argv)
int cutoff = resume_from ? resume_from : INT_MAX;
retry:
- int min_rev = 0;
+ int min_rev = 1;
foreach (Rules::Repository rule, rules.repositories()) {
Repository *repo = new Repository(rule);
repositories.insert(rule.name, repo);
if (incremental) {
int repo_next = repo->setupIncremental(cutoff);
- if (cutoff < min_rev) {
- qWarning() << "rewinding; did you hit Ctrl-C?";
+
+ /*
+ * 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 (incremental && resume_from) {
- 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";
- min_rev = resume_from;
+ if (cutoff < resume_from) {
+ qCritical() << "Cannot resume from" << resume_from
+ << "as there are errors in revision" << cutoff;
+ return EXIT_FAILURE;
}
- if (min_rev < 1)
- min_rev = 1;
+ 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());