diff options
author | Raja R Harinath <harinath@hurrynot.org> | 2010-07-20 21:17:36 +0530 |
---|---|---|
committer | Raja R Harinath <harinath@hurrynot.org> | 2010-07-20 21:17:36 +0530 |
commit | 09c6fbf79bd4e8821b799ccf79f4046a5eed6592 (patch) | |
tree | efd707059e754b5c455c620c6e0ed857d9232abf | |
parent | 4f080c2c934d5caa7a8eae8123cfbab7a735cc11 (diff) | |
download | svn2git-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.
-rw-r--r-- | src/repository.cpp | 15 | ||||
-rw-r--r-- | 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) }; |