From 8b6c8bd67831d68f8a275d8986e6589291ab6ba2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Aug 2008 23:40:41 +0200 Subject: [PATCH] Fix a bug when committing to two branches of the same repository in the same SVN revision --- src/repository.cpp | 10 ++++++---- src/repository.h | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/repository.cpp b/src/repository.cpp index 890c10c..512a745 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -45,7 +45,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 +62,7 @@ Repository::Repository(const Rules::Repository &rule) Repository::~Repository() { + Q_ASSERT(outstandingTransactions == 0); closeFastImport(); } @@ -154,11 +155,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 +190,7 @@ void Repository::startFastImport() Repository::Transaction::~Transaction() { + --repository->outstandingTransactions; } void Repository::Transaction::setAuthor(const QByteArray &a) @@ -212,7 +215,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); @@ -252,7 +255,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]; diff --git a/src/repository.h b/src/repository.h index 9a49040..c5e70fe 100644 --- a/src/repository.h +++ b/src/repository.h @@ -38,7 +38,6 @@ public: QByteArray log; uint datetime; int revnum; - int lastmark; QStringList deletedFiles; QByteArray modifiedFiles; @@ -73,6 +72,8 @@ private: QString name; QProcess fastImport; int commitCount; + int outstandingTransactions; + int lastmark; bool processHasStarted; void startFastImport(); -- 2.11.4.GIT