diff options
author | Raja R Harinath <harinath@hurrynot.org> | 2010-07-10 19:23:07 +0530 |
---|---|---|
committer | Raja R Harinath <harinath@hurrynot.org> | 2010-07-10 19:23:07 +0530 |
commit | c0bc64179f96b5d2e13a905f1f6867cce3ac9558 (patch) | |
tree | ffd98cb39cd4a0541fbc2018a6cfd8144f428bd5 /src/main.cpp | |
parent | ffc5270a6fa106fecad1a6a9f1520ca8f075c6b7 (diff) | |
download | svn2git-c0bc64179f96b5d2e13a905f1f6867cce3ac9558.tar svn2git-c0bc64179f96b5d2e13a905f1f6867cce3ac9558.tar.gz svn2git-c0bc64179f96b5d2e13a905f1f6867cce3ac9558.tar.bz2 svn2git-c0bc64179f96b5d2e13a905f1f6867cce3ac9558.tar.xz svn2git-c0bc64179f96b5d2e13a905f1f6867cce3ac9558.zip |
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.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
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 <QFile> #include <QStringList> #include <QTextStream> +#include <QDebug> +#include <limits.h> #include <stdio.h> #include "CommandLineParser.h" @@ -119,18 +121,34 @@ int main(int argc, char **argv) QHash<QString, Repository *> 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; |