# # # patch "src/model/Monotone.cpp" # from [7c91e5b0a642709420e995dff3e77a0b21aee287] # to [7684a9da94e6931dc383a4480eddcc730166c582] # # patch "src/model/Monotone.h" # from [4ae3921266ba3a21106d05ecc88ce24a924038c0] # to [58a6fbe73b90d4163d86710cc2ae1dda832ed2de] # ============================================================ --- src/model/Monotone.cpp 7c91e5b0a642709420e995dff3e77a0b21aee287 +++ src/model/Monotone.cpp 7684a9da94e6931dc383a4480eddcc730166c582 @@ -1,12 +1,15 @@ #include "Monotone.h" +#include +#include + Monotone* Monotone::instance = 0; -Monotone::Monotone() : Q3Process() +Monotone::Monotone() : QProcess() { isRunning = false; - output = new QStringList(); + output = new QStringList(); } Monotone::~Monotone() @@ -29,20 +32,26 @@ bool Monotone::openConnection(QDir *workingDirectory) { - // versions before 0.26pre3 are not supported - // in that version monotone changed its binary and + // versions before 0.26pre3 are not supported. + // In that version monotone changed its binary and // workspace folder names to mtn and _MTN - addArgument("mtn"); - addArgument("automate"); - addArgument("stdio"); - setWorkingDirectory(*workingDirectory); + setWorkingDirectory(workingDirectory->absolutePath()); + connect( - this, SIGNAL(readyReadStdout()), + this, SIGNAL(readyReadStandardOutput()), this, SLOT(parseLineFromStdout()) ); - if (!start()) + QStringList args; + args << "automate"; + args << "stdio"; + + // Start up monotone's executable 'mtn' + start("mtn", args); + + // Is montone started up inside 15 seconds? + if (!waitForStarted(15000)) { return false; } @@ -77,7 +86,14 @@ // finally, the cmd ends with "e\n" finalCmd += "e\n"; qDebug("Final command: %s", finalCmd.latin1()); - writeToStdin(finalCmd); + + // QProcess in QT4 dosen't have a writeToStdin(). + // So we need the following QTextStream + QTextStream streamStdIn(this); + + // Write our finalCmd to mtn's StdIn + streamStdIn << finalCmd; + return true; } @@ -86,7 +102,8 @@ QByteArray byteArray; // read all data from stdin - byteArray = readStdout(); + //byteArray = readStdout(); + byteArray = readAllStandardOutput(); QString temp(byteArray); // splits the input into lines ============================================================ --- src/model/Monotone.h 4ae3921266ba3a21106d05ecc88ce24a924038c0 +++ src/model/Monotone.h 58a6fbe73b90d4163d86710cc2ae1dda832ed2de @@ -1,29 +1,42 @@ #ifndef MONOTONE_H #define MONOTONE_H -#include -#include -#include -class Monotone : public Q3Process +// +// Forward class declarations +// +class QDir; + +//#include +// +// Lib Includes +// +#include + + +class Monotone : public QProcess { Q_OBJECT + public: static Monotone* singleton(QDir*); ~Monotone(); bool triggerCommand(QString cmd); QStringList* getOutput(); + protected: Monotone(); + private: bool openConnection(QDir*); QStringList *output; bool isRunning; - static Monotone* instance; + private slots: void parseLineFromStdout(); + signals: void commandFinished(int returnCode); };