Commit 0d9af123 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Do not show empty differences when the user asks for a VCS comparison.

Instead show an ugly message box.
parent 76ab0d66
......@@ -63,6 +63,12 @@ VcsDiff::VcsDiff( const VcsDiff& rhs )
d->baseDiff = rhs.d->baseDiff;
}
bool VcsDiff::isEmpty() const
{
return d->diff.isEmpty() && d->leftBinaries.isEmpty() && d->rightBinaries.isEmpty()
&& d->leftTexts.isEmpty() && d->rightTexts.isEmpty();
}
VcsDiff::Type VcsDiff::type() const
{
return d->type;
......
......@@ -121,6 +121,9 @@ public:
void setType( Type );
void setContentType( Content );
VcsDiff& operator=( const VcsDiff& rhs);
/** @returns whether there are not changes on the diff */
bool isEmpty() const;
private:
class VcsDiffPrivate* const d;
};
......
......@@ -255,6 +255,15 @@ void VcsPluginHelper::diffToHead()
d->plugin->core()->runController()->registerJob(job);
}
QStringList locationListToString(const QList<VcsLocation>& locations)
{
QStringList ret;
foreach(const VcsLocation& loc, locations) {
ret.append(loc.localUrl().prettyUrl());
}
return ret;
}
void VcsPluginHelper::diffJobFinished(KJob* job)
{
KDevelop::VcsJob* vcsjob = dynamic_cast<KDevelop::VcsJob*>(job);
......@@ -263,7 +272,14 @@ void VcsPluginHelper::diffJobFinished(KJob* job)
if (vcsjob) {
if (vcsjob->status() == KDevelop::VcsJob::JobSucceeded) {
KDevelop::VcsDiff d = vcsjob->fetchResults().value<KDevelop::VcsDiff>();
showVcsDiff(new VCSDiffPatchSource(d));
if(d.isEmpty())
KMessageBox::error(ICore::self()->uiController()->activeMainWindow(),
i18n("Cannot show the difference because there were none."),
i18n("VCS support"));
else {
VCSDiffPatchSource* patch=new VCSDiffPatchSource(d);
showVcsDiff(patch);
}
} else {
KMessageBox::error(ICore::self()->uiController()->activeMainWindow(), vcsjob->errorString(), i18n("Unable to get difference."));
}
......
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