# # # patch "src/monotone/WorkspaceCreator.cpp" # from [3fd1f85c4f61d7665f2986f71279a0873531ada6] # to [7d51f6200bed2e9b2dba2117af5e9fe02e176867] # # patch "src/monotone/WorkspaceCreator.h" # from [89f2bc9696212d97fc99e806388542b8b084a2a1] # to [f30353cccd83fcb6eb845ea9d9f86531daf9cc68] # ============================================================ --- src/monotone/WorkspaceCreator.cpp 3fd1f85c4f61d7665f2986f71279a0873531ada6 +++ src/monotone/WorkspaceCreator.cpp 7d51f6200bed2e9b2dba2117af5e9fe02e176867 @@ -17,36 +17,31 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "WorkspaceCreator.h" -#include "Guitone.h" -#include "MonotoneDelegate.h" +#include "MonotoneUtil.h" -#include #include -WorkspaceCreator::WorkspaceCreator(QObject * parent, QString rev, QDir dir) - : FileExporter(parent, rev, dir) +WorkspaceCreator::WorkspaceCreator(const QString & databaseFile, const QString & rev, const QDir & dir) + : FileExporter(databaseFile, rev, dir) {} -WorkspaceCreator::~WorkspaceCreator() -{} - bool WorkspaceCreator::run() { // // at first determine the branch name(s) of the revision and let the // user select one branch of a list of branches // - RevisionCerts certs = MonotoneDelegate::getRevisionCerts(this, revision); - + RevisionCerts certs = MonotoneUtil::getRevisionCerts(databaseFile, revision); + QStringList branches; for (int i=0,j=certs.size(); i 1) { bool ok; @@ -64,6 +59,7 @@ bool WorkspaceCreator::run() tr("The selected revision has more than one\n" "branch cert attached - please select one:"), branches, 0, false, &ok); + if (!ok || branch.isEmpty()) { D("User aborted checkout"); @@ -71,13 +67,13 @@ bool WorkspaceCreator::run() } selectedBranch = branch; } - + // // now we query the manifest contents // - FileEntryList entries = - MonotoneDelegate::getRevisionManifest(this, revision); - + FileEntryList entries = + MonotoneUtil::getRevisionManifest(databaseFile, revision); + // // finally before we export anything, we create the _MTN directory layout // @@ -86,9 +82,9 @@ bool WorkspaceCreator::run() C("Cannot create directory"); return false; } - + I(rootDir.cd("_MTN")); - + // _MTN/revision QFile revfile(rootDir.filePath("revision")); if (!revfile.open(QIODevice::WriteOnly)) @@ -96,12 +92,14 @@ bool WorkspaceCreator::run() C("Can't open revision for writing"); return false; } + QString rev = QString("format_version \"1\"\n\n" "new_manifest [0000000000000000000000000000000000000000]\n\n" "old_revision [%1]\n").arg(revision); + I(revfile.write(rev.toLatin1())); revfile.close(); - + // _MTN/format QFile formatfile(rootDir.filePath("format")); if (!formatfile.open(QIODevice::WriteOnly)) @@ -109,9 +107,10 @@ bool WorkspaceCreator::run() C("Can't open format for writing"); return false; } + I(formatfile.write(QString("2\n").toLatin1())); formatfile.close(); - + // _MTN/log (initally empty) QFile logfile(rootDir.filePath("log")); if (!logfile.open(QIODevice::WriteOnly)) @@ -120,7 +119,7 @@ bool WorkspaceCreator::run() return false; } logfile.close(); - + // _MTN/options QFile optfile(rootDir.filePath("options")); if (!optfile.open(QIODevice::WriteOnly)) @@ -128,17 +127,21 @@ bool WorkspaceCreator::run() C("Can't open revision for writing"); return false; } + // the keydir entry is not needed and automatically added to the // list of options on the first commit - QString options = QString("database \"%1\"\nbranch \"%2\"\n") - .arg(MonotoneDelegate::getDatabaseFilePath(this)) + QString options = + QString("database \"%1\"\n" + "branch \"%2\"\n") + .arg(databaseFile) .arg(selectedBranch); + I(optfile.write(options.toLatin1())); optfile.close(); - + // change back to the root dir I(rootDir.cdUp()); - + return FileExporter::run(entries); } ============================================================ --- src/monotone/WorkspaceCreator.h 89f2bc9696212d97fc99e806388542b8b084a2a1 +++ src/monotone/WorkspaceCreator.h f30353cccd83fcb6eb845ea9d9f86531daf9cc68 @@ -27,8 +27,7 @@ public: { Q_OBJECT public: - WorkspaceCreator(QObject *, QString, QDir); - ~WorkspaceCreator(); + WorkspaceCreator(const DatabaseFile &, const QString &, const QDir &); bool run(); };