aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Zander <zander@kde.org>2009-10-21 10:47:32 +0200
committerThomas Zander <zander@kde.org>2009-10-21 10:47:32 +0200
commite9d834f04442808a139445a299d153c1f7b9c04e (patch)
treed000b75bdd11ee6b5a2251edb0c90f0cb971d0f5 /src
parente0210ef585775a1744934dc973f774f48e0c271c (diff)
downloadsvn2git-e9d834f04442808a139445a299d153c1f7b9c04e.tar
svn2git-e9d834f04442808a139445a299d153c1f7b9c04e.tar.gz
svn2git-e9d834f04442808a139445a299d153c1f7b9c04e.tar.bz2
svn2git-e9d834f04442808a139445a299d153c1f7b9c04e.tar.xz
svn2git-e9d834f04442808a139445a299d153c1f7b9c04e.zip
make dry-run a command line switch instead of a compile-time switch
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp2
-rw-r--r--src/repository.cpp42
-rw-r--r--src/src.pro1
-rw-r--r--src/svn.cpp41
4 files changed, 43 insertions, 43 deletions
diff --git a/src/main.cpp b/src/main.cpp
index ab17cd1..fdea85f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -60,7 +60,7 @@ static const CommandLineOption options[] = {
{"--add-metadata", "if passed, each git commit will have svn commit info"},
{"--resume-from revision", "start importing at svn revision number"},
{"--max-rev revision", "stop importing at svn revision number"},
- //{"--dry-run", "don't actually write anything"}, TODO
+ {"--dry-run", "don't actually write anything"},
{"-h, --help", "show help"},
{"-v, --version", "show version"},
CommandLineLastOption
diff --git a/src/repository.cpp b/src/repository.cpp
index c0f0122..cdeb44d 100644
--- a/src/repository.cpp
+++ b/src/repository.cpp
@@ -65,16 +65,16 @@ Repository::Repository(const Rules::Repository &rule)
branches["master"].created = 1;
fastImport.setWorkingDirectory(name);
-#ifndef DRY_RUN
- if (!QDir(name).exists()) { // repo doesn't exist yet.
- qDebug() << "Creating new repositoryn" << name;
- QDir::current().mkpath(name);
- QProcess init;
- init.setWorkingDirectory(name);
- init.start("git", QStringList() << "--bare" << "init");
- init.waitForFinished(-1);
+ if (!CommandLineParser::instance()->contains("dry-run")) {
+ if (!QDir(name).exists()) { // repo doesn't exist yet.
+ qDebug() << "Creating new repositoryn" << name;
+ QDir::current().mkpath(name);
+ QProcess init;
+ init.setWorkingDirectory(name);
+ init.start("git", QStringList() << "--bare" << "init");
+ init.waitForFinished(-1);
+ }
}
-#endif
}
Repository::~Repository()
@@ -266,11 +266,11 @@ void Repository::startFastImport()
fastImport.setStandardOutputFile(outputFile, QIODevice::Append);
fastImport.setProcessChannelMode(QProcess::MergedChannels);
-#ifndef DRY_RUN
- fastImport.start("git", QStringList() << "fast-import");
-#else
- fastImport.start("/bin/cat", QStringList());
-#endif
+ if (!CommandLineParser::instance()->contains("dry-run")) {
+ fastImport.start("git", QStringList() << "fast-import");
+ } else {
+ fastImport.start("/bin/cat", QStringList());
+ }
reloadBranches();
}
@@ -315,13 +315,13 @@ QIODevice *Repository::Transaction::addFile(const QString &path, int mode, qint6
modifiedFiles.append(path.toUtf8());
modifiedFiles.append("\n");
-#ifndef DRY_RUN
- repository->fastImport.write("blob\nmark :");
- repository->fastImport.write(QByteArray::number(mark));
- repository->fastImport.write("\ndata ");
- repository->fastImport.write(QByteArray::number(length));
- repository->fastImport.write("\n", 1);
-#endif
+ if (!CommandLineParser::instance()->contains("dry-run")) {
+ repository->fastImport.write("blob\nmark :");
+ repository->fastImport.write(QByteArray::number(mark));
+ repository->fastImport.write("\ndata ");
+ repository->fastImport.write(QByteArray::number(length));
+ repository->fastImport.write("\n", 1);
+ }
return &repository->fastImport;
}
diff --git a/src/src.pro b/src/src.pro
index 79248bf..2fbde10 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -9,7 +9,6 @@ exists(local-config.pri):include(local-config.pri)
TEMPLATE = app
TARGET = ../svn-all-fast-export
DEPENDPATH += .
-#DEFINES += DRY_RUN
QT = core
INCLUDEPATH += . $$SVN_INCLUDE $$APR_INCLUDE
diff --git a/src/svn.cpp b/src/svn.cpp
index 3416efe..5d05ff2 100644
--- a/src/svn.cpp
+++ b/src/svn.cpp
@@ -26,6 +26,7 @@
#define _LARGEFILE64_SUPPORT
#include "svn.h"
+#include "CommandLineParser.h"
#include <unistd.h>
#include <string.h>
@@ -260,40 +261,40 @@ static int dumpBlob(Repository::Transaction *txn, svn_fs_root_t *fs_root,
SVN_ERR(svn_fs_file_length(&stream_length, fs_root, pathname, dumppool));
-#ifndef DRY_RUN
- // open the file
svn_stream_t *in_stream, *out_stream;
- SVN_ERR(svn_fs_file_contents(&in_stream, fs_root, pathname, dumppool));
-#endif
+ if (!CommandLineParser::instance()->contains("dry-run")) {
+ // open the file
+ SVN_ERR(svn_fs_file_contents(&in_stream, fs_root, pathname, dumppool));
+ }
// maybe it's a symlink?
svn_string_t *propvalue;
SVN_ERR(svn_fs_node_prop(&propvalue, fs_root, pathname, "svn:special", dumppool));
if (propvalue) {
apr_size_t len = strlen("link ");
-#ifndef DRY_RUN
- QByteArray buf;
- buf.reserve(len);
- SVN_ERR(svn_stream_read(in_stream, buf.data(), &len));
- if (len != strlen("link ") || strncmp(buf, "link ", len) != 0)
- qFatal("file %s is svn:special but not a symlink", pathname);
-#endif
+ if (!CommandLineParser::instance()->contains("dry-run")) {
+ QByteArray buf;
+ buf.reserve(len);
+ SVN_ERR(svn_stream_read(in_stream, buf.data(), &len));
+ if (len != strlen("link ") || strncmp(buf, "link ", len) != 0)
+ qFatal("file %s is svn:special but not a symlink", pathname);
+ }
mode = 0120000;
stream_length -= len;
}
QIODevice *io = txn->addFile(finalPathName, mode, stream_length);
-#ifndef DRY_RUN
- // open a generic svn_stream_t for the QIODevice
- out_stream = streamForDevice(io, dumppool);
- SVN_ERR(svn_stream_copy(in_stream, out_stream, dumppool));
- svn_stream_close(out_stream);
- svn_stream_close(in_stream);
+ if (!CommandLineParser::instance()->contains("dry-run")) {
+ // open a generic svn_stream_t for the QIODevice
+ out_stream = streamForDevice(io, dumppool);
+ SVN_ERR(svn_stream_copy(in_stream, out_stream, dumppool));
+ svn_stream_close(out_stream);
+ svn_stream_close(in_stream);
- // print an ending newline
- io->putChar('\n');
-#endif
+ // print an ending newline
+ io->putChar('\n');
+ }
return EXIT_SUCCESS;
}