aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaja R Harinath <harinath@hurrynot.org>2010-06-19 20:39:50 +0530
committerRaja R Harinath <harinath@hurrynot.org>2010-06-19 20:54:04 +0530
commit97657964b3c9ba5d5b45dced323a53c1e5d83b94 (patch)
treea9a9bed9813ac6461fc5ef2802fa5bd5e2d69e5b /src
parent2de3ef976eeb1c860d082ed73a58c02be5834923 (diff)
downloadsvn2git-97657964b3c9ba5d5b45dced323a53c1e5d83b94.tar
svn2git-97657964b3c9ba5d5b45dced323a53c1e5d83b94.tar.gz
svn2git-97657964b3c9ba5d5b45dced323a53c1e5d83b94.tar.bz2
svn2git-97657964b3c9ba5d5b45dced323a53c1e5d83b94.tar.xz
svn2git-97657964b3c9ba5d5b45dced323a53c1e5d83b94.zip
Improve determination of branch point
This fixes the logic of commit 209e6ce4ddf114494d6d72455690af819dcbf18c qLowerBound doesn't have the desired semantics -- it returns the position of the first item which is not smaller than the search key. The intended semantics seems to be to find the given key, or the next smallest one. This is almost given by qUpperBound -- it returns an element one past the desired result. I've also added some additional debugging code to help debug this.
Diffstat (limited to 'src')
-rw-r--r--src/repository.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/repository.cpp b/src/repository.cpp
index 6627568..06ac2f6 100644
--- a/src/repository.cpp
+++ b/src/repository.cpp
@@ -151,17 +151,20 @@ void Repository::createBranch(const QString &branch, int revnum,
// now create the branch
br.created = revnum;
- QByteArray branchFromRef;
- const int closestCommit = *qLowerBound(exportedCommits, branchRevNum);
- if(commitMarks.contains(closestCommit))
- {
+ QByteArray branchFromRef, branchFromDesc;
+ QVector<const int>::iterator it = qUpperBound(exportedCommits, branchRevNum);
+ const int closestCommit = it == exportedCommits.begin() ? branchRevNum : *--it;
+
+ if(commitMarks.contains(closestCommit)) {
branchFromRef = ":" + QByteArray::number(commitMarks.value(closestCommit));
+ branchFromDesc = branchFromRef + " (r" + QByteArray::number(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/");
+ branchFromDesc = branchFromRef;
}
if (!branches.contains(branchFrom) || !branches.value(branchFrom).created) {
@@ -173,7 +176,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(branchRevNum) + "\n\n");
+ + branchFromDesc + " r" + QByteArray::number(branchRevNum) + "\n\n");
}
Repository::Transaction *Repository::newTransaction(const QString &branch, const QString &svnprefix,