From ae4fa7288cbfd27296186c85206966461fa20db6 Mon Sep 17 00:00:00 2001 From: Torgny Nyblom Date: Wed, 15 Dec 2010 16:03:34 +0100 Subject: Move branch creation/deletion/restting to Repository and write these in commit() Prepare for handling cvs2svn borked tags/branches --- src/repository.cpp | 21 ++++++++++++++++----- src/repository.h | 3 +++ src/svn.cpp | 4 ++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/repository.cpp b/src/repository.cpp index 6af1200..ce6d6ea 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -344,8 +344,6 @@ int Repository::deleteBranch(const QString &branch, int revnum) int Repository::resetBranch(const QString &branch, int revnum, int mark, const QByteArray &resetTo, const QByteArray &comment) { - startFastImport(); - QByteArray branchRef = branch.toUtf8(); if (!branchRef.startsWith("refs/")) branchRef.prepend("refs/heads/"); @@ -355,21 +353,34 @@ int Repository::resetBranch(const QString &branch, int revnum, int mark, const Q QByteArray backupBranch = "refs/backups/r" + QByteArray::number(revnum) + branchRef.mid(4); qWarning() << "backing up branch" << branch << "to" << backupBranch; - fastImport.write("reset " + backupBranch + "\nfrom " + branchRef + "\n\n"); + resetBranches.append("reset " + backupBranch + "\nfrom " + branchRef + "\n\n"); } br.created = revnum; br.commits.append(revnum); br.marks.append(mark); - fastImport.write("reset " + branchRef + "\nfrom " + resetTo + "\n\n" + QByteArray cmd = "reset " + branchRef + "\nfrom " + resetTo + "\n\n" "progress SVN r" + QByteArray::number(revnum) + " branch " + branch.toUtf8() + " = :" + QByteArray::number(mark) - + " # " + comment + "\n\n"); + + " # " + comment + "\n\n"; + if(comment == "delete") + deletedBranches.append(cmd); + else + resetBranches.append(cmd); return EXIT_SUCCESS; } +void Repository::commit() +{ + startFastImport(); + fastImport.write(deletedBranches); + fastImport.write(resetBranches); + deletedBranches.clear(); + resetBranches.clear(); +} + Repository::Transaction *Repository::newTransaction(const QString &branch, const QString &svnprefix, int revnum) { diff --git a/src/repository.h b/src/repository.h index 44388e0..349cf97 100644 --- a/src/repository.h +++ b/src/repository.h @@ -142,6 +142,7 @@ public: const QByteArray &author, uint dt, const QByteArray &log); void finalizeTags(); + void commit(); private: struct Branch @@ -167,6 +168,8 @@ private: LoggingQProcess fastImport; int commitCount; int outstandingTransactions; + QByteArray deletedBranches; + QByteArray resetBranches; /* starts at 0, and counts up. */ int last_commit_mark; diff --git a/src/svn.cpp b/src/svn.cpp index c7835ff..cf4ce23 100644 --- a/src/svn.cpp +++ b/src/svn.cpp @@ -506,6 +506,10 @@ int SvnRevision::commit() // now create the commit if (fetchRevProps() != EXIT_SUCCESS) return EXIT_FAILURE; + foreach (Repository *repo, repositories.values()) { + repo->commit(); + } + foreach (Repository::Transaction *txn, transactions) { txn->setAuthor(authorident); txn->setDateTime(epoch); -- cgit v1.2.1