# # # patch "src/monotone/FileExporter.cpp" # from [fe0cd260a3d9c57b64a3c0c1e2de197fe77b531f] # to [6f9e946c9deac80196593c45918b5f7ea7fbf7ea] # # patch "src/monotone/FileExporter.h" # from [cb8015d03f0099ae8b43e538fc6dc4c8b2904811] # to [c563d3d55236f6f05c5301b9e27e15e63e34e60a] # # patch "src/monotone/WorkspaceCommitter.h" # from [79db6a761846ccce23232d750014ec74b9134746] # to [19ad4daf22ac0416f00057e20524086a4d95b0a7] # ============================================================ --- src/monotone/FileExporter.cpp fe0cd260a3d9c57b64a3c0c1e2de197fe77b531f +++ src/monotone/FileExporter.cpp 6f9e946c9deac80196593c45918b5f7ea7fbf7ea @@ -17,23 +17,25 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "FileExporter.h" -#include "MonotoneDelegate.h" -#include "Guitone.h" +#include "MonotoneUtil.h" +// +// FIXME: remove these two dependencies: +// a) refactor this class into a QThread +// b) use signals to let the GUI thread now the state of the action +// +#include "Guitone.h" #include -FileExporter::FileExporter(QObject * parent, QString rev, QDir dir) - : QObject(parent), revision(rev) +FileExporter::FileExporter(const DatabaseFile & database, const QString & rev, const QDir & dir) + : QObject(0), databaseFile(database), rootDir(dir), revision(rev) { - rootDir = dir; I(rootDir.exists()); } -FileExporter::~FileExporter() -{ -} +FileExporter::~FileExporter() {} bool FileExporter::run(const FileEntryList & entries) { @@ -52,7 +54,7 @@ bool FileExporter::run(const FileEntryLi cleanup = true; break; } - + APP->processEvents(); if (progress.wasCanceled()) { @@ -61,7 +63,7 @@ bool FileExporter::run(const FileEntryLi } progress.setValue(i + 1); } - + if (cleanup) { D("TODO: clean up written files"); @@ -80,31 +82,34 @@ bool FileExporter::exportFile(const File } return true; } - - Monotone * mtn = MTN(this); - - int commandNumber; - if (!mtn->executeCommand( - QStringList() << "get_file_of" << entry.path, - QStringList() << "r" << revision, commandNumber) || - mtn->getReturnCode(commandNumber) > 0) + + MonotoneTask out = MonotoneUtil::runSynchronousDatabaseTask( + databaseFile, + MonotoneTask( + QStringList() << "get_file_of" << entry.path, + QStringList() << "r" << revision + ) + ); + if (!out.isFinished()) F("task aborted"); + + if (out.getReturnCode() > 0) { - C("Cannot execute get_file_of"); + C(QString("get_file_of failed: %1").arg(out.getOutputUtf8())); return false; } - + QFile file(rootDir.filePath(entry.path)); if (file.exists()) file.remove(); - + if (!file.open(QIODevice::WriteOnly)) { C("Can't open file for writing"); return false; } - - I(file.write(mtn->getRawData(commandNumber))); + + I(file.write(out.getOutput())); file.close(); - + return true; } ============================================================ --- src/monotone/FileExporter.h cb8015d03f0099ae8b43e538fc6dc4c8b2904811 +++ src/monotone/FileExporter.h c563d3d55236f6f05c5301b9e27e15e63e34e60a @@ -29,13 +29,14 @@ public: { Q_OBJECT public: - FileExporter(QObject *, QString, QDir); + FileExporter(const DatabaseFile &, const QString &, const QDir &); ~FileExporter(); virtual bool run(const FileEntryList &); protected: bool exportFile(const FileEntry &); - + + DatabaseFile databaseFile; QDir rootDir; QString revision; }; ============================================================ --- src/monotone/WorkspaceCommitter.h 79db6a761846ccce23232d750014ec74b9134746 +++ src/monotone/WorkspaceCommitter.h 19ad4daf22ac0416f00057e20524086a4d95b0a7 @@ -28,7 +28,7 @@ // // TODO: we should make this class working asynchronously and work -// nicely together with QProgressDialog +// nicely together with QProgressDialog (i.e. subclass it from QThread) // class WorkspaceCommitter : public QObject {