# # # patch "guitone.pro" # from [2837f1d27731f4f24199c1c1c35ccce0d19842a9] # to [a6aadb9e25b49eb21cc71c8bd01498957aaa2f33] # # patch "src/monotone/MonotoneThread.cpp" # from [8bb311182c4678c7a98338bee71182c7e6d96c6d] # to [6fb78ad666d16cb7e6873737be59984fc8222c04] # # patch "src/util/StdioParser.cpp" # from [d4cba87dc4415fc989015ccadcc95ba28b3e50ae] # to [af29c663982c21bce620c3358388795f65947524] # # patch "src/util/StdioParser.h" # from [65096f8fbc2f50c1edfbd4af401c6cdfb9ffbb1a] # to [0621c85fc2f5c7193bde542d02d209794b750e84] # ============================================================ --- guitone.pro 2837f1d27731f4f24199c1c1c35ccce0d19842a9 +++ guitone.pro a6aadb9e25b49eb21cc71c8bd01498957aaa2f33 @@ -5,8 +5,8 @@ GUITONE_REVISION = "" # this is automatically determined if we're executing qmake in a monotone # workspace, for source releases however we need to set it explicitely GUITONE_REVISION = "" -MIN_MTN_INT_VERSION = "11.0" -MAX_MTN_INT_VERSION = "11.0" +MIN_MTN_INT_VERSION = "12.0" +MAX_MTN_INT_VERSION = "12.0" APPCAST_URL = "https://guitone.thomaskeller.biz/web/appcast.xml" # ============================================================ --- src/monotone/MonotoneThread.cpp 8bb311182c4678c7a98338bee71182c7e6d96c6d +++ src/monotone/MonotoneThread.cpp 6fb78ad666d16cb7e6873737be59984fc8222c04 @@ -284,6 +284,7 @@ void MonotoneThread::run() return; } + D(process->readAllStandardOutput()); // waitForReadyRead returns false, if there are no data available // (stdio shouldn't return anything on either channel if everything is ok) // or the time is up @@ -309,9 +310,39 @@ void MonotoneThread::run() QByteArray output; bool processingTask = false; + bool headersProcessed = false; while (!doAbort) { + if (!headersProcessed) + { + typedef QPair HeaderPair; + QList headers; + + if (process->bytesAvailable() == 0 && + !process->waitForReadyRead(500)) + continue; + + try + { + QByteArray output = process->readAllStandardOutput(); + headers = StdioParser::parseAndCheckHeaders(output); + } + catch (GuitoneException error) + { + cleanup(process); + emit aborted(threadNumber, QProcess::UnknownError, error); + return; + } + + foreach (HeaderPair pair, headers) + { + L(QString("stdio headers: %1: %2") + .arg(QString(pair.first)).arg(QString(pair.second))); + } + headersProcessed = true; + } + // send the thread to sleep if there are no tasks to process lock.lock(); if (queue.size() == 0) ============================================================ --- src/util/StdioParser.cpp d4cba87dc4415fc989015ccadcc95ba28b3e50ae +++ src/util/StdioParser.cpp af29c663982c21bce620c3358388795f65947524 @@ -19,17 +19,17 @@ #include "StdioParser.h" #include "vocab.h" +const int StdioParser::STDIO_VERSION; + StdioParser::StdioParser(const QByteArray & input) : AbstractParser(input) {} bool StdioParser::parse() { if (getLeftBytesCount() == 0) return false; - // chunk format: :::: + // chunk format: ::: commandNumber = getNumber(); I(getNext() == ':'); - errorCode = getNumber(); - I(getNext() == ':'); chunkType = getNext(); I(getNext() == ':'); chunkSize = getNumber(); @@ -41,7 +41,7 @@ bool StdioParser::parse() return false; } - if (chunkType == 'm' || chunkType == 'l') + if (chunkType == 'm') { payload = getNext(chunkSize); } @@ -51,7 +51,12 @@ bool StdioParser::parse() parseTicks(getNext(chunkSize)); } else + if (chunkType == 'l') { + errorCode = getNumber(); + } + else + { oobMessages.push_back(qMakePair(chunkType, getNext(chunkSize))); } @@ -134,3 +139,29 @@ void StdioParser::parseTicks(const QByte } } +QList > StdioParser::parseAndCheckHeaders(const QByteArray & in) +{ + ByteArrayList headerLines = in.trimmed().split('\n'); + I(headerLines.count() > 0); + + QList > out; + + foreach (QByteArray line, headerLines) + { + int sep = line.indexOf(": "); + I(sep >= 1); + QByteArray header = line.left(sep); + QByteArray value = line.mid(sep + 2); + + if (header == "format-version" && + StdioParser::STDIO_VERSION != value.toInt()) + { + throw GuitoneException("wrong stdio version, wanted %1, got %2") + .arg(StdioParser::STDIO_VERSION).arg(value.toInt()); + } + out.append(qMakePair(header, value)); + } + + return out; +} + ============================================================ --- src/util/StdioParser.h 65096f8fbc2f50c1edfbd4af401c6cdfb9ffbb1a +++ src/util/StdioParser.h 0621c85fc2f5c7193bde542d02d209794b750e84 @@ -36,6 +36,10 @@ public: inline TickerMap getTickers() const { return tickers; } inline QList getOutOfBandMessages() const { return oobMessages; } + static const int STDIO_VERSION = 2; + + static QList > parseAndCheckHeaders(const QByteArray &); + private: int getNumber(); void parseTicks(const QByteArray &);