aboutsummaryrefslogtreecommitdiffstats
path: root/src/repository.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/repository.cpp')
-rw-r--r--src/repository.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/repository.cpp b/src/repository.cpp
index 5250f71..847771f 100644
--- a/src/repository.cpp
+++ b/src/repository.cpp
@@ -141,7 +141,7 @@ void Repository::createBranch(const QString &branch, int revnum,
branchRef.prepend("refs/heads/");
Branch &br = branches[branch];
- if (br.created && br.created != revnum) {
+ if (br.created && br.created != revnum && br.marks.last()) {
QByteArray backupBranch = branchRef + '_' + QByteArray::number(revnum);
qWarning() << branch << "already exists; backing up to" << backupBranch;
@@ -193,6 +193,30 @@ void Repository::createBranch(const QString &branch, int revnum,
+ "\n\n");
}
+void Repository::deleteBranch(const QString &branch, int revnum)
+{
+ QByteArray branchRef = branch.toUtf8();
+ if (!branchRef.startsWith("refs/"))
+ branchRef.prepend("refs/heads/");
+
+ Branch &br = branches[branch];
+ if (br.created && br.created != revnum && br.marks.last()) {
+ QByteArray backupBranch = branchRef + '_' + QByteArray::number(revnum);
+ qWarning() << "backing up branch" << branch << "to" << backupBranch;
+
+ fastImport.write("reset " + backupBranch + "\nfrom " + branchRef + "\n\n");
+ }
+
+ br.created = revnum;
+ br.commits.append(revnum);
+ br.marks.append(0);
+
+ static QByteArray null_sha(40, '0');
+ fastImport.write("reset " + branchRef + "\nfrom " + null_sha + "\n\n"
+ "progress SVN r" + QByteArray::number(revnum)
+ + " branch " + branch.toUtf8() + " = :0 # delete\n\n");
+}
+
Repository::Transaction *Repository::newTransaction(const QString &branch, const QString &svnprefix,
int revnum)
{