Commit a6eefb1a authored by Nikita Baryshnikov's avatar Nikita Baryshnikov

Mercurial: Run update after pull

Get output of pull command and emit signal if update/merge is needed. On
update show update dialog.

Change-Id: I814f76daf3d89d0bd9485ed42a224b6b5d78bcb3
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent ee266048
......@@ -130,6 +130,29 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
}
}
bool MercurialClient::synchronousPull(const QString &workingDir, const QString &srcLocation, const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(PullCommand) << extraOptions << srcLocation;
// Disable UNIX terminals to suppress SSH prompting
const unsigned flags =
VcsBase::VcsBasePlugin::SshPasswordPrompt
| VcsBase::VcsBasePlugin::ShowStdOutInLogWindow
| VcsBase::VcsBasePlugin::ShowSuccessMessage;
const QString binary = settings()->binaryPath();
const int timeoutSec = settings()->value(settings()->timeoutKey).toInt();
// cause mercurial doesn`t understand LANG
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert(QLatin1String("LANGUAGE"), QLatin1String("C"));
const Utils::SynchronousProcessResponse resp = VcsBase::VcsBasePlugin::runVcs(
workingDir, binary, args, timeoutSec * 1000, env, flags);
const bool ok = resp.result == Utils::SynchronousProcessResponse::Finished;
parsePullOutput(resp.stdOut.trimmed());
return ok;
}
QString MercurialClient::branchQuerySync(const QString &repositoryRoot)
{
QByteArray output;
......@@ -377,6 +400,20 @@ MercurialClient::StatusItem MercurialClient::parseStatusLine(const QString &line
return item;
}
void MercurialClient::parsePullOutput(const QString &output)
{
if (output.endsWith(QLatin1String("no changes found")))
return;
if (output.endsWith(QLatin1String("(run 'hg update' to get a working copy)"))) {
emit needUpdate();
return;
}
if (output.endsWith(QLatin1String("'hg merge' to merge)")))
emit needMerge();
}
// Collect all parameters required for a diff to be able to associate them
// with a diff editor and re-run the diff with parameters.
struct MercurialDiffParameters
......
......@@ -49,6 +49,9 @@ public:
const QString &srcLocation,
const QString &dstLocation,
const QStringList &extraOptions = QStringList());
bool synchronousPull(const QString &workingDir,
const QString &srcLocation,
const QStringList &extraOptions = QStringList());
bool manifestSync(const QString &repository, const QString &filename);
QString branchQuerySync(const QString &repositoryRoot);
QStringList parentRevisionsSync(const QString &workingDirectory,
......@@ -86,6 +89,13 @@ protected:
const QStringList &files,
const QStringList &extraOptions);
StatusItem parseStatusLine(const QString &line) const;
signals:
void needUpdate();
void needMerge();
private:
void parsePullOutput(const QString &output);
};
} //namespace Internal
......
......@@ -140,6 +140,7 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
mercurialSettings.readSettings(core->settings());
connect(m_client, SIGNAL(changed(QVariant)), versionControl(), SLOT(changed(QVariant)));
connect(m_client, SIGNAL(needUpdate()), this, SLOT(update()));
static const char *describeSlot = SLOT(view(QString,QString));
const int editorCount = sizeof(editorParameters)/sizeof(editorParameters[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment