[kdevplatform/5.1] /: patchreview: allow updating branch diffs
Kevin Funk
kfunk at kde.org
Mon Sep 11 08:21:37 UTC 2017
On Sunday, 10 September 2017 02:28:51 CEST R. J. V. Bertin wrote:
> Git commit 355f7f7d3364bfc7989f9359595175e8c0262379 by R.J.V. Bertin.
> Committed on 10/09/2017 at 00:26.
> Pushed by rjvbb into branch '5.1'.
5.1 is closed, please don't push commits there any more.
Thanks,
Kevin
> patchreview: allow updating branch diffs
>
> This makes the patchreview plugin update button refresh the diff after
> checking out another branch during a branch diff review. Additionally,
> don't let the plugin trigger patch updates when it is known that updating
> is not supported.
>
> Differential Revision: https://phabricator.kde.org/D7421
>
> M +6 -3 plugins/patchreview/patchreview.cpp
> M +43 -1 vcs/dvcs/ui/branchmanager.cpp
>
> https://commits.kde.org/kdevplatform/355f7f7d3364bfc7989f9359595175e8c026237
> 9
>
> diff --git a/plugins/patchreview/patchreview.cpp
> b/plugins/patchreview/patchreview.cpp index 06d514945..d9226a04a 100644
> --- a/plugins/patchreview/patchreview.cpp
> +++ b/plugins/patchreview/patchreview.cpp
> @@ -217,9 +217,12 @@ void PatchReviewPlugin::notifyPatchChanged() {
>
> void PatchReviewPlugin::forceUpdate() {
> if( m_patch ) {
> - m_patch->update();
> -
> - notifyPatchChanged();
> + // don't trigger an update if we know the plugin cannot update
> itself + VCSDiffPatchSource *vcsPatch =
> dynamic_cast<VCSDiffPatchSource*>(m_patch.data()); + if (!vcsPatch
> || vcsPatch->m_updater) {
> + m_patch->update();
> + notifyPatchChanged();
> + }
> }
> }
>
> diff --git a/vcs/dvcs/ui/branchmanager.cpp b/vcs/dvcs/ui/branchmanager.cpp
> index cbe5c29c2..12eff825d 100644
> --- a/vcs/dvcs/ui/branchmanager.cpp
> +++ b/vcs/dvcs/ui/branchmanager.cpp
> @@ -194,6 +194,47 @@ void BranchManager::mergeBranch()
> }
> }
>
> +// adapted from VCSStandardDiffUpdater
> +class VCSBranchDiffUpdater : public VCSDiffUpdater {
> +public:
> + VCSBranchDiffUpdater(const QString& repo, const QString& src,
> KDevelop::DistributedVersionControlPlugin* vcs); +
> ~VCSBranchDiffUpdater() override;
> + KDevelop::VcsDiff update() const override;
> + KDevelop::IBasicVersionControl* vcs() const override { return m_vcs; }
> + QUrl url() const override { return QUrl::fromLocalFile(m_repository); }
> +private:
> + const QString m_repository;
> + const QString m_src;
> + KDevelop::DistributedVersionControlPlugin* m_vcs;
> +};
> +
> +VCSBranchDiffUpdater::VCSBranchDiffUpdater(const QString& repo, const
> QString& src, + KDevelop::DistributedVersionControlPlugin* vcs)
> + : m_repository(repo)
> + , m_src(src)
> + , m_vcs(vcs)
> +{
> +}
> +
> +VCSBranchDiffUpdater::~VCSBranchDiffUpdater() {
> +}
> +
> +VcsDiff VCSBranchDiffUpdater::update() const
> +{
> + VcsRevision srcRev;
> + srcRev.setRevisionValue(m_src, KDevelop::VcsRevision::GlobalNumber);
> + // see comment in BranchManager::diffFromBranch()
> + const auto destRev =
> VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Working); +
> QScopedPointer<VcsJob>
> diffJob(m_vcs->diff(QUrl::fromLocalFile(m_repository), srcRev, destRev)); +
> const bool success = diffJob ? diffJob->exec() : false;
> + if (!success) {
> + KMessageBox::error(nullptr, i18n("Could not create a patch for the
> current version.")); + return {};
> + }
> +
> + return diffJob->fetchResults().value<VcsDiff>();
> +}
> +
> void BranchManager::diffFromBranch()
> {
> const auto dest = m_model->currentBranch();
> @@ -234,7 +275,8 @@ void BranchManager::diffJobFinished(KJob* job)
> return;
> }
>
> - auto patch = new VCSDiffPatchSource(diff);
> + auto patch = new VCSDiffPatchSource(new
> VCSBranchDiffUpdater(m_repository, +
> m_ui->branchView->currentIndex().data().toString(), m_dvcPlugin));
> showVcsDiff(patch);
> close();
> }
--
Kevin Funk | kfunk at kde.org | http://kfunk.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170911/2d09abef/attachment.sig>
More information about the KDevelop-devel
mailing list