forked from qt-creator/qt-creator
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: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -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)
|
QString MercurialClient::branchQuerySync(const QString &repositoryRoot)
|
||||||
{
|
{
|
||||||
QByteArray output;
|
QByteArray output;
|
||||||
@@ -377,6 +400,20 @@ MercurialClient::StatusItem MercurialClient::parseStatusLine(const QString &line
|
|||||||
return item;
|
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
|
// Collect all parameters required for a diff to be able to associate them
|
||||||
// with a diff editor and re-run the diff with parameters.
|
// with a diff editor and re-run the diff with parameters.
|
||||||
struct MercurialDiffParameters
|
struct MercurialDiffParameters
|
||||||
|
@@ -49,6 +49,9 @@ public:
|
|||||||
const QString &srcLocation,
|
const QString &srcLocation,
|
||||||
const QString &dstLocation,
|
const QString &dstLocation,
|
||||||
const QStringList &extraOptions = QStringList());
|
const QStringList &extraOptions = QStringList());
|
||||||
|
bool synchronousPull(const QString &workingDir,
|
||||||
|
const QString &srcLocation,
|
||||||
|
const QStringList &extraOptions = QStringList());
|
||||||
bool manifestSync(const QString &repository, const QString &filename);
|
bool manifestSync(const QString &repository, const QString &filename);
|
||||||
QString branchQuerySync(const QString &repositoryRoot);
|
QString branchQuerySync(const QString &repositoryRoot);
|
||||||
QStringList parentRevisionsSync(const QString &workingDirectory,
|
QStringList parentRevisionsSync(const QString &workingDirectory,
|
||||||
@@ -86,6 +89,13 @@ protected:
|
|||||||
const QStringList &files,
|
const QStringList &files,
|
||||||
const QStringList &extraOptions);
|
const QStringList &extraOptions);
|
||||||
StatusItem parseStatusLine(const QString &line) const;
|
StatusItem parseStatusLine(const QString &line) const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void needUpdate();
|
||||||
|
void needMerge();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void parsePullOutput(const QString &output);
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace Internal
|
} //namespace Internal
|
||||||
|
@@ -140,6 +140,7 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
|
|||||||
mercurialSettings.readSettings(core->settings());
|
mercurialSettings.readSettings(core->settings());
|
||||||
|
|
||||||
connect(m_client, SIGNAL(changed(QVariant)), versionControl(), SLOT(changed(QVariant)));
|
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));
|
static const char *describeSlot = SLOT(view(QString,QString));
|
||||||
const int editorCount = sizeof(editorParameters)/sizeof(editorParameters[0]);
|
const int editorCount = sizeof(editorParameters)/sizeof(editorParameters[0]);
|
||||||
|
Reference in New Issue
Block a user