#include "repository.h"
#include <QTextStream>
+#include <QDebug>
Repository::Repository(const Rules::Repository &rule)
+ : name(rule.name)
{
foreach (Rules::Repository::Branch branchRule, rule.branches) {
Branch branch;
branches.insert(branchRule.name, branch);
}
+ // create the default branch
+ branches["master"].isCreated = true;
+
fastImport.setWorkingDirectory(rule.name);
fastImport.setProcessChannelMode(QProcess::ForwardedChannels);
}
Repository::Transaction *Repository::newTransaction(const QString &branch, const QString &svnprefix,
int revnum)
{
- if (!branches.contains(branch))
+ if (!branches.contains(branch)) {
+ qCritical() << branch << "is not known in repository" << name;
return 0;
+ }
Transaction *txn = new Transaction;
txn->repository = this;
txn->revnum = revnum;
txn->lastmark = revnum;
- if (fastImport.state() == QProcess::NotRunning)
+ if (fastImport.state() == QProcess::NotRunning) {
// start the process
+#ifndef DRY_RUN
fastImport.start("git-fast-import", QStringList());
+#else
+ fastImport.start("/bin/cat", QStringList());
+#endif
+ }
return txn;
}
fp.mode = mode;
fp.mark = ++lastmark;
+#ifndef DRY_RUN
repository->fastImport.write("blob\nmark :");
repository->fastImport.write(QByteArray::number(fp.mark));
repository->fastImport.write("\ndata ");
repository->fastImport.write(QByteArray::number(length));
repository->fastImport.write("\n", 1);
repository->fastImport.waitForBytesWritten(0);
+#endif
modifiedFiles.insert(path, fp);
return &repository->fastImport;
QTextStream s(&repository->fastImport);
s << "commit " << branchRef << endl;
s << "mark :" << revnum << endl;
- s << "committer " << author << ' ' << datetime << "-0000" << endl;
+ s << "committer " << author << ' ' << datetime << " -0000" << endl;
Branch &br = repository->branches[branch];
if (!br.isCreated) {