Commit b81c30df authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

VCS[git]: Add log repository action.

parent df2a2dc1
......@@ -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)
......
......@@ -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,
......
......@@ -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 {
......
......@@ -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);
......
......@@ -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;
......
......@@ -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 {
......
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