Commit 7b39f41c authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

VCS: Refactor fileNameFromDiffSpecification

Use diff file pattern to match file name. Avoid duplication.

Include unit tests for Git

Change-Id: Ib68a08368270a27976a3e16bdd1cb219a52b8889
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 57ee50d5
......@@ -52,11 +52,13 @@ using namespace Bazaar;
BazaarEditor::BazaarEditor(const VcsBase::VcsBaseEditorParameters *type, QWidget *parent)
: VcsBase::VcsBaseEditorWidget(type, parent),
m_changesetId(QLatin1String(Constants::CHANGESET_ID)),
m_exactChangesetId(QLatin1String(Constants::CHANGESET_ID_EXACT)),
m_diffFileId(QLatin1String("^=== [a-z]+ [a-z]+ '(.*)'\\s*"))
m_exactChangesetId(QLatin1String(Constants::CHANGESET_ID_EXACT))
{
setAnnotateRevisionTextFormat(tr("Annotate %1"));
setAnnotatePreviousRevisionTextFormat(tr("Annotate parent revision %1"));
// Diff format:
// === <change> <file|dir> 'mainwindow.cpp'
setDiffFilePattern(QRegExp(QLatin1String("^=== [a-z]+ [a-z]+ '(.+)'\\s*")));
}
QSet<QString> BazaarEditor::annotationChanges() const
......@@ -111,25 +113,8 @@ QString BazaarEditor::changeUnderCursor(const QTextCursor &cursorIn) const
return QString();
}
QRegExp BazaarEditor::diffFilePattern() const
{
return m_diffFileId;
}
VcsBase::BaseAnnotationHighlighter *BazaarEditor::createAnnotationHighlighter(const QSet<QString> &changes,
const QColor &bg) const
{
return new BazaarAnnotationHighlighter(changes, bg);
}
QString BazaarEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) const
{
// Check for:
// === <change> <file|dir> 'mainwindow.cpp'
for (QTextBlock block = inBlock; block.isValid(); block = block.previous()) {
const QString line = block.text();
if (m_diffFileId.indexIn(line) != -1)
return findDiffFile(m_diffFileId.cap(1));
}
return QString();
}
......@@ -46,13 +46,10 @@ public:
private:
QSet<QString> annotationChanges() const;
QString changeUnderCursor(const QTextCursor &cursor) const;
QRegExp diffFilePattern() const;
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes, const QColor &bg) const;
QString fileNameFromDiffSpecification(const QTextBlock &diffFileSpec) const;
mutable QRegExp m_changesetId;
mutable QRegExp m_exactChangesetId;
mutable QRegExp m_diffFileId;
};
} // namespace Internal
......
......@@ -591,6 +591,41 @@ void BazaarPlugin::diffFromEditorSelected(const QStringList &files)
m_client->diff(m_submitRepository, files);
}
#ifdef WITH_TESTS
#include <QTest>
void BazaarPlugin::testDiffFileResolving_data()
{
QTest::addColumn<QByteArray>("header");
QTest::addColumn<QByteArray>("fileName");
QTest::newRow("New") << QByteArray(
"=== added file 'src/plugins/bazaar/bazaareditor.cpp'\n"
"--- src/plugins/bazaar/bazaareditor.cpp\t1970-01-01 00:00:00 +0000\n"
"+++ src/plugins/bazaar/bazaareditor.cpp\t2013-01-20 21:39:47 +0000\n"
"@@ -0,0 +1,121 @@\n\n")
<< QByteArray("src/plugins/bazaar/bazaareditor.cpp");
QTest::newRow("Deleted") << QByteArray(
"=== removed file 'src/plugins/bazaar/bazaareditor.cpp'\n"
"--- src/plugins/bazaar/bazaareditor.cpp\t2013-01-20 21:39:47 +0000\n"
"+++ src/plugins/bazaar/bazaareditor.cpp\t1970-01-01 00:00:00 +0000\n"
"@@ -1,121 +0,0 @@\n\n")
<< QByteArray("src/plugins/bazaar/bazaareditor.cpp");
QTest::newRow("Modified") << QByteArray(
"=== modified file 'src/plugins/bazaar/bazaareditor.cpp'\n"
"--- src/plugins/bazaar/bazaareditor.cpp\t2010-08-27 14:12:44 +0000\n"
"+++ src/plugins/bazaar/bazaareditor.cpp\t2011-02-28 21:24:19 +0000\n"
"@@ -727,6 +727,9 @@\n\n")
<< QByteArray("src/plugins/bazaar/bazaareditor.cpp");
}
void BazaarPlugin::testDiffFileResolving()
{
BazaarEditor editor(editorParameters + 3, 0);
VcsBase::VcsBaseEditorWidget::testDiffFileResolving(&editor);
}
#endif
void BazaarPlugin::commitFromEditor()
{
// Close the submit editor
......
......@@ -112,6 +112,10 @@ private slots:
void showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status);
void commitFromEditor();
void diffFromEditorSelected(const QStringList &files);
#ifdef WITH_TESTS
void testDiffFileResolving_data();
void testDiffFileResolving();
#endif
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
......
......@@ -51,6 +51,12 @@ ClearCaseEditor::ClearCaseEditor(const VcsBase::VcsBaseEditorParameters *type,
m_versionNumberPattern(QLatin1String("[\\\\/]main[\\\\/][^ \t\n\"]*"))
{
QTC_ASSERT(m_versionNumberPattern.isValid(), return);
// Diff formats:
// "+++ D:\depot\...\mainwindow.cpp@@\main\3" (versioned)
// "+++ D:\depot\...\mainwindow.cpp[TAB]Sun May 01 14:22:37 2011" (local)
QRegExp diffFilePattern(QLatin1String("^[-+]{3} ([^\\t]+)(?:@@|\\t)"));
diffFilePattern.setMinimal(true);
setDiffFilePattern(diffFilePattern);
setAnnotateRevisionTextFormat(tr("Annotate version \"%1\""));
}
......@@ -87,41 +93,8 @@ QString ClearCaseEditor::changeUnderCursor(const QTextCursor &c) const
return QString();
}
/*
Diff header format (on Windows, native separators are used after the @@)
--- main.cpp@@\main\2
+++ main.cpp@@\main\1
@@ -6,6 +6,5 @@
*/
QRegExp ClearCaseEditor::diffFilePattern() const
{
return QRegExp(QLatin1String("^[-+][-+][-+] "));
}
VcsBase::BaseAnnotationHighlighter *ClearCaseEditor::createAnnotationHighlighter(const QSet<QString> &changes,
const QColor &bg) const
{
return new ClearCaseAnnotationHighlighter(changes, bg);
}
QString ClearCaseEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) const
{
// "+++ D:\depot\...\mainwindow.cpp@@\main\3"
// "+++ D:\depot\...\mainwindow.cpp[TAB]Sun May 01 14:22:37 2011"
// Go back chunks
const QString diffIndicator = QLatin1String("+++ ");
for (QTextBlock block = inBlock; block.isValid() ; block = block.previous()) {
QString diffFileName = block.text();
if (diffFileName.startsWith(diffIndicator)) {
diffFileName.remove(0, diffIndicator.size());
const int tabIndex = diffFileName.indexOf(QRegExp(QLatin1String("@@|\t")));
if (tabIndex != -1)
diffFileName.truncate(tabIndex);
const QString rc = findDiffFile(diffFileName);
if (ClearCase::Constants::debug)
qDebug() << Q_FUNC_INFO << diffFileName << rc << source();
return rc;
}
}
return QString();
}
......@@ -49,11 +49,9 @@ public:
private:
QSet<QString> annotationChanges() const;
QString changeUnderCursor(const QTextCursor &) const;
QRegExp diffFilePattern() const;
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes, const QColor &bg) const;
QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const;
mutable QRegExp m_versionNumberPattern;
QRegExp m_versionNumberPattern;
};
} // namespace Internal
......
......@@ -96,7 +96,9 @@
#include <QVariant>
#include <QVBoxLayout>
#include <QXmlStreamReader>
#ifdef WITH_TESTS
#include <QTest>
#endif
namespace ClearCase {
namespace Internal {
......@@ -1943,6 +1945,26 @@ void ClearCasePlugin::sync(QFutureInterface<void> &future, QString topLevel, QSt
ccSync.run(future, topLevel, files);
}
#ifdef WITH_TESTS
void ClearCasePlugin::testDiffFileResolving_data()
{
QTest::addColumn<QByteArray>("header");
QTest::addColumn<QByteArray>("fileName");
QTest::newRow("Modified") << QByteArray(
"--- src/plugins/clearcase/clearcaseeditor.cpp@@/main/1\t2013-01-20 23:45:48.549615210 +0200\n"
"+++ src/plugins/clearcase/clearcaseeditor.cpp@@/main/2\t2013-01-20 23:45:53.217604679 +0200\n"
"@@ -58,6 +58,10 @@\n\n")
<< QByteArray("src/plugins/clearcase/clearcaseeditor.cpp");
}
void ClearCasePlugin::testDiffFileResolving()
{
ClearCaseEditor editor(editorParameters + 3, 0);
VcsBase::VcsBaseEditorWidget::testDiffFileResolving(&editor);
}
#endif
} // namespace Internal
} // namespace ClearCase
......
......@@ -192,6 +192,10 @@ private slots:
void syncSlot();
void closing();
void updateStatusActions();
#ifdef WITH_TESTS
void testDiffFileResolving_data();
void testDiffFileResolving();
#endif
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
......
......@@ -55,6 +55,15 @@ CvsEditor::CvsEditor(const VcsBase::VcsBaseEditorParameters *type,
{
QTC_ASSERT(m_revisionAnnotationPattern.isValid(), return);
QTC_ASSERT(m_revisionLogPattern.isValid(), return);
/* Diff format:
\code
cvs diff -d -u -r1.1 -r1.2:
--- mainwindow.cpp<\t>13 Jul 2009 13:50:15 -0000<tab>1.1
+++ mainwindow.cpp<\t>14 Jul 2009 07:09:24 -0000<tab>1.2
@@ -6,6 +6,5 @@
\endcode
*/
setDiffFilePattern(QRegExp(QLatin1String("^[-+]{3} ([^\\t]+)")));
setAnnotateRevisionTextFormat(tr("Annotate revision \"%1\""));
}
......@@ -113,42 +122,12 @@ QString CvsEditor::changeUnderCursor(const QTextCursor &c) const
return QString();
}
/* \code
cvs diff -d -u -r1.1 -r1.2:
--- mainwindow.cpp<\t>13 Jul 2009 13:50:15 -0000 <\t>1.1
+++ mainwindow.cpp<\t>14 Jul 2009 07:09:24 -0000<\t>1.2
@@ -6,6 +6,5 @@
\endcode
*/
QRegExp CvsEditor::diffFilePattern() const
{
return QRegExp(QLatin1String("^[-+][-+][-+] .*1\\.[\\d\\.]+$"));
}
VcsBase::BaseAnnotationHighlighter *CvsEditor::createAnnotationHighlighter(const QSet<QString> &changes,
const QColor &bg) const
{
return new CvsAnnotationHighlighter(changes, bg);
}
QString CvsEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) const
{
// "+++ mainwindow.cpp<\t>13 Jul 2009 13:50:15 -0000 1.1"
// Go back chunks
const QString diffIndicator = QLatin1String("+++ ");
for (QTextBlock block = inBlock; block.isValid() ; block = block.previous()) {
QString diffFileName = block.text();
if (diffFileName.startsWith(diffIndicator)) {
diffFileName.remove(0, diffIndicator.size());
const int tabIndex = diffFileName.indexOf(QLatin1Char('\t'));
if (tabIndex != -1)
diffFileName.truncate(tabIndex);
return findDiffFile(diffFileName);
}
}
return QString();
}
QStringList CvsEditor::annotationPreviousVersions(const QString &revision) const
{
if (isFirstRevision(revision))
......
......@@ -48,9 +48,7 @@ public:
private:
QSet<QString> annotationChanges() const;
QString changeUnderCursor(const QTextCursor &) const;
QRegExp diffFilePattern() const;
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes, const QColor &bg) const;
QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const;
QStringList annotationPreviousVersions(const QString &revision) const;
mutable QRegExp m_revisionAnnotationPattern;
......
......@@ -66,6 +66,13 @@ GitEditor::GitEditor(const VcsBase::VcsBaseEditorParameters *type,
{
QTC_ASSERT(m_changeNumberPattern8.isValid(), return);
QTC_ASSERT(m_changeNumberPattern40.isValid(), return);
/* Diff format:
diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp
index 40997ff..4e49337 100644
--- a/src/plugins/git/giteditor.cpp
+++ b/src/plugins/git/giteditor.cpp
*/
setDiffFilePattern(QRegExp(QLatin1String("^(?:diff --git a/|index |[+-]{3} (?:/dev/null|[ab]/(.+$)))")));
setAnnotateRevisionTextFormat(tr("Blame %1"));
setAnnotatePreviousRevisionTextFormat(tr("Blame Parent Revision %1"));
}
......@@ -107,46 +114,12 @@ QString GitEditor::changeUnderCursor(const QTextCursor &c) const
return QString();
}
QRegExp GitEditor::diffFilePattern() const
{
return QRegExp(QLatin1String("^(diff --git a/|index |[+-][+-][+-] [ab/]).*$"));
}
VcsBase::BaseAnnotationHighlighter *GitEditor::createAnnotationHighlighter(const QSet<QString> &changes,
const QColor &bg) const
{
return new GitAnnotationHighlighter(changes, bg);
}
QString GitEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) const
{
// Check for "+++ b/src/plugins/git/giteditor.cpp" (blame and diff)
// as well as "--- a/src/plugins/git/giteditor.cpp".
// Go back chunks.
bool checkForOld = false;
const QString oldFileIndicator = QLatin1String("--- a/");
const QString newFileIndicator = QLatin1String("+++ ");
for (QTextBlock block = inBlock; block.isValid(); block = block.previous()) {
QString diffFileName = block.text();
if (diffFileName.startsWith(oldFileIndicator) && checkForOld) {
diffFileName.remove(0, oldFileIndicator.size());
checkForOld = false;
return diffFileName;
} else if (diffFileName.startsWith(newFileIndicator)) {
diffFileName.remove(0, newFileIndicator.size());
if (diffFileName == QLatin1String("/dev/null")) {
checkForOld = true;
continue;
}
diffFileName.remove(0, 2); // remove "b/"
return findDiffFile(diffFileName);
}
checkForOld = false;
}
return QString();
}
/* Remove the date specification from annotation, which is tabular:
\code
8ca887aa (author YYYY-MM-DD HH:MM:SS <offset> <line>)<content>
......
......@@ -57,9 +57,7 @@ public slots:
private:
QSet<QString> annotationChanges() const;
QString changeUnderCursor(const QTextCursor &) const;
QRegExp diffFilePattern() const;
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes, const QColor &bg) const;
QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const;
QString decorateVersion(const QString &revision) const;
QStringList annotationPreviousVersions(const QString &revision) const;
bool isValidRevision(const QString &revision) const;
......
......@@ -1253,8 +1253,14 @@ GitClient *GitPlugin::gitClient() const
}
#ifdef WITH_TESTS
#include "giteditor.h"
#include <QTest>
#include <QTextBlock>
#include <QTextDocument>
Q_DECLARE_METATYPE(FileStates)
void GitPlugin::testStatusParsing_data()
{
QTest::addColumn<FileStates>("first");
......@@ -1301,6 +1307,42 @@ void GitPlugin::testStatusParsing()
else
QCOMPARE(data.files.at(1).first, second);
}
void GitPlugin::testDiffFileResolving_data()
{
QTest::addColumn<QByteArray>("header");
QTest::addColumn<QByteArray>("fileName");
QTest::newRow("New") << QByteArray(
"diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp\n"
"new file mode 100644\n"
"index 0000000..40997ff\n"
"--- /dev/null\n"
"+++ b/src/plugins/git/giteditor.cpp\n"
"@@ -0,0 +1,281 @@\n\n")
<< QByteArray("src/plugins/git/giteditor.cpp");
QTest::newRow("Deleted") << QByteArray(
"diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp\n"
"deleted file mode 100644\n"
"index 40997ff..0000000\n"
"--- a/src/plugins/git/giteditor.cpp\n"
"+++ /dev/null\n"
"@@ -1,281 +0,0 @@\n\n")
<< QByteArray("src/plugins/git/giteditor.cpp");
QTest::newRow("Normal") << QByteArray(
"diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp\n"
"index 69e0b52..8fc974d 100644\n"
"--- a/src/plugins/git/giteditor.cpp\n"
"+++ b/src/plugins/git/giteditor.cpp\n"
"@@ -49,6 +49,8 @@\n\n")
<< QByteArray("src/plugins/git/giteditor.cpp");
}
void GitPlugin::testDiffFileResolving()
{
GitEditor editor(editorParameters + 3, 0);
VcsBase::VcsBaseEditorWidget::testDiffFileResolving(&editor);
}
#endif
Q_EXPORT_PLUGIN(GitPlugin)
......@@ -144,6 +144,8 @@ private slots:
#ifdef WITH_TESTS
void testStatusParsing_data();
void testStatusParsing();
void testDiffFileResolving_data();
void testDiffFileResolving();
#endif
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
......
......@@ -42,7 +42,7 @@ const char CHANGESETID12[] = " ([a-f0-9]{12,12}) "; //match 12 hex chars and cap
const char CHANGESETID40[] = " ([a-f0-9]{40,40}) ";
const char CHANGEIDEXACT12[] = "[a-f0-9]{12,12}"; //match 12 hex chars a
const char CHANGEIDEXACT40[] = "[a-f0-9]{40,40}";
const char DIFFIDENTIFIER[] = "^[-+]{3,3} [ab]{1,1}.*"; // match e.g. +++ b/filename
const char DIFFIDENTIFIER[] = "^[-+]{3} [ab]/(.+)$"; // match e.g. +++ b/filename
// Base editor parameters
const char COMMANDLOG_ID[] = "Mercurial Command Log Editor";
......
......@@ -51,9 +51,9 @@ MercurialEditor::MercurialEditor(const VcsBase::VcsBaseEditorParameters *type, Q
exactIdentifier12(QLatin1String(Constants::CHANGEIDEXACT12)),
exactIdentifier40(QLatin1String(Constants::CHANGEIDEXACT40)),
changesetIdentifier12(QLatin1String(Constants::CHANGESETID12)),
changesetIdentifier40(QLatin1String(Constants::CHANGESETID40)),
diffIdentifier(QLatin1String(Constants::DIFFIDENTIFIER))
changesetIdentifier40(QLatin1String(Constants::CHANGESETID40))
{
setDiffFilePattern(QRegExp(QLatin1String(Constants::DIFFIDENTIFIER)));
setAnnotateRevisionTextFormat(tr("Annotate %1"));
setAnnotatePreviousRevisionTextFormat(tr("Annotate parent revision %1"));
}
......@@ -88,33 +88,12 @@ QString MercurialEditor::changeUnderCursor(const QTextCursor &cursorIn) const
return QString();
}
QRegExp MercurialEditor::diffFilePattern() const
{
return diffIdentifier;
}
VcsBase::BaseAnnotationHighlighter *MercurialEditor::createAnnotationHighlighter(const QSet<QString> &changes,
const QColor &bg) const
{
return new MercurialAnnotationHighlighter(changes, bg);
}
QString MercurialEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) const
{
// git-compatible format: check for "+++ b/src/plugins/git/giteditor.cpp" (blame and diff)
// Go back chunks.
const QString newFileIndicator = QLatin1String("+++ b/");
for (QTextBlock block = inBlock; block.isValid(); block = block.previous()) {
QString diffFileName = block.text();
if (diffFileName.startsWith(newFileIndicator)) {
diffFileName.remove(0, newFileIndicator.size());
return findDiffFile(diffFileName);
}
}
return QString();
}
QString MercurialEditor::decorateVersion(const QString &revision) const
{
const QFileInfo fi(source());
......
......@@ -46,9 +46,7 @@ public:
private:
QSet<QString> annotationChanges() const;
QString changeUnderCursor(const QTextCursor &cursor) const;
QRegExp diffFilePattern() const;
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes, const QColor &bg) const;
QString fileNameFromDiffSpecification(const QTextBlock &diffFileSpec) const;
QString decorateVersion(const QString &revision) const;
QStringList annotationPreviousVersions(const QString &revision) const;
......@@ -56,7 +54,6 @@ private:
mutable QRegExp exactIdentifier40;
mutable QRegExp changesetIdentifier12;
const QRegExp changesetIdentifier40;
const QRegExp diffIdentifier;
};
} // namespace Internal
......
......@@ -63,6 +63,10 @@ PerforceEditor::PerforceEditor(const VcsBase::VcsBaseEditorParameters *type,
m_plugin(PerforcePlugin::perforcePluginInstance())
{
QTC_CHECK(m_changeNumberPattern.isValid());
// Diff format:
// 1) "==== //depot/.../mainwindow.cpp#2 - /depot/.../mainwindow.cpp ====" (created by p4 diff)
// 2) "==== //depot/.../mainwindow.cpp#15 (text) ====" (created by p4 describe)
setDiffFilePattern(QRegExp(QLatin1String("^==== (.+)#\\d")));
setAnnotateRevisionTextFormat(tr("Annotate change list \"%1\""));
if (Perforce::Constants::debug)
qDebug() << "PerforceEditor::PerforceEditor" << type->type << type->id;
......@@ -103,57 +107,19 @@ QString PerforceEditor::changeUnderCursor(const QTextCursor &c) const
return m_changeNumberPattern.exactMatch(change) ? change : QString();
}
QRegExp PerforceEditor::diffFilePattern() const
{
return QRegExp(QLatin1String("^====.*"));
}
VcsBase::BaseAnnotationHighlighter *PerforceEditor::createAnnotationHighlighter(const QSet<QString> &changes,
const QColor &bg) const
{
return new PerforceAnnotationHighlighter(changes, bg);
}
QString PerforceEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) const
QString PerforceEditor::findDiffFile(const QString &f) const
{
QString errorMessage;
const QString diffIndicator = QLatin1String("==== ");
const QString diffEndIndicator = QLatin1String(" ====");
// Go back chunks. Note that for 'describe', an extra, empty line
// occurs.
for (QTextBlock block = inBlock; block.isValid(); block = block.previous()) {
QString diffFileName = block.text();
if (diffFileName.startsWith(diffIndicator) && diffFileName.endsWith(diffEndIndicator)) {
// Split:
// 1) "==== //depot/.../mainwindow.cpp#2 - /depot/.../mainwindow.cpp ===="
// (as created by p4 diff) or
// 2) "==== //depot/.../mainwindow.cpp#15 (text) ===="
// (as created by p4 describe).
diffFileName.remove(0, diffIndicator.size());
diffFileName.truncate(diffFileName.size() - diffEndIndicator.size());
const int separatorPos = diffFileName.indexOf(QLatin1String(" - "));
if (separatorPos == -1) {
// ==== depot path (text) ==== (p4 describe)
const int blankPos = diffFileName.indexOf(QLatin1Char(' '));
if (blankPos == -1)
return QString();
diffFileName.truncate(blankPos);
} else {
// ==== depot path - local path ==== (p4 diff)
diffFileName.truncate(separatorPos);
}
// Split off revision "#4"
const int revisionPos = diffFileName.lastIndexOf(QLatin1Char('#'));
if (revisionPos != -1 && revisionPos < diffFileName.length() - 1)
diffFileName.truncate(revisionPos);
// Ask plugin to map back
const QString fileName = m_plugin->fileNameFromPerforceName(diffFileName.trimmed(), false, &errorMessage);
if (fileName.isEmpty())
qWarning("%s", qPrintable(errorMessage));
return fileName;
}
}
return QString();
const QString fileName = m_plugin->fileNameFromPerforceName(f.trimmed(), false, &errorMessage);
if (fileName.isEmpty())
qWarning("%s", qPrintable(errorMessage));
return fileName;
}
QStringList PerforceEditor::annotationPreviousVersions(const QString &v) const
......
......@@ -50,9 +50,8 @@ public:
private:
QSet<QString> annotationChanges() const;
QString changeUnderCursor(const QTextCursor &) const;
QRegExp diffFilePattern() const;