aboutsummaryrefslogtreecommitdiffstats
path: root/src/repository.cpp
diff options
context:
space:
mode:
authorRaja R Harinath <harinath@hurrynot.org>2010-07-20 21:17:36 +0530
committerRaja R Harinath <harinath@hurrynot.org>2010-07-20 21:17:36 +0530
commit09c6fbf79bd4e8821b799ccf79f4046a5eed6592 (patch)
treeefd707059e754b5c455c620c6e0ed857d9232abf /src/repository.cpp
parent4f080c2c934d5caa7a8eae8123cfbab7a735cc11 (diff)
downloadsvn2git-09c6fbf79bd4e8821b799ccf79f4046a5eed6592.tar
svn2git-09c6fbf79bd4e8821b799ccf79f4046a5eed6592.tar.gz
svn2git-09c6fbf79bd4e8821b799ccf79f4046a5eed6592.tar.bz2
svn2git-09c6fbf79bd4e8821b799ccf79f4046a5eed6592.tar.xz
svn2git-09c6fbf79bd4e8821b799ccf79f4046a5eed6592.zip
Add a resetBranch() to help refactor createBranch and deleteBranch.
Only deleteBranch uses it for now.
Diffstat (limited to 'src/repository.cpp')
-rw-r--r--src/repository.cpp15
1 files changed, 11 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;
}