Commit e02e0f8c authored by Robert Loehning's avatar Robert Loehning
Browse files

VCS[git]: Added showing logs of all branches

parent 8e5edbec
......@@ -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()
......
......@@ -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;
......
......@@ -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);
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment