From b059f5ed3a034a58f144abd7627f358218ec3701 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 20 Mar 2015 09:39:45 +0100 Subject: [PATCH 1/6] Remotes Module: remove all "global" module actions The menu is at the wrong place and about to be moved to the appropriate context (e.g. repo, branch, remote, ...) --- Remotes/RemotesModule.cpp | 1 - Remotes/RemotesModuleActions.hid | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/Remotes/RemotesModule.cpp b/Remotes/RemotesModule.cpp index dd002e6..0feced7 100644 --- a/Remotes/RemotesModule.cpp +++ b/Remotes/RemotesModule.cpp @@ -35,7 +35,6 @@ BlueSky::View* RemotesModule::createRemotesView() void RemotesModule::initialize() { setupActions( this ); - acRemotesAC->mergeInto( "RemotesMP" ); MacGitver::self().registerView( "Remotes", tr( "Remotes" ), &RemotesModule::createRemotesView ); diff --git a/Remotes/RemotesModuleActions.hid b/Remotes/RemotesModuleActions.hid index 4f7ffe4..3776184 100644 --- a/Remotes/RemotesModuleActions.hid +++ b/Remotes/RemotesModuleActions.hid @@ -16,27 +16,12 @@ Ui RemotesModuleActions { - Container RemotesAC { - Menu Remotes { - Text "R&emotes"; - Action RemotesCreate { - Text "&Create..."; - _ConnectTo onRemoteCreate(); - }; - Action RemotesFetch { - Text "&Fetch"; - }; - Action RemotesPush { - Text "P&ush..."; - }; - }; - }; }; From f00e95ae5bee2497fe4edb1c0927ee67a8a87313 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 20 Mar 2015 14:44:25 +0100 Subject: [PATCH 2/6] Remotes Module: Prepare an action container to build the fetch menu as a mergeable submenu. --- Remotes/RemotesModule.cpp | 11 +++++++++++ Remotes/RemotesModule.h | 4 ++++ Remotes/RemotesModuleActions.hid | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/Remotes/RemotesModule.cpp b/Remotes/RemotesModule.cpp index 0feced7..222e43c 100644 --- a/Remotes/RemotesModule.cpp +++ b/Remotes/RemotesModule.cpp @@ -36,6 +36,8 @@ void RemotesModule::initialize() { setupActions( this ); + acRemotesFetchAC->mergeInto( "RemotesFetchMP" ); + MacGitver::self().registerView( "Remotes", tr( "Remotes" ), &RemotesModule::createRemotesView ); } @@ -50,6 +52,15 @@ void RemotesModule::onRemoteCreate() RemoteCreateEditDlg().exec(); } +/** + * @brief Menu action to fetch all remotes of a repository. + */ +void RemotesModule::onRemotesFetchAll() +{ + // TODO: requires a RepositoryContext (the repo to fetch all remotes from) + // A sub-context (i.e. a branch) can further restrict, what is fetched +} + #if QT_VERSION < 0x050000 Q_EXPORT_PLUGIN2( Remotes, RemotesModule ) #endif diff --git a/Remotes/RemotesModule.h b/Remotes/RemotesModule.h index fd72b52..11e52ad 100644 --- a/Remotes/RemotesModule.h +++ b/Remotes/RemotesModule.h @@ -39,6 +39,10 @@ class RemotesModule : public Module, public RemotesModuleActions private slots: void onRemoteCreate(); + +private slots: + // RemotesFetchAC + void onRemotesFetchAll(); }; #endif diff --git a/Remotes/RemotesModuleActions.hid b/Remotes/RemotesModuleActions.hid index 3776184..9b97c14 100644 --- a/Remotes/RemotesModuleActions.hid +++ b/Remotes/RemotesModuleActions.hid @@ -21,7 +21,18 @@ Ui RemotesModuleActions { + Container RemotesFetchAC { + Menu MnuFetch { + Text "Fetch"; + Action RemotesFetchAll { + Text "All Remotes"; + _ConnectTo onRemotesFetchAll(); + }; + Separator; + }; + + }; }; From 6b0c381000c47334c2e814b4e3080041219aa310 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 20 Mar 2015 15:28:38 +0100 Subject: [PATCH 3/6] Remotes Module: Add action container to manage Git Remotes. --- Remotes/RemotesModule.cpp | 13 +++++++++++-- Remotes/RemotesModule.h | 3 ++- Remotes/RemotesModuleActions.hid | 9 +++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Remotes/RemotesModule.cpp b/Remotes/RemotesModule.cpp index 222e43c..e5f749f 100644 --- a/Remotes/RemotesModule.cpp +++ b/Remotes/RemotesModule.cpp @@ -36,6 +36,7 @@ void RemotesModule::initialize() { setupActions( this ); + acRemotesAC->mergeInto( "RemotesMP" ); acRemotesFetchAC->mergeInto( "RemotesFetchMP" ); MacGitver::self().registerView( "Remotes", tr( "Remotes" ), @@ -47,9 +48,17 @@ void RemotesModule::deinitialize() MacGitver::self().unregisterView( "Remotes" ); } -void RemotesModule::onRemoteCreate() +/** + * @brief Menu action to create a remote and add it to a repository. + */ +void RemotesModule::onRemoteCreateEdit() { - RemoteCreateEditDlg().exec(); + // TODO: requires a repository context (the repo to add the remote to) + // To edit an existing remote, the remote context is required + RemoteCreateEditDlg dlg; + //TODO: dlg.setContext( ctx ); + dlg.exec(); +} } /** diff --git a/Remotes/RemotesModule.h b/Remotes/RemotesModule.h index 11e52ad..67a86fb 100644 --- a/Remotes/RemotesModule.h +++ b/Remotes/RemotesModule.h @@ -38,7 +38,8 @@ class RemotesModule : public Module, public RemotesModuleActions static BlueSky::View* createRemotesView(); private slots: - void onRemoteCreate(); + // RemotesAC + void onRemoteCreateEdit(); private slots: // RemotesFetchAC diff --git a/Remotes/RemotesModuleActions.hid b/Remotes/RemotesModuleActions.hid index 9b97c14..3157f63 100644 --- a/Remotes/RemotesModuleActions.hid +++ b/Remotes/RemotesModuleActions.hid @@ -16,10 +16,19 @@ Ui RemotesModuleActions { + Container RemotesAC { + Menu MnuRemotes { + Text "Remotes"; + Action RemoteAdd { + Text "Add Remote ..."; + _ConnectTo onRemoteCreateEdit(); + }; + }; + }; Container RemotesFetchAC { From 67ffd742739d2d0863a29968ce0d19236ebb8ff0 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 20 Mar 2015 15:30:40 +0100 Subject: [PATCH 4/6] Repository Module: Add menu merge places for "Fetch" and "Remotes" actions --- Repository/RepoTreeViewCtxMenu.hid | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Repository/RepoTreeViewCtxMenu.hid b/Repository/RepoTreeViewCtxMenu.hid index cbedc14..7016414 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."; @@ -34,6 +32,9 @@ Ui RepoTreeViewCtxMenu { Action Activate; Separator; + MergePlace RemotesMP; + MergePlace RemotesFetchMP; + Separator; Action Close; }; From 7231af6df9c126688a49d323d1fea1fb227f4663 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 20 Mar 2015 15:33:59 +0100 Subject: [PATCH 5/6] Remotes Module: minor cleanup in the edit dialog for Git Remotes The dialog is non-functional yet. It could use the (Options ...) technique from the clone dialog to hide the "advanced options". --- Remotes/RemoteCreateEditDlg.ui | 146 +++++++++++++++++---------------- 1 file changed, 74 insertions(+), 72 deletions(-) diff --git a/Remotes/RemoteCreateEditDlg.ui b/Remotes/RemoteCreateEditDlg.ui index 05f0b41..29f4053 100644 --- a/Remotes/RemoteCreateEditDlg.ui +++ b/Remotes/RemoteCreateEditDlg.ui @@ -6,75 +6,58 @@ 0 0 - 428 - 307 + 438 + 340 - - - - - Remote Server + + + + + URL + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + txtUrl - - - - - Url - - - txtUrl - - - - - - - true - - - - - - - Name - - - txtName - - - - - - - true - - - - - - - Push Url - - - - - - - false - - - true - - - - - + + + + Enter the full URI to the remote repository + + + true + + + + + + + false + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + - Custom refspec for Fetch + Custom refspecs for Fetch true @@ -139,13 +122,36 @@ - - - - Qt::Horizontal + + + + Alias - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + txtName + + + + + + + + + + Enter an alias for the Git Remote ... + + + true + + + + + + + Push URL @@ -159,10 +165,6 @@ - txtName - txtUrl - chkPushUrl - txtPushUrl chkRefSpecs treeRefSpecs txtEditRefSpec From 16283c7d6cf27520b50bf2203a43670fa62e69a1 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 20 Mar 2015 17:01:36 +0100 Subject: [PATCH 6/6] Remotes Module: add (preview) implementation for menu action "fetch -> all remotes" Also fixes a compile error due to a double closing bracket. Caution: This currently *only* works within a repository context (static cast to RM::Repo)! If used in other contexts, MGV might crash or not behave like expected! --- Remotes/RemotesModule.cpp | 61 ++++++++++++++++++++++++++++++++++++++- Remotes/RemotesModule.h | 4 +++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Remotes/RemotesModule.cpp b/Remotes/RemotesModule.cpp index e5f749f..c490c06 100644 --- a/Remotes/RemotesModule.cpp +++ b/Remotes/RemotesModule.cpp @@ -16,8 +16,12 @@ #include #include +#include + +#include "libGitWrap/Operations/RemoteOperations.hpp" #include "libMacGitverCore/App/MacGitver.hpp" +#include "libMacGitverCore/RepoMan/Repo.hpp" #include "RemoteCreateEditDlg.h" #include "RemotesModule.h" @@ -59,6 +63,10 @@ void RemotesModule::onRemoteCreateEdit() //TODO: dlg.setContext( ctx ); dlg.exec(); } + +void RemotesModule::onRemoteDelete() +{ + // TODO: requires the remote context (the remote to delete) } /** @@ -66,8 +74,59 @@ void RemotesModule::onRemoteCreateEdit() */ void RemotesModule::onRemotesFetchAll() { - // TODO: requires a RepositoryContext (the repo to fetch all remotes from) + // TODO: requires a repository context (the repo to fetch all remotes from) // A sub-context (i.e. a branch) can further restrict, what is fetched + 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( 0, 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( 0, 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() ); + 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(); + } + } +} + +/** + * @brief Called, when an non-blocking Git::Operation finished. + */ +void RemotesModule::onOperationFinished() +{ + Git::BaseOperation* op = qobject_cast( sender() ); + Q_ASSERT( op ); + Git::Result r( op->result() ); + if ( !r ) { + QMessageBox::warning( 0, tr("Operation failed."), + tr("Operation failed. Message:\n %1").arg(r.errorText()) + ); + } + + // delete the operation + op->deleteLater(); } #if QT_VERSION < 0x050000 diff --git a/Remotes/RemotesModule.h b/Remotes/RemotesModule.h index 67a86fb..9ddf949 100644 --- a/Remotes/RemotesModule.h +++ b/Remotes/RemotesModule.h @@ -40,10 +40,14 @@ class RemotesModule : public Module, public RemotesModuleActions private slots: // RemotesAC void onRemoteCreateEdit(); + void onRemoteDelete(); private slots: // RemotesFetchAC void onRemotesFetchAll(); + +private slots: + void onOperationFinished(); }; #endif