From b1c9d0eb3797136e84f130bf0a31182331230e87 Mon Sep 17 00:00:00 2001 From: Petar Perisin Date: Sat, 30 Mar 2013 03:31:42 +0100 Subject: [PATCH] Git: Added Checkout Commit Change-Id: I9446060b9a8ee1717b832f1f7b7dbcaf8e739ad3 Reviewed-by: Tobias Hunger Reviewed-by: Orgad Shaneh --- src/plugins/git/changeselectiondialog.cpp | 9 +++++++++ src/plugins/git/changeselectiondialog.h | 3 +++ src/plugins/git/gitclient.h | 4 +++- src/plugins/git/gitplugin.cpp | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index 8a750cd4db..edf49194ab 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -53,6 +53,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QW , m_showButton(new QPushButton(tr("Show"), this)) , m_cherryPickButton(new QPushButton(tr("Cherry Pick"), this)) , m_revertButton(new QPushButton(tr("Revert"), this)) + , m_checkoutButton(new QPushButton(tr("Checkout"), this)) , m_cancelButton(new QPushButton(tr("Cancel"), this)) , m_command(NoCommand) { @@ -71,6 +72,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QW QHBoxLayout* buttonsLine = new QHBoxLayout(); buttonsLine->addWidget(m_cancelButton); buttonsLine->addStretch(); + buttonsLine->addWidget(m_checkoutButton); buttonsLine->addWidget(m_revertButton); buttonsLine->addWidget(m_cherryPickButton); buttonsLine->addWidget(m_showButton); @@ -91,6 +93,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QW connect(m_showButton, SIGNAL(clicked()), this, SLOT(acceptShow())); connect(m_cherryPickButton, SIGNAL(clicked()), this, SLOT(acceptCherryPick())); connect(m_revertButton, SIGNAL(clicked()), this, SLOT(acceptRevert())); + connect(m_checkoutButton, SIGNAL(clicked()), this, SLOT(acceptCheckout())); connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject())); recalculateDetails(m_changeNumberEdit->text()); @@ -116,6 +119,12 @@ ChangeCommand ChangeSelectionDialog::command() const return m_command; } +void ChangeSelectionDialog::acceptCheckout() +{ + m_command = Checkout; + accept(); +} + void ChangeSelectionDialog::acceptCherryPick() { m_command = CherryPick; diff --git a/src/plugins/git/changeselectiondialog.h b/src/plugins/git/changeselectiondialog.h index 0f2e77e6ea..a7a5fad38e 100644 --- a/src/plugins/git/changeselectiondialog.h +++ b/src/plugins/git/changeselectiondialog.h @@ -46,6 +46,7 @@ namespace Internal { enum ChangeCommand { NoCommand, + Checkout, CherryPick, Revert, Show @@ -66,6 +67,7 @@ public: private slots: void setDetails(int exitCode); void recalculateDetails(const QString &ref); + void acceptCheckout(); void acceptCherryPick(); void acceptRevert(); void acceptShow(); @@ -83,6 +85,7 @@ private: QPushButton* m_showButton; QPushButton* m_cherryPickButton; QPushButton* m_revertButton; + QPushButton* m_checkoutButton; QPushButton* m_cancelButton; ChangeCommand m_command; diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 79af177e4d..2619a41fa6 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -155,7 +155,9 @@ public: QString revision = QString(), QString *errorMessage = 0, bool revertStaging = true); // Checkout branch - bool synchronousCheckout(const QString &workingDirectory, const QString &ref, QString *errorMessage = 0); + bool synchronousCheckout(const QString &workingDirectory, const QString &ref, QString *errorMessage); + bool synchronousCheckout(const QString &workingDirectory, const QString &ref) + { return synchronousCheckout(workingDirectory, ref, 0); } // Do a stash and return identier. enum { StashPromptDescription = 0x1, StashImmediateRestore = 0x2, StashIgnoreUnchanged = 0x4 }; diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 63061d8cc8..862b375bfd 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -763,6 +763,10 @@ void GitPlugin::startChangeRelatedAction() command = QLatin1String("Revert"); commandFunction = &GitClient::revertCommit; break; + case Checkout: + command = QLatin1String("Checkout"); + commandFunction = &GitClient::synchronousCheckout; + break; default: return; } -- GitLab