aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/git
diff options
context:
space:
mode:
authorFriedemann Kleint <[email protected]>2010-01-08 16:07:05 +0100
committerFriedemann Kleint <[email protected]>2010-01-08 16:07:05 +0100
commitb81c30df2b32d530848c07d4dc25fb40b0694a99 (patch)
treee0e51308f7efd990d658d3ea202486f659766d5e /src/plugins/git
parentdf2a2dc118216d1233dfdc162404e0448f6f6a7c (diff)
VCS[git]: Add log repository action.
Diffstat (limited to 'src/plugins/git')
-rw-r--r--src/plugins/git/gitclient.cpp23
-rw-r--r--src/plugins/git/gitclient.h1
-rw-r--r--src/plugins/git/giteditor.cpp2
-rw-r--r--src/plugins/git/gitplugin.cpp17
-rw-r--r--src/plugins/git/gitplugin.h3
-rw-r--r--src/plugins/git/gitsettings.cpp2
6 files changed, 44 insertions, 4 deletions
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 37d7c6a46d7..04d5b473c4c 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 c086e88a24b..54be3a2e382 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 db10366140f..b50b1dfe740 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 19880501e22..7227085a367 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 924ccf9f299..d89290841da 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 0e302d098a5..13277d225d2 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 {