diff options
author | Raja R Harinath <harinath@hurrynot.org> | 2010-07-05 21:36:28 +0530 |
---|---|---|
committer | Raja R Harinath <harinath@hurrynot.org> | 2010-07-05 21:36:28 +0530 |
commit | 8d462d3531a702655c5b81c6c6c9409d6a320150 (patch) | |
tree | d9c189ab5e7c56f8bb6817a1c11dc852431fadce /src | |
parent | 2d55c90c734841b9c60b372047c296475e6e782b (diff) | |
download | svn2git-8d462d3531a702655c5b81c6c6c9409d6a320150.tar svn2git-8d462d3531a702655c5b81c6c6c9409d6a320150.tar.gz svn2git-8d462d3531a702655c5b81c6c6c9409d6a320150.tar.bz2 svn2git-8d462d3531a702655c5b81c6c6c9409d6a320150.tar.xz svn2git-8d462d3531a702655c5b81c6c6c9409d6a320150.zip |
Move SVN revision to fast-import mark mapping to the per-branch datastructure.
A single SVN revision can affect multiple branches in the same repository.
Keeping track of only one mark per revision loses information and makes
the history incorrect.
Diffstat (limited to 'src')
-rw-r--r-- | src/repository.cpp | 57 | ||||
-rw-r--r-- | src/repository.h | 2 |
2 files changed, 32 insertions, 27 deletions
diff --git a/src/repository.cpp b/src/repository.cpp index 059dbf6..5250f71 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -156,28 +156,28 @@ void Repository::createBranch(const QString &branch, int revnum, exit(1); } - // now create the branch - br.created = revnum; - br.commits.append(revnum); - - QByteArray branchFromRef, branchFromDesc; - - int closestCommit = branchRevNum; + int mark = 0; + QByteArray branchFromDesc = "from branch " + branchFrom.toUtf8(); if (branchRevNum == brFrom.commits.last()) { - branchFromDesc = "from branch " + branchFrom.toUtf8(); + mark = brFrom.marks.last(); } else { QVector<int>::const_iterator it = qUpperBound(brFrom.commits, branchRevNum); - closestCommit = it == brFrom.commits.begin() ? branchRevNum : *--it; - branchFromDesc = "from branch " + branchFrom.toUtf8() + " at r" + QByteArray::number(branchRevNum); - if (closestCommit != branchRevNum) - branchFromDesc += " => r" + QByteArray::number(closestCommit); + if (it != brFrom.commits.begin()) { + int closestCommit = *--it; + mark = brFrom.marks[it - brFrom.commits.begin()]; + branchFromDesc += " at r" + QByteArray::number(branchRevNum); + if (closestCommit != branchRevNum) + branchFromDesc += " => r" + QByteArray::number(closestCommit); + } } - if(commitMarks.contains(closestCommit)) { - int mark = commitMarks[closestCommit]; - branchFromRef = ":" + QByteArray::number(mark); - commitMarks[revnum] = mark; - } else { + // now create the branch + br.created = revnum; + br.commits.append(revnum); + br.marks.append(mark); + + QByteArray branchFromRef = ":" + QByteArray::number(mark); + if (!mark) { qWarning() << branch << "in repository" << name << "is branching but no exported commits exist in repository" << "creating an empty branch."; branchFromRef = branchFrom.toUtf8(); @@ -339,21 +339,26 @@ void Repository::Transaction::noteCopyFromBranch (const QString &branchFrom, int return; } - int closestCommit = branchRevNum; - if (branchRevNum != brFrom.commits.last()) { + int mark = 0; + + if (branchRevNum == brFrom.commits.last()) { + mark = brFrom.marks.last(); + } else { QVector<int>::const_iterator it = qUpperBound(brFrom.commits, branchRevNum); - closestCommit = it == brFrom.commits.begin() ? branchRevNum : *--it; + if (it != brFrom.commits.begin()) { + --it; + mark = brFrom.marks[it - brFrom.commits.begin()]; + } } - if (!repository->commitMarks.contains(closestCommit)) { - qWarning() << "Unknown revision r" << QByteArray::number(closestCommit) - << ". Continuing, assuming the files exist."; + if (!mark) { + qWarning() << "Unknown revision r" << QByteArray::number(branchRevNum) + << ". Continuing, assuming the files exist."; return; } qWarning() << "repository " + repository->name + " branch " + branch + " has some files copied from " + branchFrom + "@" + QByteArray::number(branchRevNum); - int mark = repository->commitMarks[closestCommit]; if (!merges.contains(mark)) merges.append(mark); } @@ -407,13 +412,14 @@ void Repository::Transaction::commit() int parentmark = 0; Branch &br = repository->branches[branch]; if (br.created) { - parentmark = repository->commitMarks[br.commits.last()]; + parentmark = br.marks.last(); } else { qWarning() << "Branch" << branch << "in repository" << repository->name << "doesn't exist at revision" << revnum << "-- did you resume from the wrong revision?"; br.created = revnum; } br.commits.append(revnum); + br.marks.append(mark); { QByteArray branchRef = branch; @@ -423,7 +429,6 @@ void Repository::Transaction::commit() QTextStream s(&repository->fastImport); s << "commit " << branchRef << endl; s << "mark :" << QByteArray::number(mark) << endl; - repository->commitMarks.insert(revnum, mark); s << "committer " << QString::fromUtf8(author) << ' ' << datetime << " -0000" << endl; s << "data " << message.length() << endl; diff --git a/src/repository.h b/src/repository.h index 020e1f6..f30b49f 100644 --- a/src/repository.h +++ b/src/repository.h @@ -77,6 +77,7 @@ private: { int created; QVector<int> commits; + QVector<int> marks; }; struct AnnotatedTag { @@ -90,7 +91,6 @@ private: QHash<QString, Branch> branches; QHash<QString, AnnotatedTag> annotatedTags; - QHash<int, int> commitMarks; QString name; QProcess fastImport; int commitCount; |