Commit b4969672 authored by Friedemann Kleint's avatar Friedemann Kleint

VCS[Perforce/SVN/CVS]: Add "Annotate" to single file logs.

...over change numbers. Add missing "Log project/repository"
actions and log count limits.
Task-number: QTCREATORBUG-503
parent aadc0b9b
...@@ -54,6 +54,7 @@ CVSEditor::CVSEditor(const VCSBase::VCSBaseEditorParameters *type, ...@@ -54,6 +54,7 @@ CVSEditor::CVSEditor(const VCSBase::VCSBaseEditorParameters *type,
{ {
QTC_ASSERT(m_revisionAnnotationPattern.isValid(), return); QTC_ASSERT(m_revisionAnnotationPattern.isValid(), return);
QTC_ASSERT(m_revisionLogPattern.isValid(), return); QTC_ASSERT(m_revisionLogPattern.isValid(), return);
setAnnotateRevisionTextFormat(tr("Annotate revision \"%1\""));
} }
QSet<QString> CVSEditor::annotationChanges() const QSet<QString> CVSEditor::annotationChanges() const
...@@ -149,11 +150,10 @@ QString CVSEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) cons ...@@ -149,11 +150,10 @@ QString CVSEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) cons
return QString(); return QString();
} }
QStringList CVSEditor::annotationPreviousVersions(const QString &revision, QString *actionTextFormat) const QStringList CVSEditor::annotationPreviousVersions(const QString &revision) const
{ {
if (isFirstRevision(revision)) if (isFirstRevision(revision))
return QStringList(); return QStringList();
*actionTextFormat = tr("Annotate revision \"%1\"");
return QStringList(previousRevision(revision)); return QStringList(previousRevision(revision));
} }
......
...@@ -51,7 +51,7 @@ private: ...@@ -51,7 +51,7 @@ private:
virtual VCSBase::DiffHighlighter *createDiffHighlighter() const; virtual VCSBase::DiffHighlighter *createDiffHighlighter() const;
virtual VCSBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const; virtual VCSBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const;
virtual QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const; virtual QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const;
virtual QStringList annotationPreviousVersions(const QString &revision, QString *actionTextFormat) const; virtual QStringList annotationPreviousVersions(const QString &revision) const;
const QRegExp m_revisionAnnotationPattern; const QRegExp m_revisionAnnotationPattern;
const QRegExp m_revisionLogPattern; const QRegExp m_revisionLogPattern;
......
...@@ -95,6 +95,9 @@ static const char * const CMD_ID_ANNOTATE_CURRENT = "CVS.AnnotateCurrent"; ...@@ -95,6 +95,9 @@ static const char * const CMD_ID_ANNOTATE_CURRENT = "CVS.AnnotateCurrent";
static const char * const CMD_ID_SEPARATOR3 = "CVS.Separator3"; static const char * const CMD_ID_SEPARATOR3 = "CVS.Separator3";
static const char * const CMD_ID_STATUS = "CVS.Status"; static const char * const CMD_ID_STATUS = "CVS.Status";
static const char * const CMD_ID_UPDATE = "CVS.Update"; static const char * const CMD_ID_UPDATE = "CVS.Update";
static const char * const CMD_ID_PROJECTLOG = "CVS.ProjectLog";
static const char * const CMD_ID_REPOSITORYLOG = "CVS.RepositoryLog";
static const char * const CMD_ID_SEPARATOR4 = "CVS.Separator4";
static const VCSBase::VCSBaseEditorParameters editorParameters[] = { static const VCSBase::VCSBaseEditorParameters editorParameters[] = {
{ {
...@@ -149,6 +152,8 @@ CVSPlugin::CVSPlugin() : ...@@ -149,6 +152,8 @@ CVSPlugin::CVSPlugin() :
m_revertAction(0), m_revertAction(0),
m_diffProjectAction(0), m_diffProjectAction(0),
m_diffCurrentAction(0), m_diffCurrentAction(0),
m_logProjectAction(0),
m_logRepositoryAction(0),
m_commitAllAction(0), m_commitAllAction(0),
m_commitCurrentAction(0), m_commitCurrentAction(0),
m_filelogCurrentAction(0), m_filelogCurrentAction(0),
...@@ -325,12 +330,24 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes ...@@ -325,12 +330,24 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(projectStatus())); connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(projectStatus()));
cvsMenu->addAction(command); cvsMenu->addAction(command);
m_logProjectAction = new Utils::ParameterAction(tr("Log Project"), tr("Log Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = ami->registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
cvsMenu->addAction(command);
m_updateProjectAction = new Utils::ParameterAction(tr("Update Project"), tr("Update Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); m_updateProjectAction = new Utils::ParameterAction(tr("Update Project"), tr("Update Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = ami->registerAction(m_updateProjectAction, CMD_ID_UPDATE, globalcontext); command = ami->registerAction(m_updateProjectAction, CMD_ID_UPDATE, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject())); connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject()));
cvsMenu->addAction(command); cvsMenu->addAction(command);
cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR4, globalcontext));
m_logRepositoryAction = new QAction(tr("Repository Log"), this);
command = ami->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext);
connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
cvsMenu->addAction(command);
// Actions of the submit editor // Actions of the submit editor
QList<int> cvscommitcontext; QList<int> cvscommitcontext;
cvscommitcontext << Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::CVSCOMMITEDITOR); cvscommitcontext << Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::CVSCOMMITEDITOR);
...@@ -475,6 +492,8 @@ void CVSPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) ...@@ -475,6 +492,8 @@ void CVSPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
if (!VCSBase::VCSBasePlugin::enableMenuAction(as, m_menuAction)) if (!VCSBase::VCSBasePlugin::enableMenuAction(as, m_menuAction))
return; return;
m_logRepositoryAction->setEnabled(currentState().hasTopLevel());
const QString currentFileName = currentState().currentFileName(); const QString currentFileName = currentState().currentFileName();
m_addAction->setParameter(currentFileName); m_addAction->setParameter(currentFileName);
m_deleteAction->setParameter(currentFileName); m_deleteAction->setParameter(currentFileName);
...@@ -488,6 +507,7 @@ void CVSPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) ...@@ -488,6 +507,7 @@ void CVSPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
m_diffProjectAction->setParameter(currentProjectName); m_diffProjectAction->setParameter(currentProjectName);
m_statusProjectAction->setParameter(currentProjectName); m_statusProjectAction->setParameter(currentProjectName);
m_updateProjectAction->setParameter(currentProjectName); m_updateProjectAction->setParameter(currentProjectName);
m_logProjectAction->setParameter(currentProjectName);
m_commitAllAction->setEnabled(currentState().hasTopLevel()); m_commitAllAction->setEnabled(currentState().hasTopLevel());
} }
...@@ -641,10 +661,26 @@ void CVSPlugin::filelogCurrentFile() ...@@ -641,10 +661,26 @@ void CVSPlugin::filelogCurrentFile()
{ {
const VCSBase::VCSBasePluginState state = currentState(); const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return) QTC_ASSERT(state.hasFile(), return)
filelog(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile())); filelog(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), true);
} }
void CVSPlugin::filelog(const QString &workingDir, const QStringList &files) void CVSPlugin::logProject()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
filelog(state.currentProjectTopLevel(), state.relativeCurrentProject());
}
void CVSPlugin::logRepository()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
filelog(state.topLevel());
}
void CVSPlugin::filelog(const QString &workingDir,
const QStringList &files,
bool enableAnnotationContextMenu)
{ {
QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(workingDir, files); QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(workingDir, files);
// no need for temp file // no need for temp file
...@@ -659,7 +695,6 @@ void CVSPlugin::filelog(const QString &workingDir, const QStringList &files) ...@@ -659,7 +695,6 @@ void CVSPlugin::filelog(const QString &workingDir, const QStringList &files)
// Re-use an existing view if possible to support // Re-use an existing view if possible to support
// the common usage pattern of continuously changing and diffing a file // the common usage pattern of continuously changing and diffing a file
if (Core::IEditor *editor = locateEditor("logFileName", id)) { if (Core::IEditor *editor = locateEditor("logFileName", id)) {
editor->createNew(response.stdOut); editor->createNew(response.stdOut);
Core::EditorManager::instance()->activateEditor(editor); Core::EditorManager::instance()->activateEditor(editor);
...@@ -667,6 +702,8 @@ void CVSPlugin::filelog(const QString &workingDir, const QStringList &files) ...@@ -667,6 +702,8 @@ void CVSPlugin::filelog(const QString &workingDir, const QStringList &files)
const QString title = QString::fromLatin1("cvs log %1").arg(id); const QString title = QString::fromLatin1("cvs log %1").arg(id);
Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::LogOutput, source, codec); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::LogOutput, source, codec);
newEditor->setProperty("logFileName", id); newEditor->setProperty("logFileName", id);
if (enableAnnotationContextMenu)
VCSBase::VCSBaseEditor::getVcsBaseEditor(newEditor)->setFileLogAnnotateEnabled(true);
} }
} }
...@@ -726,8 +763,6 @@ void CVSPlugin::annotate(const QString &workingDir, const QString &file, ...@@ -726,8 +763,6 @@ void CVSPlugin::annotate(const QString &workingDir, const QString &file,
const QString title = QString::fromLatin1("cvs annotate %1").arg(id); const QString title = QString::fromLatin1("cvs annotate %1").arg(id);
Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::AnnotateOutput, source, codec); Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::AnnotateOutput, source, codec);
newEditor->setProperty("annotateFileName", id); newEditor->setProperty("annotateFileName", id);
connect(newEditor, SIGNAL(annotatePreviousRequested(QString,QString,int)),
this, SLOT(annotateVersion(QString,QString,int)));
VCSBase::VCSBaseEditor::gotoLineOfEditor(newEditor, lineNumber); VCSBase::VCSBaseEditor::gotoLineOfEditor(newEditor, lineNumber);
} }
} }
...@@ -992,6 +1027,8 @@ Core::IEditor * CVSPlugin::showOutputInEditor(const QString& title, const QStrin ...@@ -992,6 +1027,8 @@ Core::IEditor * CVSPlugin::showOutputInEditor(const QString& title, const QStrin
qDebug() << "CVSPlugin::showOutputInEditor" << title << kind << "source=" << source << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); qDebug() << "CVSPlugin::showOutputInEditor" << title << kind << "source=" << source << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
QString s = title; QString s = title;
Core::IEditor *editor = Core::EditorManager::instance()->openEditorWithContents(kind, &s, output.toLocal8Bit()); Core::IEditor *editor = Core::EditorManager::instance()->openEditorWithContents(kind, &s, output.toLocal8Bit());
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)),
this, SLOT(annotateVersion(QString,QString,int)));
CVSEditor *e = qobject_cast<CVSEditor*>(editor->widget()); CVSEditor *e = qobject_cast<CVSEditor*>(editor->widget());
if (!e) if (!e)
return 0; return 0;
......
...@@ -113,6 +113,8 @@ private slots: ...@@ -113,6 +113,8 @@ private slots:
void updateProject(); void updateProject();
void submitCurrentLog(); void submitCurrentLog();
void diffCommitFiles(const QStringList &); void diffCommitFiles(const QStringList &);
void logProject();
void logRepository();
protected: protected:
virtual void updateActions(VCSBase::VCSBasePlugin::ActionState); virtual void updateActions(VCSBase::VCSBasePlugin::ActionState);
...@@ -135,7 +137,9 @@ private: ...@@ -135,7 +137,9 @@ private:
bool describe(const QString &source, const QString &changeNr, QString *errorMessage); bool describe(const QString &source, const QString &changeNr, QString *errorMessage);
bool describe(const QString &toplevel, const QString &source, const QString &changeNr, QString *errorMessage); bool describe(const QString &toplevel, const QString &source, const QString &changeNr, QString *errorMessage);
bool describe(const QString &repository, QList<CVS_LogEntry> entries, QString *errorMessage); bool describe(const QString &repository, QList<CVS_LogEntry> entries, QString *errorMessage);
void filelog(const QString &workingDir, const QStringList &files = QStringList()); void filelog(const QString &workingDir,
const QStringList &files = QStringList(),
bool enableAnnotationContextMenu = false);
bool managesDirectory(const QDir &directory) const; bool managesDirectory(const QDir &directory) const;
QString findTopLevelForDirectoryI(const QString &directory) const; QString findTopLevelForDirectoryI(const QString &directory) const;
void startCommit(const QString &workingDir, const QStringList &files = QStringList()); void startCommit(const QString &workingDir, const QStringList &files = QStringList());
...@@ -152,6 +156,8 @@ private: ...@@ -152,6 +156,8 @@ private:
Utils::ParameterAction *m_revertAction; Utils::ParameterAction *m_revertAction;
Utils::ParameterAction *m_diffProjectAction; Utils::ParameterAction *m_diffProjectAction;
Utils::ParameterAction *m_diffCurrentAction; Utils::ParameterAction *m_diffCurrentAction;
Utils::ParameterAction *m_logProjectAction;
QAction *m_logRepositoryAction;
QAction *m_commitAllAction; QAction *m_commitAllAction;
Utils::ParameterAction *m_commitCurrentAction; Utils::ParameterAction *m_commitCurrentAction;
Utils::ParameterAction *m_filelogCurrentAction; Utils::ParameterAction *m_filelogCurrentAction;
......
...@@ -62,6 +62,7 @@ PerforceEditor::PerforceEditor(const VCSBase::VCSBaseEditorParameters *type, ...@@ -62,6 +62,7 @@ PerforceEditor::PerforceEditor(const VCSBase::VCSBaseEditorParameters *type,
m_plugin(PerforcePlugin::perforcePluginInstance()) m_plugin(PerforcePlugin::perforcePluginInstance())
{ {
QTC_ASSERT(m_changeNumberPattern.isValid(), /**/); QTC_ASSERT(m_changeNumberPattern.isValid(), /**/);
setAnnotateRevisionTextFormat(tr("Annotate change list \"%1\""));
if (Perforce::Constants::debug) if (Perforce::Constants::debug)
qDebug() << "PerforceEditor::PerforceEditor" << type->type << type->kind; qDebug() << "PerforceEditor::PerforceEditor" << type->type << type->kind;
} }
...@@ -154,13 +155,12 @@ QString PerforceEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) ...@@ -154,13 +155,12 @@ QString PerforceEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock)
return QString(); return QString();
} }
QStringList PerforceEditor::annotationPreviousVersions(const QString &v, QString *actionTextFormat) const QStringList PerforceEditor::annotationPreviousVersions(const QString &v) const
{ {
bool ok; bool ok;
const int changeList = v.toInt(&ok); const int changeList = v.toInt(&ok);
if (!ok || changeList < 2) if (!ok || changeList < 2)
return QStringList(); return QStringList();
*actionTextFormat = tr("Annotate change list \"%1\"");
return QStringList(QString::number(changeList - 1)); return QStringList(QString::number(changeList - 1));
} }
......
...@@ -53,7 +53,7 @@ private: ...@@ -53,7 +53,7 @@ private:
virtual VCSBase::DiffHighlighter *createDiffHighlighter() const; virtual VCSBase::DiffHighlighter *createDiffHighlighter() const;
virtual VCSBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const; virtual VCSBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const;
virtual QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const; virtual QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const;
virtual QStringList annotationPreviousVersions(const QString &v, QString *actionTextFormat) const; virtual QStringList annotationPreviousVersions(const QString &v) const;
const QRegExp m_changeNumberPattern; const QRegExp m_changeNumberPattern;
PerforcePlugin *m_plugin; PerforcePlugin *m_plugin;
......
...@@ -133,6 +133,8 @@ static const char * const CMD_ID_EDIT = "Perforce.Edit"; ...@@ -133,6 +133,8 @@ static const char * const CMD_ID_EDIT = "Perforce.Edit";
static const char * const CMD_ID_ADD = "Perforce.Add"; static const char * const CMD_ID_ADD = "Perforce.Add";
static const char * const CMD_ID_DELETE_FILE = "Perforce.Delete"; static const char * const CMD_ID_DELETE_FILE = "Perforce.Delete";
static const char * const CMD_ID_OPENED = "Perforce.Opened"; static const char * const CMD_ID_OPENED = "Perforce.Opened";
static const char * const CMD_ID_PROJECTLOG = "Perforce.ProjectLog";
static const char * const CMD_ID_REPOSITORYLOG = "Perforce.RepositoryLog";
static const char * const CMD_ID_REVERT = "Perforce.Revert"; static const char * const CMD_ID_REVERT = "Perforce.Revert";
static const char * const CMD_ID_DIFF_CURRENT = "Perforce.DiffCurrent"; static const char * const CMD_ID_DIFF_CURRENT = "Perforce.DiffCurrent";
static const char * const CMD_ID_DIFF_PROJECT = "Perforce.DiffProject"; static const char * const CMD_ID_DIFF_PROJECT = "Perforce.DiffProject";
...@@ -152,6 +154,7 @@ static const char * const CMD_ID_UPDATEALL = "Perforce.UpdateAll"; ...@@ -152,6 +154,7 @@ static const char * const CMD_ID_UPDATEALL = "Perforce.UpdateAll";
static const char * const CMD_ID_SEPARATOR1 = "Perforce.Separator1"; static const char * const CMD_ID_SEPARATOR1 = "Perforce.Separator1";
static const char * const CMD_ID_SEPARATOR2 = "Perforce.Separator2"; static const char * const CMD_ID_SEPARATOR2 = "Perforce.Separator2";
static const char * const CMD_ID_SEPARATOR3 = "Perforce.Separator3"; static const char * const CMD_ID_SEPARATOR3 = "Perforce.Separator3";
static const char * const CMD_ID_SEPARATOR4 = "Perforce.Separator4";
//// ////
// PerforcePlugin // PerforcePlugin
...@@ -188,6 +191,8 @@ PerforcePlugin::PerforcePlugin() : ...@@ -188,6 +191,8 @@ PerforcePlugin::PerforcePlugin() :
m_annotateAction(0), m_annotateAction(0),
m_filelogCurrentAction(0), m_filelogCurrentAction(0),
m_filelogAction(0), m_filelogAction(0),
m_logProjectAction(0),
m_logRepositoryAction(0),
m_submitCurrentLogAction(0), m_submitCurrentLogAction(0),
m_updateAllAction(0), m_updateAllAction(0),
m_submitActionTriggered(false), m_submitActionTriggered(false),
...@@ -318,6 +323,12 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e ...@@ -318,6 +323,12 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
connect(m_openedAction, SIGNAL(triggered()), this, SLOT(printOpenedFileList())); connect(m_openedAction, SIGNAL(triggered()), this, SLOT(printOpenedFileList()));
mperforce->addAction(command); mperforce->addAction(command);
m_logProjectAction = new Utils::ParameterAction(tr("Log Project Log"), tr("Log Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
mperforce->addAction(command);
m_submitProjectAction = new Utils::ParameterAction(tr("Submit Project"), tr("Submit Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); m_submitProjectAction = new Utils::ParameterAction(tr("Submit Project"), tr("Submit Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_submitProjectAction, CMD_ID_SUBMIT, globalcontext); command = am->registerAction(m_submitProjectAction, CMD_ID_SUBMIT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
...@@ -385,6 +396,16 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e ...@@ -385,6 +396,16 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
connect(m_filelogAction, SIGNAL(triggered()), this, SLOT(filelog())); connect(m_filelogAction, SIGNAL(triggered()), this, SLOT(filelog()));
mperforce->addAction(command); mperforce->addAction(command);
tmpaction = new QAction(this);
tmpaction->setSeparator(true);
command = am->registerAction(tmpaction, QLatin1String(CMD_ID_SEPARATOR4), globalcontext);
mperforce->addAction(command);
m_logRepositoryAction = new QAction(tr("Repository Log"), this);
command = am->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext);
connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
mperforce->addAction(command);
m_updateAllAction = new QAction(tr("Update All"), this); m_updateAllAction = new QAction(tr("Update All"), this);
command = am->registerAction(m_updateAllAction, CMD_ID_UPDATEALL, globalcontext); command = am->registerAction(m_updateAllAction, CMD_ID_UPDATEALL, globalcontext);
connect(m_updateAllAction, SIGNAL(triggered()), this, SLOT(updateAll())); connect(m_updateAllAction, SIGNAL(triggered()), this, SLOT(updateAll()));
...@@ -715,8 +736,6 @@ void PerforcePlugin::annotate(const QString &workingDir, ...@@ -715,8 +736,6 @@ void PerforcePlugin::annotate(const QString &workingDir,
Core::IEditor *ed = showOutputInEditor(tr("p4 annotate %1").arg(id), Core::IEditor *ed = showOutputInEditor(tr("p4 annotate %1").arg(id),
result.stdOut, VCSBase::AnnotateOutput, result.stdOut, VCSBase::AnnotateOutput,
source, codec); source, codec);
connect(ed, SIGNAL(annotatePreviousRequested(QString,QString,int)),
this, SLOT(annotateVersion(QString,QString,int)));
VCSBase::VCSBaseEditor::gotoLineOfEditor(ed, lineNumber); VCSBase::VCSBaseEditor::gotoLineOfEditor(ed, lineNumber);
} }
} }
...@@ -725,7 +744,7 @@ void PerforcePlugin::filelogCurrentFile() ...@@ -725,7 +744,7 @@ void PerforcePlugin::filelogCurrentFile()
{ {
const VCSBase::VCSBasePluginState state = currentState(); const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return) QTC_ASSERT(state.hasFile(), return)
filelog(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile())); filelog(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), true);
} }
void PerforcePlugin::filelog() void PerforcePlugin::filelog()
...@@ -737,21 +756,40 @@ void PerforcePlugin::filelog() ...@@ -737,21 +756,40 @@ void PerforcePlugin::filelog()
} }
} }
void PerforcePlugin::filelog(const QString &workingDir, const QStringList &fileNames) void PerforcePlugin::logProject()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
filelog(state.currentProjectTopLevel(), perforceRelativeFileArguments(state.relativeCurrentProject()));
}
void PerforcePlugin::logRepository()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
filelog(state.topLevel(), perforceRelativeFileArguments(QStringList()));
}
void PerforcePlugin::filelog(const QString &workingDir, const QStringList &fileNames,
bool enableAnnotationContextMenu)
{ {
const QString id = VCSBase::VCSBaseEditor::getTitleId(workingDir, fileNames); const QString id = VCSBase::VCSBaseEditor::getTitleId(workingDir, fileNames);
QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(workingDir, fileNames); QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(workingDir, fileNames);
QStringList args; QStringList args;
args << QLatin1String("filelog") << QLatin1String("-li"); args << QLatin1String("filelog") << QLatin1String("-li");
if (m_settings.logCount() > 0)
args << QLatin1String("-m") << QString::number(m_settings.logCount());
args.append(fileNames); args.append(fileNames);
const PerforceResponse result = runP4Cmd(workingDir, args, const PerforceResponse result = runP4Cmd(workingDir, args,
CommandToWindow|StdErrToWindow|ErrorToWindow, CommandToWindow|StdErrToWindow|ErrorToWindow,
QStringList(), QByteArray(), codec); QStringList(), QByteArray(), codec);
if (!result.error) if (!result.error) {
showOutputInEditor(tr("p4 filelog %1").arg(id), result.stdOut, const QString source = VCSBase::VCSBaseEditor::getSource(workingDir, fileNames);
VCSBase::LogOutput, Core::IEditor *editor = showOutputInEditor(tr("p4 filelog %1").arg(id), result.stdOut,
VCSBase::VCSBaseEditor::getSource(workingDir, fileNames), VCSBase::LogOutput, source, codec);
codec); if (enableAnnotationContextMenu)
VCSBase::VCSBaseEditor::getVcsBaseEditor(editor)->setFileLogAnnotateEnabled(true);
}
} }
void PerforcePlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) void PerforcePlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
...@@ -759,6 +797,8 @@ void PerforcePlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) ...@@ -759,6 +797,8 @@ void PerforcePlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
if (!VCSBase::VCSBasePlugin::enableMenuAction(as, m_menuAction)) if (!VCSBase::VCSBasePlugin::enableMenuAction(as, m_menuAction))
return; return;
m_logRepositoryAction->setEnabled(currentState().hasTopLevel());
const QString fileName = currentState().currentFileName(); const QString fileName = currentState().currentFileName();
m_editAction->setParameter(fileName); m_editAction->setParameter(fileName);
m_addAction->setParameter(fileName); m_addAction->setParameter(fileName);
...@@ -769,6 +809,7 @@ void PerforcePlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) ...@@ -769,6 +809,7 @@ void PerforcePlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
m_filelogCurrentAction->setParameter(fileName); m_filelogCurrentAction->setParameter(fileName);
const QString projectName = currentState().currentProjectName(); const QString projectName = currentState().currentProjectName();
m_logProjectAction->setParameter(projectName);
m_updateProjectAction->setParameter(projectName); m_updateProjectAction->setParameter(projectName);
m_diffProjectAction->setParameter(projectName); m_diffProjectAction->setParameter(projectName);
m_submitProjectAction->setParameter(projectName); m_submitProjectAction->setParameter(projectName);
...@@ -1110,6 +1151,8 @@ Core::IEditor * PerforcePlugin::showOutputInEditor(const QString& title, const Q ...@@ -1110,6 +1151,8 @@ Core::IEditor * PerforcePlugin::showOutputInEditor(const QString& title, const Q
qDebug() << "PerforcePlugin::showOutputInEditor" << title << kind << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec); qDebug() << "PerforcePlugin::showOutputInEditor" << title << kind << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
QString s = title; QString s = title;
Core::IEditor *editor = Core::EditorManager::instance()->openEditorWithContents(kind, &s, output); Core::IEditor *editor = Core::EditorManager::instance()->openEditorWithContents(kind, &s, output);
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)),
this, SLOT(annotateVersion(QString,QString,int)));
PerforceEditor *e = qobject_cast<PerforceEditor*>(editor->widget()); PerforceEditor *e = qobject_cast<PerforceEditor*>(editor->widget());
if (!e) if (!e)
return 0; return 0;
......
...@@ -123,6 +123,8 @@ private slots: ...@@ -123,6 +123,8 @@ private slots:
void annotateVersion(const QString &file, const QString &revision, int lineNumber); void annotateVersion(const QString &file, const QString &revision, int lineNumber);
void filelogCurrentFile(); void filelogCurrentFile();
void filelog(); void filelog();
void logProject();
void logRepository();
void submitCurrentLog(); void submitCurrentLog();
void printPendingChanges(); void printPendingChanges();
...@@ -177,7 +179,8 @@ private: ...@@ -177,7 +179,8 @@ private:
QString clientFilePath(const QString &serverFilePath); QString clientFilePath(const QString &serverFilePath);
void annotate(const QString &workingDir, const QString &fileName, void annotate(const QString &workingDir, const QString &fileName,
const QString &changeList = QString(), int lineNumber = -1); const QString &changeList = QString(), int lineNumber = -1);
void filelog(const QString &workingDir, const QStringList &fileNames); void filelog(const QString &workingDir, const QStringList &fileNames = QStringList(),
bool enableAnnotationContextMenu = false);
void cleanCommitMessageFile(); void cleanCommitMessageFile();
bool isCommitEditorOpen() const; bool isCommitEditorOpen() const;
QSharedPointer<QTemporaryFile> createTemporaryArgumentFile(const QStringList &extraArgs) const; QSharedPointer<QTemporaryFile> createTemporaryArgumentFile(const QStringList &extraArgs) const;
...@@ -208,6 +211,8 @@ private: ...@@ -208,6 +211,8 @@ private:
QAction *m_annotateAction; QAction *m_annotateAction;
Utils::ParameterAction *m_filelogCurrentAction; Utils::ParameterAction *m_filelogCurrentAction;
QAction *m_filelogAction; QAction *m_filelogAction;
Utils::ParameterAction *m_logProjectAction;
QAction *m_logRepositoryAction;
QAction *m_submitCurrentLogAction; QAction *m_submitCurrentLogAction;
QAction *m_updateAllAction; QAction *m_updateAllAction;
bool m_submitActionTriggered; bool m_submitActionTriggered;
......
...@@ -47,8 +47,9 @@ static const char *clientKeyC = "Client"; ...@@ -47,8 +47,9 @@ static const char *clientKeyC = "Client";
static const char *userKeyC = "User"; static const char *userKeyC = "User";
static const char *promptToSubmitKeyC = "PromptForSubmit"; static const char *promptToSubmitKeyC = "PromptForSubmit";
static const char *timeOutKeyC = "TimeOut"; static const char *timeOutKeyC = "TimeOut";
static const char *logCountKeyC = "LogCount";
enum { defaultTimeOutS = 30 }; enum { defaultTimeOutS = 30, defaultLogCount = 1000 };
static QString defaultCommand() static QString defaultCommand()
{ {
...@@ -64,6 +65,7 @@ namespace Perforce { ...@@ -64,6 +65,7 @@ namespace Perforce {
namespace Internal { namespace Internal {
Settings::Settings() : Settings::Settings() :
logCount(defaultLogCount),
defaultEnv(true), defaultEnv(true),
timeOutS(defaultTimeOutS), timeOutS(defaultTimeOutS),
promptToSubmit(true) promptToSubmit(true)
...@@ -73,6 +75,7 @@ Settings::Settings() : ...@@ -73,6 +75,7 @@ Settings::Settings() :
bool Settings::equals(const Settings &rhs) const bool Settings::equals(const Settings &rhs) const
{ {
return defaultEnv == rhs.defaultEnv return defaultEnv == rhs.defaultEnv
&& logCount == rhs.logCount
&& p4Command == rhs.p4Command && p4Port == rhs.p4Port && p4Command == rhs.p4Command && p4Port == rhs.p4Port
&& p4Client == rhs.p4Client && p4User == rhs.p4User && p4Client == rhs.p4Client && p4User