forked from qt-creator/qt-creator
DiffEditor: Fix detection of subsequent renames
Change-Id: Ie47c5a7ca91752b0da40b46f780ee5e0b3b6ce29 Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
c3c19aaab6
commit
0b1b080cb3
@@ -820,6 +820,56 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
|
||||
QTest::newRow("Blank line followed by No newline") << patch
|
||||
<< fileDataList5;
|
||||
|
||||
//////////////
|
||||
|
||||
// Based on 953cdb97
|
||||
patch = _("diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/textdocument.h\n"
|
||||
"similarity index 100%\n"
|
||||
"rename from src/plugins/texteditor/basetextdocument.h\n"
|
||||
"rename to src/plugins/texteditor/textdocument.h\n"
|
||||
"diff --git a/src/plugins/texteditor/basetextdocumentlayout.cpp b/src/plugins/texteditor/textdocumentlayout.cpp\n"
|
||||
"similarity index 79%\n"
|
||||
"rename from src/plugins/texteditor/basetextdocumentlayout.cpp\n"
|
||||
"rename to src/plugins/texteditor/textdocumentlayout.cpp\n"
|
||||
"index 0121933..01cc3a0 100644\n"
|
||||
"--- a/src/plugins/texteditor/basetextdocumentlayout.cpp\n"
|
||||
"+++ b/src/plugins/texteditor/textdocumentlayout.cpp\n"
|
||||
"@@ -2,5 +2,5 @@ void func()\n"
|
||||
" A\n"
|
||||
" B\n"
|
||||
"-C\n"
|
||||
"+Z\n"
|
||||
" D\n"
|
||||
" \n"
|
||||
);
|
||||
|
||||
fileData1 = FileData();
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("src/plugins/texteditor/basetextdocument.h"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("src/plugins/texteditor/textdocument.h"));
|
||||
fileData1.fileOperation = FileData::RenameFile;
|
||||
fileData2 = FileData();
|
||||
fileData2.leftFileInfo = DiffFileInfo(_("src/plugins/texteditor/basetextdocumentlayout.cpp"), _("0121933"));
|
||||
fileData2.rightFileInfo = DiffFileInfo(_("src/plugins/texteditor/textdocumentlayout.cpp"), _("01cc3a0"));
|
||||
fileData2.fileOperation = FileData::RenameFile;
|
||||
chunkData2.leftStartingLineNumber = 1;
|
||||
chunkData2.rightStartingLineNumber = 1;
|
||||
rows2.clear();
|
||||
rows2 << RowData(_("A"));
|
||||
rows2 << RowData(_("B"));
|
||||
rows2 << RowData(_("C"), _("Z"));
|
||||
rows2 << RowData(_("D"));
|
||||
rows2 << RowData(_(""));
|
||||
chunkData2.rows = rows2;
|
||||
fileData2.chunks.clear();
|
||||
fileData2.chunks << chunkData2;
|
||||
|
||||
QList<FileData> fileDataList6;
|
||||
fileDataList6 << fileData1 << fileData2;
|
||||
|
||||
QTest::newRow("Multiple renames") << patch
|
||||
<< fileDataList6;
|
||||
|
||||
}
|
||||
|
||||
void DiffEditor::Internal::DiffEditorPlugin::testReadPatch()
|
||||
|
||||
@@ -741,7 +741,7 @@ static QList<ChunkData> readChunks(const QString &patch,
|
||||
chunkData.rightStartingLineNumber = rightStartingPos - 1;
|
||||
chunkData.contextInfo = contextInfo;
|
||||
chunkDataList.append(chunkData);
|
||||
} while ((pos = chunkRegExp.indexIn(patch, pos)) != -1);
|
||||
} while ((pos = chunkRegExp.indexIn(patch, pos, QRegExp::CaretAtOffset)) != -1);
|
||||
|
||||
if (endOfLastChunk > 0) {
|
||||
const QString lines = patch.mid(endOfLastChunk);
|
||||
@@ -1037,8 +1037,8 @@ static QList<FileData> readGitPatch(const QString &patch, bool ignoreWhitespace,
|
||||
|
||||
QList<FileData> fileDataList;
|
||||
|
||||
const int simpleGitPos = simpleGitRegExp.indexIn(patch, 0);
|
||||
const int similarityPos = similarityRegExp.indexIn(patch, 0);
|
||||
int simpleGitPos = simpleGitRegExp.indexIn(patch);
|
||||
int similarityPos = similarityRegExp.indexIn(patch);
|
||||
|
||||
bool simpleGitMatched = false;
|
||||
int pos = -1;
|
||||
@@ -1104,8 +1104,8 @@ static QList<FileData> readGitPatch(const QString &patch, bool ignoreWhitespace,
|
||||
break; // either copy or rename, otherwise broken
|
||||
}
|
||||
|
||||
const int simpleGitPos = simpleGitRegExp.indexIn(patch, pos);
|
||||
const int similarityPos = similarityRegExp.indexIn(patch, pos);
|
||||
simpleGitPos = simpleGitRegExp.indexIn(patch, pos, QRegExp::CaretAtOffset);
|
||||
similarityPos = similarityRegExp.indexIn(patch, pos, QRegExp::CaretAtOffset);
|
||||
|
||||
simpleGitMatched = false;
|
||||
pos = -1;
|
||||
|
||||
Reference in New Issue
Block a user