From e02e0f8c4a8caa04776a7b6b7b99985e09ef1968 Mon Sep 17 00:00:00 2001 From: Robert Loehning <robert.loehning@nokia.com> Date: Thu, 26 Aug 2010 12:56:15 +0100 Subject: [PATCH] VCS[git]: Added showing logs of all branches --- src/plugins/git/branchdialog.cpp | 17 +++++++++++++++++ src/plugins/git/branchdialog.h | 2 ++ src/plugins/git/gitclient.cpp | 10 ++++++++-- src/plugins/git/gitclient.h | 3 ++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp index ae883675cb3..b804fea5a9a 100644 --- a/src/plugins/git/branchdialog.cpp +++ b/src/plugins/git/branchdialog.cpp @@ -73,6 +73,7 @@ BranchDialog::BranchDialog(QWidget *parent) : m_ui(new Ui::BranchDialog), m_checkoutButton(0), m_diffButton(0), + m_logButton(0), m_refreshButton(0), m_deleteButton(0), m_localModel(new LocalBranchModel(gitClient(), this)), @@ -90,6 +91,9 @@ BranchDialog::BranchDialog(QWidget *parent) : m_diffButton = m_ui->buttonBox->addButton(tr("Diff"), QDialogButtonBox::ActionRole); connect(m_diffButton, SIGNAL(clicked()), this, SLOT(slotDiffSelected())); + m_logButton = m_ui->buttonBox->addButton(tr("Log"), QDialogButtonBox::ActionRole); + connect(m_logButton, SIGNAL(clicked()), this, SLOT(slotLog())); + m_refreshButton = m_ui->buttonBox->addButton(tr("Refresh"), QDialogButtonBox::ActionRole); connect(m_refreshButton, SIGNAL(clicked()), this, SLOT(slotRefresh())); @@ -168,6 +172,7 @@ void BranchDialog::slotEnableButtons(const QItemSelection &selected) m_checkoutButton->setEnabled(otherLocalSelected); m_diffButton->setEnabled(branchSelected); + m_logButton->setEnabled(branchSelected); m_deleteButton->setEnabled(otherLocalSelected); m_refreshButton->setEnabled(hasRepository); // Also disable <New Branch> entry of list view @@ -258,6 +263,18 @@ void BranchDialog::slotDiffSelected() gitClient()->diffBranch(m_repository, QStringList(), m_remoteModel->branchName(idx)); } +void BranchDialog::slotLog() +{ + int idx = selectedLocalBranchIndex(); + if (idx != -1) { + gitClient()->graphLog(m_repository, m_localModel->branchName(idx)); + return; + } + idx = selectedRemoteBranchIndex(); + if (idx != -1) + gitClient()->graphLog(m_repository, m_remoteModel->branchName(idx)); +} + /* Ask to stash away changes and then close dialog and do an asynchronous * checkout. */ void BranchDialog::slotCheckoutSelectedBranch() diff --git a/src/plugins/git/branchdialog.h b/src/plugins/git/branchdialog.h index bf21a746e34..4fdabeaa88d 100644 --- a/src/plugins/git/branchdialog.h +++ b/src/plugins/git/branchdialog.h @@ -69,6 +69,7 @@ private slots: void slotCheckoutSelectedBranch(); void slotDeleteSelectedBranch(); void slotDiffSelected(); + void slotLog(); void slotRefresh(); void slotLocalBranchActivated(); void slotRemoteBranchActivated(const QModelIndex &); @@ -87,6 +88,7 @@ private: Ui::BranchDialog *m_ui; QPushButton *m_checkoutButton; QPushButton *m_diffButton; + QPushButton *m_logButton; QPushButton *m_refreshButton; QPushButton *m_deleteButton; diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 74f778bd551..f81480bd3a7 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -291,7 +291,7 @@ void GitClient::status(const QString &workingDirectory) static const char graphLogFormatC[] = "%h %an %s %ci"; // Create a graphical log. -void GitClient::graphLog(const QString &workingDirectory) +void GitClient::graphLog(const QString &workingDirectory, const QString & branch) { if (Git::Constants::debug) qDebug() << "log" << workingDirectory; @@ -304,7 +304,13 @@ void GitClient::graphLog(const QString &workingDirectory) arguments << (QLatin1String("--pretty=format:") + QLatin1String(graphLogFormatC)) << QLatin1String("--topo-order") << QLatin1String("--graph"); - const QString title = tr("Git Log"); + QString title; + if (branch.isEmpty()) { + title = tr("Git Log"); + } else { + title = tr("Git Log %1").arg(branch); + arguments << branch; + } const QString editorId = QLatin1String(Git::Constants::GIT_LOG_EDITOR_ID); const QString sourceFile = VCSBase::VCSBaseEditor::getSource(workingDirectory, QStringList()); VCSBase::VCSBaseEditor *editor = createVCSEditor(editorId, title, sourceFile, false, "logFileName", sourceFile); diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index a183a619099..dbf0ea58a9d 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -87,7 +87,8 @@ public: const QString &branchName); void status(const QString &workingDirectory); - void graphLog(const QString &workingDirectory); + void graphLog(const QString &workingDirectory) { graphLog(workingDirectory, QString()); } + void graphLog(const QString &workingDirectory, const QString &branch); void log(const QString &workingDirectory, const QStringList &fileNames, bool enableAnnotationContextMenu = false); void blame(const QString &workingDirectory, const QString &fileName, -- GitLab