From 09c6fbf79bd4e8821b799ccf79f4046a5eed6592 Mon Sep 17 00:00:00 2001 From: Raja R Harinath Date: Tue, 20 Jul 2010 21:17:36 +0530 Subject: Add a resetBranch() to help refactor createBranch and deleteBranch. Only deleteBranch uses it for now. --- src/repository.cpp | 15 +++++++++++---- src/repository.h | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/repository.cpp b/src/repository.cpp index cf36c1f..913ef73 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -341,6 +341,13 @@ int Repository::createBranch(const QString &branch, int revnum, int Repository::deleteBranch(const QString &branch, int revnum) { startFastImport(); + + static QByteArray null_sha(40, '0'); + return resetBranch(branch, revnum, 0, null_sha, "delete"); +} + +int Repository::resetBranch(const QString &branch, int revnum, int mark, const QByteArray &resetTo, const QByteArray &comment) +{ QByteArray branchRef = branch.toUtf8(); if (!branchRef.startsWith("refs/")) branchRef.prepend("refs/heads/"); @@ -355,12 +362,12 @@ int Repository::deleteBranch(const QString &branch, int revnum) br.created = revnum; br.commits.append(revnum); - br.marks.append(0); + br.marks.append(mark); - static QByteArray null_sha(40, '0'); - fastImport.write("reset " + branchRef + "\nfrom " + null_sha + "\n\n" + fastImport.write("reset " + branchRef + "\nfrom " + resetTo + "\n\n" "progress SVN r" + QByteArray::number(revnum) - + " branch " + branch.toUtf8() + " = :0 # delete\n\n"); + + " branch " + branch.toUtf8() + " = :" + QByteArray::number(mark) + + " # " + comment + "\n\n"); return EXIT_SUCCESS; } diff --git a/src/repository.h b/src/repository.h index ec821e2..d4f3d54 100644 --- a/src/repository.h +++ b/src/repository.h @@ -113,6 +113,8 @@ private: // called when a transaction is deleted void forgetTransaction(Transaction *t); + int resetBranch(const QString &branch, int revnum, int mark, const QByteArray &resetTo, const QByteArray &comment); + friend class ProcessCache; Q_DISABLE_COPY(Repository) }; -- cgit v1.2.1