aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/repository.cpp28
-rw-r--r--src/repository.h2
2 files changed, 17 insertions, 13 deletions
diff --git a/src/repository.cpp b/src/repository.cpp
index 06ac2f6..c786a71 100644
--- a/src/repository.cpp
+++ b/src/repository.cpp
@@ -140,7 +140,6 @@ void Repository::createBranch(const QString &branch, int revnum,
if (!branchRef.startsWith("refs/"))
branchRef.prepend("refs/heads/");
-
Branch &br = branches[branch];
if (br.created && br.created != revnum) {
QByteArray backupBranch = branchRef + '_' + QByteArray::number(revnum);
@@ -149,15 +148,27 @@ void Repository::createBranch(const QString &branch, int revnum,
fastImport.write("reset " + backupBranch + "\nfrom " + branchRef + "\n\n");
}
+ Branch &brFrom = branches[branchFrom];
+ if (!brFrom.created) {
+ qCritical() << branch << "in repository" << name
+ << "is branching from branch" << branchFrom
+ << "but the latter doesn't exist. Can't continue.";
+ exit(1);
+ }
+
// now create the branch
br.created = revnum;
+ br.commits.append(revnum);
+
QByteArray branchFromRef, branchFromDesc;
- QVector<const int>::iterator it = qUpperBound(exportedCommits, branchRevNum);
- const int closestCommit = it == exportedCommits.begin() ? branchRevNum : *--it;
+ QVector<const int>::iterator it = qUpperBound(brFrom.commits, branchRevNum);
+ const int closestCommit = it == brFrom.commits.begin() ? branchRevNum : *--it;
if(commitMarks.contains(closestCommit)) {
- branchFromRef = ":" + QByteArray::number(commitMarks.value(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"
<< "creating an empty branch.";
@@ -167,13 +178,6 @@ void Repository::createBranch(const QString &branch, int revnum,
branchFromDesc = branchFromRef;
}
- if (!branches.contains(branchFrom) || !branches.value(branchFrom).created) {
- qCritical() << branch << "in repository" << name
- << "is branching from branch" << branchFrom
- << "but the latter doesn't exist. Can't continue.";
- exit(1);
- }
-
fastImport.write("reset " + branchRef + "\nfrom " + branchFromRef + "\n\n"
"progress Branch " + branchRef + " created from "
+ branchFromDesc + " r" + QByteArray::number(branchRevNum) + "\n\n");
@@ -369,7 +373,6 @@ void Repository::Transaction::commit()
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];
@@ -378,6 +381,7 @@ void Repository::Transaction::commit()
<< revnum << "-- did you resume from the wrong revision?";
br.created = revnum;
}
+ br.commits.append(revnum);
s << "data " << message.length() << endl;
}
diff --git a/src/repository.h b/src/repository.h
index 629616b..3df9d9a 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -72,6 +72,7 @@ private:
struct Branch
{
int created;
+ QVector<int> commits;
};
struct AnnotatedTag
{
@@ -86,7 +87,6 @@ private:
QHash<QString, Branch> branches;
QHash<QString, AnnotatedTag> annotatedTags;
QHash<int, int> commitMarks;
- QVector<int> exportedCommits;
QString name;
QProcess fastImport;
int commitCount;