]> andersk Git - svn-all-fast-export.git/blobdiff - src/repository.cpp
Add a --no-metadata option to suppress the svn info in commit messages.
[svn-all-fast-export.git] / src / repository.cpp
index 890c10c9329f88ff356fefa3d4de0c8a333ffb4e..9c2a9d5421964cd2261a0f75c2ebedf9ae91d369 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include "repository.h"
+#include "options.h"
 #include <QTextStream>
 #include <QDebug>
 #include <QLinkedList>
@@ -45,7 +46,7 @@ public:
 static ProcessCache processCache;
 
 Repository::Repository(const Rules::Repository &rule)
-    : name(rule.name), commitCount(0), processHasStarted(false)
+    : name(rule.name), commitCount(0), outstandingTransactions(0), processHasStarted(false)
 {
     foreach (Rules::Repository::Branch branchRule, rule.branches) {
         Branch branch;
@@ -62,6 +63,7 @@ Repository::Repository(const Rules::Repository &rule)
 
 Repository::~Repository()
 {
+    Q_ASSERT(outstandingTransactions == 0);
     closeFastImport();
 }
 
@@ -154,11 +156,12 @@ Repository::Transaction *Repository::newTransaction(const QString &branch, const
     txn->svnprefix = svnprefix.toUtf8();
     txn->datetime = 0;
     txn->revnum = revnum;
-    txn->lastmark = revnum;
 
     if ((++commitCount % 10000) == 0)
         // write everything to disk every 10000 commits
         fastImport.write("checkpoint\n");
+    if (outstandingTransactions++ == 0)
+        lastmark = 1;           // reset the mark number
     return txn;
 }
 
@@ -188,6 +191,7 @@ void Repository::startFastImport()
 
 Repository::Transaction::~Transaction()
 {
+    --repository->outstandingTransactions;
 }
 
 void Repository::Transaction::setAuthor(const QByteArray &a)
@@ -212,7 +216,7 @@ void Repository::Transaction::deleteFile(const QString &path)
 
 QIODevice *Repository::Transaction::addFile(const QString &path, int mode, qint64 length)
 {
-    int mark = ++lastmark;
+    int mark = ++repository->lastmark;
 
     if (modifiedFiles.capacity() == 0)
         modifiedFiles.reserve(2048);
@@ -243,7 +247,8 @@ void Repository::Transaction::commit()
     QByteArray message = log;
     if (!message.endsWith('\n'))
         message += '\n';
-    message += "\nsvn path=" + svnprefix + "; revision=" + QByteArray::number(revnum) + "\n";
+    if (Options::globalOptions->switches.value("metadata", true))
+        message += "\nsvn path=" + svnprefix + "; revision=" + QByteArray::number(revnum) + "\n";
 
     {
         QByteArray branchRef = branch;
@@ -252,7 +257,6 @@ void Repository::Transaction::commit()
 
         QTextStream s(&repository->fastImport);
         s << "commit " << branchRef << endl;
-        s << "mark :" << revnum << endl;
         s << "committer " << QString::fromUtf8(author) << ' ' << datetime << " -0000" << endl;
 
         Branch &br = repository->branches[branch];
This page took 0.026761 seconds and 4 git commands to generate.