diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index aadafe0b8fa00ec422ce1d16d615ec63b49cb5aa..21403256d296dfb32188b5792ed17abb8fca88d9 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -248,7 +248,7 @@ private: bool logCommandToWindow = true); // Synchronous git execution using Utils::SynchronousProcess, with - // log windows updating. + // log windows updating (using VCSBasePlugin::runVCS with flags). inline Utils::SynchronousProcessResponse synchronousGit(const QString &workingDirectory, const QStringList &arguments, unsigned flags = 0, QTextCodec *outputCodec = 0); diff --git a/src/plugins/mercurial/mercurialclient.cpp b/src/plugins/mercurial/mercurialclient.cpp index a7bf38b09fb522f5ecb24b1d414e96c2dec982fc..ff1cd160d9c76e6326ff7789c8b8d3b5acd1dd51 100644 --- a/src/plugins/mercurial/mercurialclient.cpp +++ b/src/plugins/mercurial/mercurialclient.cpp @@ -84,7 +84,7 @@ bool MercurialClient::add(const QString &workingDir, const QString &filename) QStringList args; args << QLatin1String("add") << filename; QByteArray stdOut; - return executeHgSynchronously(workingDir, args, &stdOut); + return executeHgFullySynchronously(workingDir, args, &stdOut); } bool MercurialClient::remove(const QString &workingDir, const QString &filename) @@ -92,7 +92,7 @@ bool MercurialClient::remove(const QString &workingDir, const QString &filename) QStringList args; args << QLatin1String("remove") << filename; QByteArray stdOut; - return executeHgSynchronously(workingDir, args, &stdOut); + return executeHgFullySynchronously(workingDir, args, &stdOut); } bool MercurialClient::move(const QString &workingDir, const QString &from, const QString &to) @@ -100,7 +100,7 @@ bool MercurialClient::move(const QString &workingDir, const QString &from, const QStringList args; args << QLatin1String("rename") << from << to; QByteArray stdOut; - return executeHgSynchronously(workingDir, args, &stdOut); + return executeHgFullySynchronously(workingDir, args, &stdOut); } bool MercurialClient::manifestSync(const QString &repository, const QString &relativeFilename) @@ -109,7 +109,7 @@ bool MercurialClient::manifestSync(const QString &repository, const QString &rel const QStringList args(QLatin1String("manifest")); QByteArray output; - executeHgSynchronously(repository, args, &output); + executeHgFullySynchronously(repository, args, &output); const QDir repositoryDir(repository); const QFileInfo needle = QFileInfo(repositoryDir, relativeFilename); @@ -122,7 +122,21 @@ bool MercurialClient::manifestSync(const QString &repository, const QString &rel return false; } -bool MercurialClient::executeHgSynchronously(const QString &workingDir, +Utils::SynchronousProcessResponse + MercurialClient::executeHgSynchronously(const QString &workingDirectory, + const QStringList &hgArgs, + unsigned flags, + QTextCodec *outputCodec) +{ + const MercurialSettings &settings = MercurialPlugin::instance()->settings(); + const QString binary = settings.binary(); + const QStringList arguments = settings.standardArguments() + hgArgs; + return VCSBase::VCSBasePlugin::runVCS(workingDirectory, binary, arguments, + settings.timeoutMilliSeconds(), + flags, outputCodec); +} + +bool MercurialClient::executeHgFullySynchronously(const QString &workingDir, const QStringList &args, QByteArray *output) const { @@ -163,7 +177,7 @@ bool MercurialClient::executeHgSynchronously(const QString &workingDir, QString MercurialClient::branchQuerySync(const QString &repositoryRoot) { QByteArray output; - if (executeHgSynchronously(repositoryRoot, QStringList(QLatin1String("branch")), &output)) + if (executeHgFullySynchronously(repositoryRoot, QStringList(QLatin1String("branch")), &output)) return QTextCodec::codecForLocale()->toUnicode(output).trimmed(); return QLatin1String("Unknown Branch"); @@ -192,7 +206,7 @@ bool MercurialClient::parentRevisionsSync(const QString &workingDirectory, if (!file.isEmpty()) args << file; QByteArray outputData; - if (!executeHgSynchronously(workingDirectory, args, &outputData)) + if (!executeHgFullySynchronously(workingDirectory, args, &outputData)) return false; QString output = QString::fromLocal8Bit(outputData); output.remove(QLatin1Char('\r')); @@ -236,7 +250,7 @@ bool MercurialClient::shortDescriptionSync(const QString &workingDirectory, if (!format.isEmpty()) args << QLatin1String("--template") << format; QByteArray outputData; - if (!executeHgSynchronously(workingDirectory, args, &outputData)) + if (!executeHgFullySynchronously(workingDirectory, args, &outputData)) return false; *description = QString::fromLocal8Bit(outputData); description->remove(QLatin1Char('\r')); @@ -380,7 +394,7 @@ bool MercurialClient::createRepositorySync(const QString &workingDirectory) { const QStringList args(QLatin1String("init")); QByteArray outputData; - if (!executeHgSynchronously(workingDirectory, args, &outputData)) + if (!executeHgFullySynchronously(workingDirectory, args, &outputData)) return false; QString output = QString::fromLocal8Bit(outputData); output.remove(QLatin1Char('\r')); @@ -451,28 +465,33 @@ void MercurialClient::import(const QString &repositoryRoot, const QStringList &f enqueueJob(job); } -void MercurialClient::pull(const QString &repositoryRoot, const QString &repository) +bool MercurialClient::pullSync(const QString &repositoryRoot, const QString &repository) { QStringList args(QLatin1String("pull")); if (!repository.isEmpty()) args.append(repository); - QSharedPointer<HgTask> job(new HgTask(repositoryRoot, args, false, QVariant(repositoryRoot))); - // Suppress SSH prompting - job->setUnixTerminalDisabled(VCSBase::VCSBasePlugin::isSshPromptConfigured()); - connect(job.data(), SIGNAL(succeeded(QVariant)), this, SIGNAL(changed(QVariant)), Qt::QueuedConnection); - enqueueJob(job); + // Disable UNIX terminals to suppress SSH prompting. + const unsigned flags = VCSBase::VCSBasePlugin::SshPasswordPrompt|VCSBase::VCSBasePlugin::ShowStdOutInLogWindow + |VCSBase::VCSBasePlugin::ShowSuccessMessage; + const Utils::SynchronousProcessResponse resp = + executeHgSynchronously(repositoryRoot, args, flags); + const bool ok = resp.result == Utils::SynchronousProcessResponse::Finished; + if (ok) + emit changed(QVariant(repositoryRoot)); + return ok; } -void MercurialClient::push(const QString &repositoryRoot, const QString &repository) +bool MercurialClient::pushSync(const QString &repositoryRoot, const QString &repository) { QStringList args(QLatin1String("push")); if (!repository.isEmpty()) args.append(repository); - - QSharedPointer<HgTask> job(new HgTask(repositoryRoot, args, false)); - // Suppress SSH prompting - job->setUnixTerminalDisabled(VCSBase::VCSBasePlugin::isSshPromptConfigured()); - enqueueJob(job); + // Disable UNIX terminals to suppress SSH prompting. + const unsigned flags = VCSBase::VCSBasePlugin::SshPasswordPrompt|VCSBase::VCSBasePlugin::ShowStdOutInLogWindow + |VCSBase::VCSBasePlugin::ShowSuccessMessage; + const Utils::SynchronousProcessResponse resp = + executeHgSynchronously(repositoryRoot, args, flags); + return resp.result == Utils::SynchronousProcessResponse::Finished; } void MercurialClient::incoming(const QString &repositoryRoot, const QString &repository) diff --git a/src/plugins/mercurial/mercurialclient.h b/src/plugins/mercurial/mercurialclient.h index 215b24f79b0e8116007a559266b2017e38a74fad..f6ea3a3d28b47db515cdd7330bf8e4db5309ed12 100644 --- a/src/plugins/mercurial/mercurialclient.h +++ b/src/plugins/mercurial/mercurialclient.h @@ -48,6 +48,10 @@ namespace VCSBase{ class VCSBaseEditor; } +namespace Utils { + struct SynchronousProcessResponse; +} + namespace Mercurial { namespace Internal { @@ -81,8 +85,8 @@ public: void log(const QString &workingDir, const QStringList &files = QStringList(), bool enableAnnotationContextMenu = false); void import(const QString &repositoryRoot, const QStringList &files); - void pull(const QString &repositoryRoot, const QString &repository = QString()); - void push(const QString &repositoryRoot, const QString &repository = QString()); + bool pullSync(const QString &repositoryRoot, const QString &repository = QString()); + bool pushSync(const QString &repositoryRoot, const QString &repository = QString()); void incoming(const QString &repositoryRoot, const QString &repository = QString()); void outgoing(const QString &repositoryRoot); void status(const QString &workingDir, const QString &file = QString()); @@ -113,9 +117,16 @@ private slots: void slotAnnotateRevisionRequested(const QString &source, QString change, int lineNumber); private: - bool executeHgSynchronously(const QString &workingDir, - const QStringList &args, - QByteArray *output) const; + // Fully synchronous git execution (QProcess-based). + bool executeHgFullySynchronously(const QString &workingDir, + const QStringList &args, + QByteArray *output) const; + // Synchronous hg execution using Utils::SynchronousProcess, with + // log windows updating (using VCSBasePlugin::runVCS with flags). + inline Utils::SynchronousProcessResponse + executeHgSynchronously(const QString &workingDir, const QStringList &args, + unsigned flags = 0, QTextCodec *outputCodec = 0); + void enqueueJob(const QSharedPointer<HgTask> &); void revert(const QString &workingDir, const QString &argument, const QString &revision, const QVariant &cookie); diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index 958e5ae058d9f6fbe1b02c348439968dd2a6b178..25844685702242878736d7b40a6ef4dbd5272bd3 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -470,7 +470,7 @@ void MercurialPlugin::pull() dialog.setWindowTitle(tr("Pull Source")); if (dialog.exec() != QDialog::Accepted) return; - m_client->pull(state.topLevel(), dialog.getRepositoryString()); + m_client->pullSync(state.topLevel(), dialog.getRepositoryString()); } void MercurialPlugin::push() @@ -482,7 +482,7 @@ void MercurialPlugin::push() dialog.setWindowTitle(tr("Push Destination")); if (dialog.exec() != QDialog::Accepted) return; - m_client->push(state.topLevel(), dialog.getRepositoryString()); + m_client->pushSync(state.topLevel(), dialog.getRepositoryString()); } void MercurialPlugin::update()