diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 37d7c6a46d7118549925b49d3966c0ec4fafcac6..04d5b473c4c145385d0afee7ac71183702acb5d0 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -260,6 +260,29 @@ void GitClient::status(const QString &workingDirectory) Qt::QueuedConnection); } +static const char graphLogFormatC[] = "%h %an %s %ci"; + +// Create a graphical log. +void GitClient::graphLog(const QString &workingDirectory) +{ + if (Git::Constants::debug) + qDebug() << "log" << workingDirectory; + + QStringList arguments; + arguments << QLatin1String("log") << QLatin1String(noColorOption); + + if (m_settings.logCount > 0) + arguments << QLatin1String("-n") << QString::number(m_settings.logCount); + arguments << (QLatin1String("--pretty=format:") + QLatin1String(graphLogFormatC)) + << QLatin1String("--topo-order") << QLatin1String("--graph"); + + const QString title = tr("Git Log"); + 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); + executeGit(workingDirectory, arguments, editor); +} + void GitClient::log(const QString &workingDirectory, const QStringList &fileNames, bool enableAnnotationContextMenu) { if (Git::Constants::debug) diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index c086e88a24b321328b2fb33e29cff14cfd1e5ab9..54be3a2e3825363fcba9f01c882acf29a2a518fb 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -79,6 +79,7 @@ public: const QStringList &unstagedFileNames, const QStringList &stagedFileNames= QStringList()); void status(const QString &workingDirectory); + void graphLog(const QString &workingDirectory); void log(const QString &workingDirectory, const QStringList &fileNames, bool enableAnnotationContextMenu = false); void blame(const QString &workingDirectory, const QString &fileName, diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp index db10366140f52752a9a205a41af8bb4cb37e1eb5..b50b1dfe7407988ea945d28e5fa997af0303a9e2 100644 --- a/src/plugins/git/giteditor.cpp +++ b/src/plugins/git/giteditor.cpp @@ -50,7 +50,7 @@ #include <QtGui/QTextCursor> #include <QtGui/QTextEdit> -#define CHANGE_PATTERN_8C "[a-f0-9]{8,8}" +#define CHANGE_PATTERN_8C "[a-f0-9]{7,8}" #define CHANGE_PATTERN_40C "[a-f0-9]{40,40}" namespace Git { diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 19880501e22fa19c3362eaa256b54d2a409c56ab..7227085a367e4ae49a93b62634684046aefc736c 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -120,6 +120,7 @@ GitPlugin::GitPlugin() : m_blameAction(0), m_logProjectAction(0), m_undoFileAction(0), + m_logRepositoryAction(0), m_undoRepositoryAction(0), m_showAction(0), m_stageAction(0), @@ -295,9 +296,13 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) connect(m_statusRepositoryAction, SIGNAL(triggered()), this, SLOT(statusRepository())); gitContainer->addAction(command); + m_logRepositoryAction = new QAction(tr("Log Repository"), this); + command = actionManager->registerAction(m_logRepositoryAction, "Git.LogRepository", globalcontext); + connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository())); + gitContainer->addAction(command); + m_undoRepositoryAction = new QAction(tr("Undo Repository Changes"), this); command = actionManager->registerAction(m_undoRepositoryAction, "Git.UndoRepository", globalcontext); - command->setAttribute(Core::Command::CA_UpdateText); connect(m_undoRepositoryAction, SIGNAL(triggered()), this, SLOT(undoRepositoryChanges())); gitContainer->addAction(command); @@ -448,6 +453,13 @@ void GitPlugin::undoFileChanges() m_gitClient->revert(QStringList(state.currentFile())); } +void GitPlugin::logRepository() +{ + const VCSBase::VCSBasePluginState state = currentState(); + QTC_ASSERT(state.hasTopLevel(), return) + m_gitClient->graphLog(state.topLevel()); +} + void GitPlugin::undoRepositoryChanges() { const VCSBase::VCSBasePluginState state = currentState(); @@ -690,7 +702,6 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) m_diffProjectAction->setParameter(projectName); m_logProjectAction->setEnabled(projectEnabled); m_logProjectAction->setParameter(projectName); - m_undoRepositoryAction->setEnabled(projectEnabled); const bool repositoryEnabled = currentState().hasTopLevel(); m_diffRepositoryAction->setEnabled(repositoryEnabled); @@ -698,6 +709,8 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) m_branchListAction->setEnabled(repositoryEnabled); m_stashListAction->setEnabled(repositoryEnabled); m_stashPopAction->setEnabled(repositoryEnabled); + m_logRepositoryAction->setEnabled(repositoryEnabled); + m_undoRepositoryAction->setEnabled(repositoryEnabled); // Prompts for repo. m_showAction->setEnabled(true); diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index 924ccf9f29906a46d5eaab1892b9eb62f50610ea..d89290841da2a391f57590a2b19f8b4c9a3dded5 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -96,6 +96,7 @@ private slots: void blameFile(); void logProject(); void undoFileChanges(); + void logRepository(); void undoRepositoryChanges(); void stageFile(); void unstageFile(); @@ -128,7 +129,9 @@ private: Utils::ParameterAction *m_blameAction; Utils::ParameterAction *m_logProjectAction; Utils::ParameterAction *m_undoFileAction; + QAction *m_logRepositoryAction; QAction *m_undoRepositoryAction; + QAction *m_showAction; Utils::ParameterAction *m_stageAction; Utils::ParameterAction *m_unstageAction; diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp index 0e302d098a59da4c3d4a8f84fd0ed186e60c965b..13277d225d224f517e6546c3427cfbce80d4e35b 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -45,7 +45,7 @@ static const char *promptToSubmitKeyC = "PromptForSubmit"; static const char *omitAnnotationDateKeyC = "OmitAnnotationDate"; static const char *spaceIgnorantBlameKeyC = "SpaceIgnorantBlame"; -enum { defaultLogCount = 10 , defaultTimeOut = 30}; +enum { defaultLogCount = 100 , defaultTimeOut = 30}; namespace Git { namespace Internal {