Commit 7b08d993 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

VCS: Pass workingDirectory for annotate



Required for supporting renames on annotate.

The renamed file (and possibly its parent directory) doesn't exist
anymore, so it shouldn't be passed as a working directory.

Change-Id: I809e8df17c1dc5199e533b525244a668eccbcd5f
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 0bb9ab13
......@@ -1253,12 +1253,12 @@ void ClearCasePlugin::annotateCurrentFile()
vcsAnnotate(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void ClearCasePlugin::annotateVersion(const QString &file,
const QString &revision,
int lineNr)
void ClearCasePlugin::annotateVersion(const QString &workingDirectory,
const QString &file,
const QString &revision,
int lineNr)
{
const QFileInfo fi(file);
vcsAnnotate(fi.absolutePath(), fi.fileName(), revision, lineNr);
vcsAnnotate(workingDirectory, file, revision, lineNr);
}
void ClearCasePlugin::vcsAnnotate(const QString &workingDir, const QString &file,
......@@ -1402,8 +1402,8 @@ IEditor *ClearCasePlugin::showOutputInEditor(const QString& title, const QString
<< "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
QString s = title;
IEditor *editor = EditorManager::openEditorWithContents(id, &s, output.toUtf8());
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)),
this, SLOT(annotateVersion(QString,QString,int)));
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
this, SLOT(annotateVersion(QString,QString,QString,int)));
ClearCaseEditor *e = qobject_cast<ClearCaseEditor*>(editor->widget());
if (!e)
return 0;
......
......@@ -185,7 +185,7 @@ private slots:
void startCheckInCurrentFile();
void historyCurrentFile();
void annotateCurrentFile();
void annotateVersion(const QString &file, const QString &revision, int lineNumber);
void annotateVersion(const QString &workingDirectory, const QString &file, const QString &revision, int lineNumber);
void describe(const QString &source, const QString &changeNr);
void viewStatus();
void checkInSelected();
......
......@@ -148,7 +148,8 @@ bool CvsControl::vcsRemoveSnapshot(const QString &, const QString &)
bool CvsControl::vcsAnnotate(const QString &file, int line)
{
m_plugin->vcsAnnotate(file, QString(), line);
const QFileInfo fi(file);
m_plugin->vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
......
......@@ -923,10 +923,10 @@ void CvsPlugin::annotateCurrentFile()
annotate(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void CvsPlugin::vcsAnnotate(const QString &file, const QString &revision, int lineNumber)
void CvsPlugin::vcsAnnotate(const QString &workingDirectory, const QString &file,
const QString &revision, int lineNumber)
{
const QFileInfo fi(file);
annotate(fi.absolutePath(), fi.fileName(), revision, lineNumber);
annotate(workingDirectory, file, revision, lineNumber);
}
bool CvsPlugin::edit(const QString &topLevel, const QStringList &files)
......@@ -1274,8 +1274,8 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp
<< "source=" << source << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
QString s = title;
IEditor *editor = EditorManager::openEditorWithContents(id, &s, output.toUtf8());
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)),
this, SLOT(vcsAnnotate(QString,QString,int)));
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
this, SLOT(vcsAnnotate(QString,QString,QString,int)));
CvsEditor *e = qobject_cast<CvsEditor*>(editor->widget());
if (!e)
return 0;
......
......@@ -96,7 +96,8 @@ public:
static CvsPlugin *instance();
public slots:
void vcsAnnotate(const QString &file, const QString &revision /* = QString() */, int lineNumber);
void vcsAnnotate(const QString &workingDirectory, const QString &file,
const QString &revision, int lineNumber);
private slots:
void addCurrentFile();
......
......@@ -1038,8 +1038,8 @@ VcsBase::VcsBaseEditorWidget *GitClient::createVcsEditor(
m_msgWait.toUtf8());
outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
rc = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor);
connect(rc, SIGNAL(annotateRevisionRequested(QString,QString,int)),
this, SLOT(slotBlameRevisionRequested(QString,QString,int)));
connect(rc, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
this, SLOT(slotBlameRevisionRequested(QString,QString,QString,int)));
QTC_ASSERT(rc, return 0);
rc->setSource(source);
if (codecType == CodecSource) {
......@@ -1461,15 +1461,15 @@ void GitClient::saveSettings()
settings()->writeSettings(Core::ICore::settings());
}
void GitClient::slotBlameRevisionRequested(const QString &source, QString change, int lineNumber)
void GitClient::slotBlameRevisionRequested(const QString &workingDirectory, const QString &file,
QString change, int lineNumber)
{
// This might be invoked with a verbose revision description
// "SHA1 author subject" from the annotation context menu. Strip the rest.
const int blankPos = change.indexOf(QLatin1Char(' '));
if (blankPos != -1)
change.truncate(blankPos);
const QFileInfo fi(source);
blame(fi.absolutePath(), QStringList(), fi.fileName(), change, lineNumber);
blame(workingDirectory, QStringList(), file, change, lineNumber);
}
QTextCodec *GitClient::getSourceCodec(const QString &file) const
......
......@@ -335,7 +335,8 @@ public slots:
void saveSettings();
private slots:
void slotBlameRevisionRequested(const QString &source, QString change, int lineNumber);
void slotBlameRevisionRequested(const QString &workingDirectory, const QString &file,
QString change, int lineNumber);
void finishSubmoduleUpdate();
void fetchFinished(const QVariant &cookie);
......
......@@ -692,10 +692,10 @@ void PerforcePlugin::annotate()
}
}
void PerforcePlugin::vcsAnnotate(const QString &file, const QString &revision, int lineNumber)
void PerforcePlugin::vcsAnnotate(const QString &workingDirectory, const QString &file,
const QString &revision, int lineNumber)
{
const QFileInfo fi(file);
annotate(fi.absolutePath(), fi.fileName(), revision, lineNumber);
annotate(workingDirectory, file, revision, lineNumber);
}
void PerforcePlugin::annotate(const QString &workingDir,
......@@ -1166,8 +1166,8 @@ Core::IEditor *PerforcePlugin::showOutputInEditor(const QString &title, const QS
<< "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
QString s = title;
Core::IEditor *editor = Core::EditorManager::openEditorWithContents(id, &s, output.toUtf8());
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)),
this, SLOT(vcsAnnotate(QString,QString,int)));
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
this, SLOT(vcsAnnotate(QString,QString,QString,int)));
PerforceEditor *e = qobject_cast<PerforceEditor*>(editor->widget());
if (!e)
return 0;
......
......@@ -105,7 +105,8 @@ public:
public slots:
void describe(const QString &source, const QString &n);
void vcsAnnotate(const QString &file, const QString &revision /* = QString() */, int lineNumber);
void vcsAnnotate(const QString &workingDirectory, const QString &file,
const QString &revision, int lineNumber);
void p4Diff(const Perforce::Internal::PerforceDiffParameters &p);
private slots:
......
......@@ -147,7 +147,8 @@ bool PerforceVersionControl::vcsRemoveSnapshot(const QString &, const QString &)
bool PerforceVersionControl::vcsAnnotate(const QString &file, int line)
{
m_plugin->vcsAnnotate(file, QString(), line);
const QFileInfo fi(file);
m_plugin->vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
......
......@@ -940,12 +940,12 @@ void SubversionPlugin::annotateCurrentFile()
vcsAnnotate(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void SubversionPlugin::annotateVersion(const QString &file,
void SubversionPlugin::annotateVersion(const QString &workingDirectory,
const QString &file,
const QString &revision,
int lineNr)
{
const QFileInfo fi(file);
vcsAnnotate(fi.absolutePath(), fi.fileName(), revision, lineNr);
vcsAnnotate(workingDirectory, file, revision, lineNr);
}
void SubversionPlugin::vcsAnnotate(const QString &workingDir, const QString &file,
......@@ -1177,8 +1177,8 @@ Core::IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const
<< "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
QString s = title;
Core::IEditor *editor = Core::EditorManager::openEditorWithContents(id, &s, output.toUtf8());
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)),
this, SLOT(annotateVersion(QString,QString,int)));
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
this, SLOT(annotateVersion(QString,QString,QString,int)));
SubversionEditor *e = qobject_cast<SubversionEditor*>(editor->widget());
if (!e)
return 0;
......
......@@ -131,7 +131,7 @@ private slots:
void revertAll();
void filelogCurrentFile();
void annotateCurrentFile();
void annotateVersion(const QString &file, const QString &revision, int lineNumber);
void annotateVersion(const QString &workingDirectory, const QString &file, const QString &revision, int lineNumber);
void projectStatus();
void describe(const QString &source, const QString &changeNr);
void slotDescribe();
......
......@@ -90,7 +90,8 @@ public:
VcsBaseClientPrivate(VcsBaseClient *client, VcsBaseClientSettings *settings);
void statusParser(const QString &text);
void annotateRevision(QString source, QString change, int lineNumber);
void annotateRevision(const QString &workingDirectory, const QString &file,
QString change, int lineNumber);
void saveSettings();
void bindCommandToEditor(Command *cmd, VcsBaseEditorWidget *editor);
......@@ -125,15 +126,15 @@ void VcsBaseClientPrivate::statusParser(const QString &text)
emit m_client->parsedStatus(lineInfoList);
}
void VcsBaseClientPrivate::annotateRevision(QString source, QString change, int lineNumber)
void VcsBaseClientPrivate::annotateRevision(const QString &workingDirectory, const QString &file,
QString change, int lineNumber)
{
// This might be invoked with a verbose revision description
// "SHA1 author subject" from the annotation context menu. Strip the rest.
const int blankPos = change.indexOf(QLatin1Char(' '));
if (blankPos != -1)
change.truncate(blankPos);
const QFileInfo fi(source);
m_client->annotate(fi.absolutePath(), fi.fileName(), change, lineNumber);
m_client->annotate(workingDirectory, file, change, lineNumber);
}
void VcsBaseClientPrivate::saveSettings()
......@@ -574,8 +575,8 @@ VcsBase::VcsBaseEditorWidget *VcsBaseClient::createVcsEditor(Core::Id kind, QStr
outputEditor = Core::EditorManager::openEditorWithContents(kind, &title, progressMsg.toUtf8());
outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
baseEditor = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor);
connect(baseEditor, SIGNAL(annotateRevisionRequested(QString,QString,int)),
this, SLOT(annotateRevision(QString,QString,int)));
connect(baseEditor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
this, SLOT(annotateRevision(QString,QString,QString,int)));
QTC_ASSERT(baseEditor, return 0);
baseEditor->setSource(source);
if (setSourceCodec)
......
......@@ -194,7 +194,7 @@ private:
VcsBaseClientPrivate *d;
Q_PRIVATE_SLOT(d, void statusParser(QString))
Q_PRIVATE_SLOT(d, void annotateRevision(QString, QString, int))
Q_PRIVATE_SLOT(d, void annotateRevision(QString, QString, QString, int))
Q_PRIVATE_SLOT(d, void saveSettings())
Q_PRIVATE_SLOT(d, void commandFinishedGotoLine(QWidget *))
};
......
......@@ -158,7 +158,8 @@ public:
signals:
void describeRequested(const QString &source, const QString &change);
void annotateRevisionRequested(const QString &source, const QString &change, int line);
void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
const QString &change, int line);
private:
Core::Id m_id;
......@@ -818,8 +819,8 @@ TextEditor::BaseTextEditor *VcsBaseEditorWidget::createEditor()
// Pass on signals.
connect(this, SIGNAL(describeRequested(QString,QString)),
editor, SIGNAL(describeRequested(QString,QString)));
connect(this, SIGNAL(annotateRevisionRequested(QString,QString,int)),
editor, SIGNAL(annotateRevisionRequested(QString,QString,int)));
connect(this, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)));
return editor;
}
......@@ -1412,9 +1413,11 @@ void VcsBaseEditorWidget::addDiffActions(QMenu *, const DiffChunk &)
void VcsBaseEditorWidget::slotAnnotateRevision()
{
if (const QAction *a = qobject_cast<const QAction *>(sender()))
emit annotateRevisionRequested(source(), a->data().toString(),
editor()->currentLine());
if (const QAction *a = qobject_cast<const QAction *>(sender())) {
QFileInfo fi(source());
emit annotateRevisionRequested(fi.absolutePath(), fi.fileName(),
a->data().toString(), currentLine);
}
}
QStringList VcsBaseEditorWidget::annotationPreviousVersions(const QString &) const
......
......@@ -202,7 +202,8 @@ signals:
// handled by the editor manager for convenience. They are emitted
// for LogOutput/AnnotateOutput content types.
void describeRequested(const QString &source, const QString &change);
void annotateRevisionRequested(const QString &source, const QString &change, int lineNumber);
void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
const QString &change, int lineNumber);
void diffChunkApplied(const VcsBase::DiffChunk &dc);
void diffChunkReverted(const VcsBase::DiffChunk &dc);
......
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