aboutsummaryrefslogtreecommitdiffstats
path: root/src/repository.cpp
diff options
context:
space:
mode:
authorMarc Guenther <marcguenther@me.com>2010-05-06 14:11:10 +0200
committerMarc Guenther <marcguenther@me.com>2010-05-06 14:11:10 +0200
commit54e55cfcb0ec8f634c1d5488232c54d1f7495882 (patch)
tree9e66046568979983a6ef135c8d30ba6560775de8 /src/repository.cpp
parentb886ca85875859e7a3dd98aaf087abe9365c0646 (diff)
parent209e6ce4ddf114494d6d72455690af819dcbf18c (diff)
downloadsvn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.tar
svn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.tar.gz
svn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.tar.bz2
svn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.tar.xz
svn2git-54e55cfcb0ec8f634c1d5488232c54d1f7495882.zip
Merge branch 'master' of gitorious.org:svn2git/svn2git
Diffstat (limited to 'src/repository.cpp')
-rw-r--r--src/repository.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/repository.cpp b/src/repository.cpp
index d589b6e..1398dd0 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];
@@ -376,9 +388,9 @@ void Repository::Transaction::commit()
QByteArray::number(repository->commitCount) +
" branch " + branch +
" = SVN r" + QByteArray::number(revnum) + "\n\n");
- printf(" %d modifications to \"%s\"",
- deletedFiles.count() + modifiedFiles.count(),
- qPrintable(repository->name));
+ printf(" %d modifications from SVN %s to %s/%s",
+ deletedFiles.count() + modifiedFiles.count(), svnprefix.data(),
+ qPrintable(repository->name), branch.data());
while (repository->fastImport.bytesToWrite())
if (!repository->fastImport.waitForBytesWritten(-1))