diff options
-rw-r--r-- | src/repository.cpp | 30 | ||||
-rw-r--r-- | src/repository.h | 3 |
2 files changed, 24 insertions, 9 deletions
diff --git a/src/repository.cpp b/src/repository.cpp index f7f7a30..426eeff 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -120,7 +120,7 @@ void Repository::reloadBranches() } void Repository::createBranch(const QString &branch, int revnum, - const QString &branchFrom, int) + const QString &branchFrom, int branchRevNum) { startFastImport(); if (!branches.contains(branch)) { @@ -129,8 +129,9 @@ void Repository::createBranch(const QString &branch, int revnum, } QByteArray branchRef = branch.toUtf8(); - if (!branchRef.startsWith("refs/")) - branchRef.prepend("refs/heads/"); + if (!branchRef.startsWith("refs/")) + branchRef.prepend("refs/heads/"); + Branch &br = branches[branch]; if (br.created && br.created != revnum) { @@ -142,9 +143,18 @@ void Repository::createBranch(const QString &branch, int revnum, // now create the branch br.created = revnum; - QByteArray branchFromRef = branchFrom.toUtf8(); - if (!branchFromRef.startsWith("refs/")) - branchFromRef.prepend("refs/heads/"); + QByteArray branchFromRef; + const int closestCommit = *qLowerBound(exportedCommits, branchRevNum); + if(commitMarks.contains(closestCommit)) + { + branchFromRef = ":" + QByteArray::number(commitMarks.value(closestCommit)); + } else { + qWarning() << branch << "in repository" << name << "is branching but no exported commits exist in repository" + << "creating an empty branch."; + branchFromRef = branchFrom.toUtf8(); + if (!branchFromRef.startsWith("refs/")) + branchFromRef.prepend("refs/heads/"); + } if (!branches.contains(branchFrom) || !branches.value(branchFrom).created) { qCritical() << branch << "in repository" << name @@ -155,7 +165,7 @@ void Repository::createBranch(const QString &branch, int revnum, fastImport.write("reset " + branchRef + "\nfrom " + branchFromRef + "\n\n" "progress Branch " + branchRef + " created from " - + branchFromRef + " r" + QByteArray::number(revnum) + "\n\n"); + + branchFromRef + " r" + QByteArray::number(branchRevNum) + "\n\n"); } Repository::Transaction *Repository::newTransaction(const QString &branch, const QString &svnprefix, @@ -177,8 +187,7 @@ Repository::Transaction *Repository::newTransaction(const QString &branch, const if ((++commitCount % CommandLineParser::instance()->optionArgument(QLatin1String("commit-interval"), QLatin1String("10000")).toInt()) == 0) // write everything to disk every 10000 commits fastImport.write("checkpoint\n"); - if (outstandingTransactions++ == 0) - lastmark = 1; // reset the mark number + outstandingTransactions++; return txn; } @@ -347,6 +356,9 @@ void Repository::Transaction::commit() QTextStream s(&repository->fastImport); s << "commit " << branchRef << endl; + s << "mark :" << QByteArray::number(++repository->lastmark) << endl; + repository->commitMarks.insert(revnum, repository->lastmark); + repository->exportedCommits.append(revnum); s << "committer " << QString::fromUtf8(author) << ' ' << datetime << " -0000" << endl; Branch &br = repository->branches[branch]; diff --git a/src/repository.h b/src/repository.h index c00518a..629616b 100644 --- a/src/repository.h +++ b/src/repository.h @@ -20,6 +20,7 @@ #include <QHash> #include <QProcess> +#include <QVector> #include "ruleparser.h" @@ -84,6 +85,8 @@ private: QHash<QString, Branch> branches; QHash<QString, AnnotatedTag> annotatedTags; + QHash<int, int> commitMarks; + QVector<int> exportedCommits; QString name; QProcess fastImport; int commitCount; |