forked from qt-creator/qt-creator
Git: Support graph log for all log types (file, project, repo)
* Added a Graph toggle button for log editor * Hide diff parameters when Diff is off * Remove GitClient::graphLog Change-Id: Ib87560bc4d6d7dbe866f0e58db8743a95df0622b Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
48b9747550
commit
a5962841cf
@@ -285,7 +285,7 @@ void BranchDialog::log()
|
||||
if (branchName.isEmpty())
|
||||
return;
|
||||
// Do not pass working dir by reference since it might change
|
||||
GitPlugin::instance()->gitClient()->graphLog(QString(m_repository), branchName);
|
||||
GitPlugin::instance()->gitClient()->log(QString(m_repository), QStringList(), false, QStringList(branchName));
|
||||
}
|
||||
|
||||
void BranchDialog::merge()
|
||||
|
@@ -70,6 +70,7 @@
|
||||
#include <QTextCodec>
|
||||
|
||||
static const char GIT_DIRECTORY[] = ".git";
|
||||
static const char graphLogFormatC[] = "%h %d %an %s %ci";
|
||||
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
@@ -265,13 +266,19 @@ public:
|
||||
m_enableAnnotationContextMenu(enableAnnotationContextMenu),
|
||||
m_fileNames(fileNames)
|
||||
{
|
||||
QToolButton *button = addToggleButton(QLatin1String("--patch"), tr("Show Diff"),
|
||||
QToolButton *diffButton = addToggleButton(QLatin1String("--patch"), tr("Show Diff"),
|
||||
tr("Show difference."));
|
||||
mapSetting(button, m_client->settings()->boolPointer(GitSettings::logDiffKey));
|
||||
connect(button, SIGNAL(toggled(bool)), m_patienceButton, SLOT(setEnabled(bool)));
|
||||
connect(button, SIGNAL(toggled(bool)), m_ignoreWSButton, SLOT(setEnabled(bool)));
|
||||
m_patienceButton->setEnabled(button->isChecked());
|
||||
m_ignoreWSButton->setEnabled(button->isChecked());
|
||||
mapSetting(diffButton, m_client->settings()->boolPointer(GitSettings::logDiffKey));
|
||||
connect(diffButton, SIGNAL(toggled(bool)), m_patienceButton, SLOT(setVisible(bool)));
|
||||
connect(diffButton, SIGNAL(toggled(bool)), m_ignoreWSButton, SLOT(setVisible(bool)));
|
||||
m_patienceButton->setVisible(diffButton->isChecked());
|
||||
m_ignoreWSButton->setVisible(diffButton->isChecked());
|
||||
QStringList graphArguments(QLatin1String("--graph"));
|
||||
graphArguments << QLatin1String("--oneline") << QLatin1String("--topo-order");
|
||||
graphArguments << (QLatin1String("--pretty=format:") + QLatin1String(graphLogFormatC));
|
||||
QToolButton *graphButton = addToggleButton(graphArguments, tr("Graph"),
|
||||
tr("Show textual graph log."));
|
||||
mapSetting(graphButton, m_client->settings()->boolPointer(GitSettings::graphLogKey));
|
||||
}
|
||||
|
||||
void executeCommand()
|
||||
@@ -666,35 +673,6 @@ void GitClient::status(const QString &workingDirectory)
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
static const char graphLogFormatC[] = "%h %d %an %s %ci";
|
||||
|
||||
// Create a graphical log.
|
||||
void GitClient::graphLog(const QString &workingDirectory, const QString & branch)
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("log") << QLatin1String(noColorOption);
|
||||
|
||||
int logCount = settings()->intValue(GitSettings::logCountKey);
|
||||
if (logCount > 0)
|
||||
arguments << QLatin1String("-n") << QString::number(logCount);
|
||||
arguments << (QLatin1String("--pretty=format:") + QLatin1String(graphLogFormatC))
|
||||
<< QLatin1String("--topo-order") << QLatin1String("--graph");
|
||||
|
||||
QString title;
|
||||
if (branch.isEmpty()) {
|
||||
title = tr("Git Log");
|
||||
} else {
|
||||
title = tr("Git Log \"%1\"").arg(branch);
|
||||
arguments << branch;
|
||||
}
|
||||
const Core::Id editorId = Git::Constants::GIT_LOG_EDITOR_ID;
|
||||
const QString sourceFile = VcsBase::VcsBaseEditorWidget::getSource(workingDirectory, QStringList());
|
||||
VcsBase::VcsBaseEditorWidget *editor = findExistingVCSEditor("logFileName", sourceFile);
|
||||
if (!editor)
|
||||
editor = createVcsEditor(editorId, title, sourceFile, CodecLogOutput, "logFileName", sourceFile, 0);
|
||||
executeGit(workingDirectory, arguments, editor);
|
||||
}
|
||||
|
||||
void GitClient::log(const QString &workingDirectory, const QStringList &fileNames,
|
||||
bool enableAnnotationContextMenu, const QStringList &args)
|
||||
{
|
||||
|
@@ -137,8 +137,6 @@ public:
|
||||
void merge(const QString &workingDirectory, const QStringList &unmergedFileNames = QStringList());
|
||||
|
||||
void status(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 = QStringList(),
|
||||
bool enableAnnotationContextMenu = false, const QStringList &args = QStringList());
|
||||
void blame(const QString &workingDirectory, const QStringList &args, const QString &fileName,
|
||||
|
@@ -401,7 +401,8 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
|
||||
createRepositoryAction(localRepositoryMenu,
|
||||
tr("Log"), Core::Id("Git.LogRepository"),
|
||||
globalcontext, true, &GitClient::graphLog);
|
||||
globalcontext, true,
|
||||
SLOT(logRepository()));
|
||||
|
||||
createRepositoryAction(localRepositoryMenu,
|
||||
tr("Clean..."), Core::Id("Git.CleanRepository"),
|
||||
@@ -720,6 +721,13 @@ void GitPlugin::logProject()
|
||||
m_gitClient->log(state.currentProjectTopLevel(), state.relativeCurrentProject());
|
||||
}
|
||||
|
||||
void GitPlugin::logRepository()
|
||||
{
|
||||
const VcsBase::VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
m_gitClient->log(state.topLevel());
|
||||
}
|
||||
|
||||
void GitPlugin::undoFileChanges(bool revertStaging)
|
||||
{
|
||||
const VcsBase::VcsBasePluginState state = currentState();
|
||||
|
@@ -113,6 +113,7 @@ private slots:
|
||||
void logFile();
|
||||
void blameFile();
|
||||
void logProject();
|
||||
void logRepository();
|
||||
void undoFileChanges(bool revertStaging = true);
|
||||
void undoUnstagedFileChanges();
|
||||
void resetRepository();
|
||||
|
@@ -46,6 +46,7 @@ const QLatin1String GitSettings::showPrettyFormatKey("DiffPrettyFormat");
|
||||
const QLatin1String GitSettings::gitkOptionsKey("GitKOptions");
|
||||
const QLatin1String GitSettings::logDiffKey("LogDiff");
|
||||
const QLatin1String GitSettings::repositoryBrowserCmd("RepositoryBrowserCmd");
|
||||
const QLatin1String GitSettings::graphLogKey("GraphLog");
|
||||
|
||||
GitSettings::GitSettings()
|
||||
{
|
||||
@@ -64,6 +65,7 @@ GitSettings::GitSettings()
|
||||
declareKey(showPrettyFormatKey, 2);
|
||||
declareKey(logDiffKey, false);
|
||||
declareKey(repositoryBrowserCmd, QString());
|
||||
declareKey(graphLogKey, false);
|
||||
}
|
||||
|
||||
QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||
|
@@ -52,6 +52,7 @@ public:
|
||||
static const QLatin1String gitkOptionsKey;
|
||||
static const QLatin1String logDiffKey;
|
||||
static const QLatin1String repositoryBrowserCmd;
|
||||
static const QLatin1String graphLogKey;
|
||||
|
||||
QString gitBinaryPath(bool *ok = 0, QString *errorMessage = 0) const;
|
||||
|
||||
|
Reference in New Issue
Block a user