summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@theqtcompany.com>2015-04-10 15:23:20 +0200
committerTobias Hunger <tobias.hunger@theqtcompany.com>2015-04-13 10:48:01 +0000
commit7c083eadee877212ae64083e73a8939be7bc9e31 (patch)
tree8f6920de310cd44f5d8e834e49061cc1b300ac10
parent60f5372b6793f33a711b60113087910136d21b14 (diff)
downloadqt-creator-7c083eadee877212ae64083e73a8939be7bc9e31.tar.gz
Vcs: Make VcsBaseClient return stderr on fullySynchronous execution
Change-Id: I7a72a2f865148d7cf375897ec944a45f4b440818 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
-rw-r--r--src/plugins/git/gitclient.cpp20
-rw-r--r--src/plugins/mercurial/mercurialclient.cpp2
-rw-r--r--src/plugins/subversion/subversionclient.cpp2
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.cpp35
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.h7
5 files changed, 35 insertions, 31 deletions
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 329995df64..41791a7040 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -540,24 +540,6 @@ IEditor *locateEditor(const char *property, const QString &entry)
return 0;
}
-// Return converted command output, remove '\r' read on Windows
-static inline QString commandOutputFromLocal8Bit(const QByteArray &a)
-{
- return SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(a));
-}
-
-// Return converted command output split into lines
-static inline QStringList commandOutputLinesFromLocal8Bit(const QByteArray &a)
-{
- QString output = commandOutputFromLocal8Bit(a);
- const QChar newLine = QLatin1Char('\n');
- if (output.endsWith(newLine))
- output.truncate(output.size() - 1);
- if (output.isEmpty())
- return QStringList();
- return output.split(newLine);
-}
-
static inline QString msgRepositoryNotFound(const QString &dir)
{
return GitClient::tr("Cannot determine the repository for \"%1\".").arg(dir);
@@ -594,7 +576,7 @@ static inline void msgCannotRun(const QStringList &args, const QString &workingD
const QString message = GitClient::tr("Cannot run \"%1 %2\" in \"%2\": %3")
.arg(QLatin1String("git ") + args.join(QLatin1Char(' ')),
QDir::toNativeSeparators(workingDirectory),
- commandOutputFromLocal8Bit(error));
+ GitClient::commandOutputFromLocal8Bit(error));
msgCannotRun(message, errorMessage);
}
diff --git a/src/plugins/mercurial/mercurialclient.cpp b/src/plugins/mercurial/mercurialclient.cpp
index 82ed3dc995..f53c816fe8 100644
--- a/src/plugins/mercurial/mercurialclient.cpp
+++ b/src/plugins/mercurial/mercurialclient.cpp
@@ -244,7 +244,7 @@ QString MercurialClient::shortDescriptionSync(const QString &workingDirectory,
QByteArray outputData;
if (!vcsFullySynchronousExec(workingDirectory, args, &outputData))
return revision;
- description = SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(outputData));
+ description = commandOutputFromLocal8Bit(outputData);
if (description.endsWith(QLatin1Char('\n')))
description.truncate(description.size() - 1);
return description;
diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp
index fa284ec7ee..526f2bd21c 100644
--- a/src/plugins/subversion/subversionclient.cpp
+++ b/src/plugins/subversion/subversionclient.cpp
@@ -150,7 +150,7 @@ QString SubversionClient::synchronousTopic(const QString &repository)
const QString revisionString = QLatin1String("Revision: ");
// stdOut is ASCII only (at least in those areas we care about).
- QString output = SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(stdOut));
+ QString output = commandOutputFromLocal8Bit(stdOut);
foreach (const QString &line, output.split(QLatin1Char('\n'))) {
if (line.startsWith(revisionString))
return QString::fromLatin1("r") + line.mid(revisionString.count());
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp
index 277e264f2e..042037475c 100644
--- a/src/plugins/vcsbase/vcsbaseclient.cpp
+++ b/src/plugins/vcsbase/vcsbaseclient.cpp
@@ -170,6 +170,22 @@ QProcessEnvironment VcsBaseClientImpl::processEnvironment() const
return environment;
}
+QString VcsBaseClientImpl::commandOutputFromLocal8Bit(const QByteArray &a)
+{
+ return Utils::SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(a));
+}
+
+QStringList VcsBaseClientImpl::commandOutputLinesFromLocal8Bit(const QByteArray &a)
+{
+ QString output = commandOutputFromLocal8Bit(a);
+ const QChar newLine = QLatin1Char('\n');
+ if (output.endsWith(newLine))
+ output.truncate(output.size() - 1);
+ if (output.isEmpty())
+ return QStringList();
+ return output.split(newLine);
+}
+
void VcsBaseClientImpl::resetCachedVcsInfo(const QString &workingDir)
{
Core::VcsManager::resetVersionControlForDirectory(workingDir);
@@ -288,8 +304,7 @@ bool VcsBaseClient::synchronousCreateRepository(const QString &workingDirectory,
QByteArray outputData;
if (!vcsFullySynchronousExec(workingDirectory, args, &outputData))
return false;
- VcsOutputWindow::append(
- Utils::SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(outputData)));
+ VcsOutputWindow::append(commandOutputFromLocal8Bit(outputData));
resetCachedVcsInfo(workingDirectory);
@@ -373,13 +388,15 @@ bool VcsBaseClient::synchronousPush(const QString &workingDir,
bool VcsBaseClient::vcsFullySynchronousExec(const QString &workingDir,
const QStringList &args,
- QByteArray *output) const
-{
- QByteArray errorData;
- QScopedPointer<VcsCommand> command = createCommand(workingDir);
- bool result = command->runFullySynchronous(args, vcsTimeoutS(), output, &errorData);
- if (!errorData.isEmpty())
- VcsOutputWindow::appendError(QString::fromLocal8Bit(errorData));
+ QByteArray *outputData,
+ QByteArray *errorData) const
+{
+ QByteArray internalErrorData;
+ QScopedPointer<VcsCommand> command(createCommand(workingDir));
+ bool result = command->runFullySynchronous(args, vcsTimeoutS(), outputData,
+ errorData ? errorData : &internalErrorData);
+ if (!internalErrorData.isEmpty())
+ VcsOutputWindow::appendError(commandOutputFromLocal8Bit(internalErrorData));
return result;
}
diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h
index 1a70f7cfa1..91d812db4d 100644
--- a/src/plugins/vcsbase/vcsbaseclient.h
+++ b/src/plugins/vcsbase/vcsbaseclient.h
@@ -100,6 +100,11 @@ public:
const QString &revision = QString(), int lineNumber = -1,
const QStringList &extraOptions = QStringList()) = 0;
+ // Return converted command output, remove '\r' read on Windows
+ static QString commandOutputFromLocal8Bit(const QByteArray &a);
+ // Return converted command output split into lines
+ static QStringList commandOutputLinesFromLocal8Bit(const QByteArray &a);
+
protected:
void resetCachedVcsInfo(const QString &workingDir);
virtual void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
@@ -217,7 +222,7 @@ protected:
QString vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const;
// Fully synchronous VCS execution (QProcess-based)
bool vcsFullySynchronousExec(const QString &workingDir, const QStringList &args,
- QByteArray *output) const;
+ QByteArray *outputData, QByteArray *errorData = 0) const;
// Synchronous VCS execution using Utils::SynchronousProcess, with
// log windows updating (using VcsBasePlugin::runVcs with flags)
Utils::SynchronousProcessResponse vcsSynchronousExec(const QString &workingDir,