From 689495e2243354dbaf41f41b50549ab8fae35697 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 7 Mar 2015 15:50:24 +0100 Subject: [PATCH 1/6] added placeholder for a "fetch all remotes" action to repo context menu --- Repository/RepoTreeViewCtxMenu.hid | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Repository/RepoTreeViewCtxMenu.hid b/Repository/RepoTreeViewCtxMenu.hid index cbedc14..df13898 100644 --- a/Repository/RepoTreeViewCtxMenu.hid +++ b/Repository/RepoTreeViewCtxMenu.hid @@ -16,8 +16,6 @@ Ui RepoTreeViewCtxMenu { - - Action Activate { Text "&Activate"; StatusToolTip "Make this repository the active one."; @@ -30,10 +28,25 @@ Ui RepoTreeViewCtxMenu { ConnectTo onCtxClose(); }; + + Action FetchAll { + Text "All Remotes"; + StatusToolTip "Fetch repository changes from all remotes."; + }; + + + Menu MenuFetch { + Text "Fetch"; + Action FetchAll; + Separator; + }; + Menu CtxMenuRepo { Action Activate; Separator; + Menu MenuFetch; + Separator; Action Close; }; From 4213d0336948d098ac93ff9c327b6701d6068887 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 7 Mar 2015 15:52:19 +0100 Subject: [PATCH 2/6] added empty slot "onCtxFetchAll" and connect it --- Repository/RepoTreeView.cpp | 5 +++++ Repository/RepoTreeView.hpp | 2 ++ Repository/RepoTreeViewCtxMenu.hid | 1 + 3 files changed, 8 insertions(+) diff --git a/Repository/RepoTreeView.cpp b/Repository/RepoTreeView.cpp index 2ef7834..ed72c68 100644 --- a/Repository/RepoTreeView.cpp +++ b/Repository/RepoTreeView.cpp @@ -143,6 +143,11 @@ void RepoTreeView::onRepoDeactivated(RM::Repo* repo) } } + +void RepoTreeView::onCtxFetchAll() +{ +} + BlueSky::ViewContext* RepoTreeView::createContextObject() const { return new RepositoryContext; diff --git a/Repository/RepoTreeView.hpp b/Repository/RepoTreeView.hpp index 5904fdb..a169cf1 100644 --- a/Repository/RepoTreeView.hpp +++ b/Repository/RepoTreeView.hpp @@ -46,6 +46,8 @@ private slots: // from actions void onCtxActivate(); void onCtxClose(); + void onCtxFetchAll(); + private slots: // from mRepos void contextMenu( const QModelIndex& index, const QPoint& globalPos ); diff --git a/Repository/RepoTreeViewCtxMenu.hid b/Repository/RepoTreeViewCtxMenu.hid index df13898..18f4255 100644 --- a/Repository/RepoTreeViewCtxMenu.hid +++ b/Repository/RepoTreeViewCtxMenu.hid @@ -32,6 +32,7 @@ Ui RepoTreeViewCtxMenu { Action FetchAll { Text "All Remotes"; StatusToolTip "Fetch repository changes from all remotes."; + ConnectTo onCtxFetchAll(); }; From 252196cba483742101cfa71449b4f7db2c6c586e Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 7 Mar 2015 16:00:22 +0100 Subject: [PATCH 3/6] fetch all remotes: create a background "fetch" operation for each remote This is meant as a POC and not a full working implementation. The general idea is to create a threaded background-operation for each remote of the selected repository. Requires also extensions/completions in the GitWrap API (i.e. to set the remote-alias (i.e. "origin"). --- Repository/RepoTreeView.cpp | 57 +++++++++++++++++++++++++++++++++++++ Repository/RepoTreeView.hpp | 3 ++ 2 files changed, 60 insertions(+) diff --git a/Repository/RepoTreeView.cpp b/Repository/RepoTreeView.cpp index ed72c68..ec93025 100644 --- a/Repository/RepoTreeView.cpp +++ b/Repository/RepoTreeView.cpp @@ -15,8 +15,11 @@ */ #include +#include #include +#include "libGitWrap/Operations/RemoteOperations.hpp" + #include "libMacGitverCore/Widgets/TreeViewCtxMenu.hpp" #include "libMacGitverCore/App/MacGitver.hpp" @@ -143,9 +146,63 @@ void RepoTreeView::onRepoDeactivated(RM::Repo* repo) } } +/** + * @brief Called as soon as one fetch operation finishes. + */ +void RepoTreeView::fetchOperationFinished() +{ + Git::FetchOperation* op = qobject_cast( sender() ); + Q_ASSERT( op ); + + Git::Result r( op->result() ); + if ( !r ) { + QMessageBox::warning( this, tr("Operation failed."), + tr("Failed to fetch repository '%1'.\nMessage: %2") + .arg(op->repository().name()).arg(r.errorText()) + ); + } + + // delete the operation + op->deleteLater(); +} void RepoTreeView::onCtxFetchAll() { + Heaven::Action* action = qobject_cast< Heaven::Action* >( sender() ); + Q_ASSERT( action ); + + RM::Repo* repo = qobject_cast< RM::Repo* >( action->activatedBy() ); + if( repo ) { + Git::Result r; + Git::Repository gitRepo = repo->gitRepo(); + const QStringList aliases( gitRepo.allRemoteNames(r) ); + if ( !r ) { + QMessageBox::warning( this, tr("Lookup of remotes failed"), + tr("Unable to lookup remotes for repository '%1'." + "\nMessage: %2").arg(repo->displayName()) + .arg(r.errorText()) + ); + return; + } + + if ( aliases.isEmpty() ) { + QMessageBox::information( this, tr("No Remotes found"), + tr("No remotes configured for repository '%1'.") + .arg(repo->displayName()) + ); + return; + } + + foreach (const QString& alias, aliases) { + Git::FetchOperation* op = new Git::FetchOperation( repo->gitRepo() ); + // TODO: needs extension in GW-API + //op->setRemoteAlias( alias ); + op->setBackgroundMode( true ); + connect( op, SIGNAL(finished()), this, SLOT(fetchOperationFinished()) ); + // TODO: create a central dialog to show progress of parallel operations + op->execute(); + } + } } BlueSky::ViewContext* RepoTreeView::createContextObject() const diff --git a/Repository/RepoTreeView.hpp b/Repository/RepoTreeView.hpp index a169cf1..00c0e7e 100644 --- a/Repository/RepoTreeView.hpp +++ b/Repository/RepoTreeView.hpp @@ -55,6 +55,9 @@ private slots: // for MacGitver::repoMan() void onRepoActivated(RM::Repo* repo); void onRepoDeactivated(RM::Repo* repo); +private slots: + void fetchOperationFinished(); + private: QModelIndex deeplyMapToSource( QModelIndex current ) const; BlueSky::ViewContext* createContextObject() const; From 50150c2174571ca8ab264ac6eee10bb865078dab Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sun, 8 Mar 2015 10:53:14 +0100 Subject: [PATCH 4/6] Fetch Repo: docs correction --- Repository/RepoTreeView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Repository/RepoTreeView.cpp b/Repository/RepoTreeView.cpp index ec93025..5dcbffd 100644 --- a/Repository/RepoTreeView.cpp +++ b/Repository/RepoTreeView.cpp @@ -147,7 +147,7 @@ void RepoTreeView::onRepoDeactivated(RM::Repo* repo) } /** - * @brief Called as soon as one fetch operation finishes. + * @brief This slot is called, when a single fetch operation finishes. */ void RepoTreeView::fetchOperationFinished() { From 291944331fcbed6763aba4a99219a0d196354521 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sun, 8 Mar 2015 10:54:23 +0100 Subject: [PATCH 5/6] Fetch Repo: added "fetch" menu to submodules --- Repository/RepoTreeViewCtxMenu.hid | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Repository/RepoTreeViewCtxMenu.hid b/Repository/RepoTreeViewCtxMenu.hid index 18f4255..f1fdc61 100644 --- a/Repository/RepoTreeViewCtxMenu.hid +++ b/Repository/RepoTreeViewCtxMenu.hid @@ -55,6 +55,8 @@ Ui RepoTreeViewCtxMenu { Menu CtxMenuSMRepo { Action Activate; + Separator; + Menu MenuFetch; }; From 86ed2d790b4b7d0fc4b891ca678e4d0725aec4da Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sun, 8 Mar 2015 13:56:15 +0100 Subject: [PATCH 6/6] Fetch Repo: set remote alias for each operation --- Repository/RepoTreeView.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Repository/RepoTreeView.cpp b/Repository/RepoTreeView.cpp index 5dcbffd..09ca0d3 100644 --- a/Repository/RepoTreeView.cpp +++ b/Repository/RepoTreeView.cpp @@ -195,8 +195,7 @@ void RepoTreeView::onCtxFetchAll() foreach (const QString& alias, aliases) { Git::FetchOperation* op = new Git::FetchOperation( repo->gitRepo() ); - // TODO: needs extension in GW-API - //op->setRemoteAlias( alias ); + op->setRemoteAlias( alias ); op->setBackgroundMode( true ); connect( op, SIGNAL(finished()), this, SLOT(fetchOperationFinished()) ); // TODO: create a central dialog to show progress of parallel operations