aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaja R Harinath <harinath@hurrynot.org>2010-06-20 22:59:41 +0530
committerRaja R Harinath <harinath@hurrynot.org>2010-06-20 22:59:41 +0530
commitc4d607628ba4b9f5a532900051f80f5fa1a01034 (patch)
tree8ba190a9e25065f92cce124d43d0a04bce5bb6f2
parentc99f14df097f72394a6bb9c8ae9130cd8cb86cf1 (diff)
downloadsvn2git-c4d607628ba4b9f5a532900051f80f5fa1a01034.tar
svn2git-c4d607628ba4b9f5a532900051f80f5fa1a01034.tar.gz
svn2git-c4d607628ba4b9f5a532900051f80f5fa1a01034.tar.bz2
svn2git-c4d607628ba4b9f5a532900051f80f5fa1a01034.tar.xz
svn2git-c4d607628ba4b9f5a532900051f80f5fa1a01034.zip
Improve progess log
Make the progress log for commit and branch creation more uniform and machine parse-able. Add 'mark' information to log so that it can be cross-referenced against the fast-import marks file. The log-* files now have enough information in a convenient enough form that the export can eventually be made fully resumable and incremental. The format is essentially progress SVN r<svn-rev> branch <git-branch> = (:<mark> | <other-git-branch>) with a possible trailing # comment. Any line not matching this can be The incremental mode would prime the internal structures with if (<mark>) repository->commitMarks[<svn-rev>] = <mark>; repository->branches[<git-branch>].commits.append(<svn-rev>);
-rw-r--r--src/repository.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/repository.cpp b/src/repository.cpp
index c786a71..1405d90 100644
--- a/src/repository.cpp
+++ b/src/repository.cpp
@@ -161,13 +161,21 @@ void Repository::createBranch(const QString &branch, int revnum,
br.commits.append(revnum);
QByteArray branchFromRef, branchFromDesc;
- QVector<const int>::iterator it = qUpperBound(brFrom.commits, branchRevNum);
- const int closestCommit = it == brFrom.commits.begin() ? branchRevNum : *--it;
+
+ int closestCommit = branchRevNum;
+ if (branchRevNum == brFrom.commits.last()) {
+ branchFromDesc = "from branch " + branchFrom.toUtf8();
+ } else {
+ QVector<const int>::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(commitMarks.contains(closestCommit)) {
int mark = commitMarks[closestCommit];
branchFromRef = ":" + QByteArray::number(mark);
- branchFromDesc = branchFromRef + " (r" + QByteArray::number(closestCommit) + ")";
commitMarks[revnum] = mark;
} else {
qWarning() << branch << "in repository" << name << "is branching but no exported commits exist in repository"
@@ -175,12 +183,14 @@ void Repository::createBranch(const QString &branch, int revnum,
branchFromRef = branchFrom.toUtf8();
if (!branchFromRef.startsWith("refs/"))
branchFromRef.prepend("refs/heads/");
- branchFromDesc = branchFromRef;
+ branchFromDesc = "at unknown r" + QByteArray::number(branchRevNum);
}
fastImport.write("reset " + branchRef + "\nfrom " + branchFromRef + "\n\n"
- "progress Branch " + branchRef + " created from "
- + branchFromDesc + " r" + QByteArray::number(branchRevNum) + "\n\n");
+ "progress SVN r" + QByteArray::number(revnum)
+ + " branch " + branch.toUtf8() + " = " + branchFromRef
+ + " # " + branchFromDesc
+ + "\n\n");
}
Repository::Transaction *Repository::newTransaction(const QString &branch, const QString &svnprefix,
@@ -357,6 +367,8 @@ void Repository::Transaction::commit()
{
processCache.touch(repository);
+ int mark = ++repository->lastmark;
+
// create the commit message
QByteArray message = log;
if (!message.endsWith('\n'))
@@ -371,8 +383,8 @@ 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);
+ s << "mark :" << QByteArray::number(mark) << endl;
+ repository->commitMarks.insert(revnum, mark);
s << "committer " << QString::fromUtf8(author) << ' ' << datetime << " -0000" << endl;
Branch &br = repository->branches[branch];
@@ -399,10 +411,10 @@ void Repository::Transaction::commit()
// write the file modifications
repository->fastImport.write(modifiedFiles);
- repository->fastImport.write("\nprogress Commit #" +
- QByteArray::number(repository->commitCount) +
- " branch " + branch +
- " = SVN r" + QByteArray::number(revnum) + "\n\n");
+ repository->fastImport.write("\nprogress SVN r" + QByteArray::number(revnum)
+ + " branch " + branch + " = :" + QByteArray::number(mark)
+ /*+ " # Commit #" + QByteArray::number(repository->commitCount)*/
+ + "\n\n");
printf(" %d modifications from SVN %s to %s/%s",
deletedFiles.count() + modifiedFiles.count(), svnprefix.data(),
qPrintable(repository->name), branch.data());