Skip to content

Commit 496fd52

Browse files
Ditti4tnyblom
authored andcommitted
Make git fast-import timeout configurable (#39)
Very large SVN repositories, especially those which include binary files, tend to result in very large git pack files (tens of gigabytes). With its current approach, svn2git will wait 30 seconds (the default timeout of waitForFinished()) for git fast-import to finish before it terminates the git process. That default timeout is way too small for large pack files for which the import process can take several minutes. To work around this very long processing time, this commit adds the new command line option "--fast-import-timeout". It allows the user to set a custom timeout in seconds to wait for git fast-import to finish, with a timeout of 0 meaning that svn2git will wait forever. This way even large SVN repositories can be imported successfully.
1 parent f00d5a5 commit 496fd52

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ static const CommandLineOption options[] = {
144144
{"--empty-dirs", "Add .gitignore-file for empty dirs"},
145145
{"--svn-ignore", "Import svn-ignore-properties via .gitignore"},
146146
{"--propcheck", "Check for svn-properties except svn-ignore"},
147+
{"--fast-import-timeout SECONDS", "number of seconds to wait before terminating fast-import, 0 to wait forever"},
147148
{"-h, --help", "show help"},
148149
{"-v, --version", "show version"},
149150
CommandLineLastOption

src/repository.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,18 @@ FastImportRepository::~FastImportRepository()
468468
void FastImportRepository::closeFastImport()
469469
{
470470
if (fastImport.state() != QProcess::NotRunning) {
471+
int fastImportTimeout = CommandLineParser::instance()->optionArgument(QLatin1String("fast-import-timeout"), QLatin1String("30")).toInt();
472+
if(fastImportTimeout == 0) {
473+
qDebug() << "Waiting forever for fast-import to finish.";
474+
fastImportTimeout = -1;
475+
} else {
476+
qDebug() << "Waiting" << fastImportTimeout << "seconds for fast-import to finish.";
477+
fastImportTimeout *= 10000;
478+
}
471479
fastImport.write("checkpoint\n");
472480
fastImport.waitForBytesWritten(-1);
473481
fastImport.closeWriteChannel();
474-
if (!fastImport.waitForFinished()) {
482+
if (!fastImport.waitForFinished(fastImportTimeout)) {
475483
fastImport.terminate();
476484
if (!fastImport.waitForFinished(200))
477485
qWarning() << "WARN: git-fast-import for repository" << name << "did not die";

0 commit comments

Comments
 (0)