From c0bc64179f96b5d2e13a905f1f6867cce3ac9558 Mon Sep 17 00:00:00 2001 From: Raja R Harinath Date: Sat, 10 Jul 2010 19:23:07 +0530 Subject: make --incremental robust to inconsistent import directories An interrupted import (say with Ctrl-C) can leave the import directory in an inconsistent state. This can be due to checkpointing fast-import only occassionally, but updating log-* files immediately, and/or other reasons. The incremental mode can detect certain such situations and rewind back to a safe state. Note that since the default commit-interval is quite large, this rewind can end up backtracking a lot. Note also that import interrupted under the control of svn2git, say, for missing rules should leave the import directory in a consistent state for the purpose of svn2git. --- src/main.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index da39a5b..5d0a1fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,9 @@ #include #include #include +#include +#include #include #include "CommandLineParser.h" @@ -119,18 +121,34 @@ int main(int argc, char **argv) QHash repositories; bool incremental = args->contains("incremental"); - int min_rev = resume_from; + int cutoff = resume_from ? resume_from : INT_MAX; + retry: + int min_rev = 0; foreach (Rules::Repository rule, rules.repositories()) { Repository *repo = new Repository(rule); repositories.insert(rule.name, repo); if (incremental) { - int repo_next = repo->setupIncremental(resume_from); + int repo_next = repo->setupIncremental(cutoff); + if (cutoff < min_rev) { + qWarning() << "rewinding; did you hit Ctrl-C?"; + 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 (min_rev < 1) min_rev = 1; -- cgit v1.2.1