From 97657964b3c9ba5d5b45dced323a53c1e5d83b94 Mon Sep 17 00:00:00 2001 From: Raja R Harinath Date: Sat, 19 Jun 2010 20:39:50 +0530 Subject: 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. --- src/repository.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') 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::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, -- cgit v1.2.1