Replace old svn diff editor with the new one

Change-Id: I4137b709be718603cdc221ac938e139326c88835
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
jkobus
2014-11-06 13:23:40 +01:00
committed by Jarek Kobus
parent 07e3a032ff
commit 8d1940a796
12 changed files with 347 additions and 185 deletions

View File

@@ -349,7 +349,7 @@ QWidget *DiffEditor::toolBar()
reloadButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_RELOAD_GRAY)));
reloadButton->setToolTip(tr("Reload Editor"));
m_reloadAction = m_toolBar->addWidget(reloadButton);
slotReloaderChanged(m_controller->reloader());
slotReloaderChanged();
QToolButton *toggleSync = new QToolButton(m_toolBar);
toggleSync->setIcon(QIcon(QLatin1String(Core::Constants::ICON_LINK)));
@@ -378,8 +378,10 @@ QWidget *DiffEditor::toolBar()
this, SLOT(slotDiffEditorSwitched()));
connect(reloadButton, SIGNAL(clicked()),
m_controller, SLOT(requestReload()));
connect(m_controller, SIGNAL(reloaderChanged(DiffEditorReloader*)),
this, SLOT(slotReloaderChanged(DiffEditorReloader*)));
connect(m_controller, SIGNAL(reloaderChanged()),
this, SLOT(slotReloaderChanged()));
connect(m_controller, SIGNAL(contextLinesNumberEnablementChanged(bool)),
this, SLOT(slotReloaderChanged()));
return m_toolBar;
}
@@ -495,11 +497,14 @@ void DiffEditor::slotDescriptionVisibilityChanged()
m_toggleDescriptionAction->setVisible(enabled);
}
void DiffEditor::slotReloaderChanged(DiffEditorReloader *reloader)
void DiffEditor::slotReloaderChanged()
{
const DiffEditorReloader *reloader = m_controller->reloader();
const bool contextVisible = m_controller->isContextLinesNumberEnabled();
m_whitespaceButtonAction->setVisible(reloader);
m_contextLabelAction->setVisible(reloader);
m_contextSpinBoxAction->setVisible(reloader);
m_contextLabelAction->setVisible(reloader && contextVisible);
m_contextSpinBoxAction->setVisible(reloader && contextVisible);
m_reloadAction->setVisible(reloader);
}

View File

@@ -83,7 +83,7 @@ private slots:
void entryActivated(int index);
void slotDescriptionChanged(const QString &description);
void slotDescriptionVisibilityChanged();
void slotReloaderChanged(DiffEditorReloader *reloader);
void slotReloaderChanged();
void slotDiffEditorSwitched();
private:

View File

@@ -48,6 +48,7 @@ DiffEditorController::DiffEditorController(QObject *parent)
m_chunkIndex(-1),
m_descriptionEnabled(false),
m_contextLinesNumber(3),
m_contextLinesNumberEnabled(true),
m_ignoreWhitespace(true),
m_reloader(0)
{
@@ -97,6 +98,11 @@ int DiffEditorController::contextLinesNumber() const
return m_contextLinesNumber;
}
bool DiffEditorController::isContextLinesNumberEnabled() const
{
return m_contextLinesNumberEnabled;
}
bool DiffEditorController::isIgnoreWhitespace() const
{
return m_ignoreWhitespace;
@@ -150,7 +156,7 @@ void DiffEditorController::setReloader(DiffEditorReloader *reloader)
if (m_reloader)
m_reloader->setController(this);
emit reloaderChanged(m_reloader);
emit reloaderChanged();
}
void DiffEditorController::clear()
@@ -180,10 +186,6 @@ void DiffEditorController::setDescription(const QString &description)
return;
m_description = description;
// Empty line before headers and commit message
const int emptyLine = m_description.indexOf(QLatin1String("\n\n"));
if (emptyLine != -1)
m_description.insert(emptyLine, QLatin1Char('\n') + QLatin1String(Constants::EXPAND_BRANCHES));
emit descriptionChanged(m_description);
}
@@ -250,6 +252,15 @@ void DiffEditorController::setContextLinesNumber(int lines)
emit contextLinesNumberChanged(l);
}
void DiffEditorController::setContextLinesNumberEnabled(bool on)
{
if (m_contextLinesNumberEnabled == on)
return;
m_contextLinesNumberEnabled = on;
emit contextLinesNumberEnablementChanged(on);
}
void DiffEditorController::setIgnoreWhitespace(bool ignore)
{
if (m_ignoreWhitespace == ignore)

View File

@@ -54,6 +54,7 @@ public:
QString description() const;
bool isDescriptionEnabled() const;
int contextLinesNumber() const;
bool isContextLinesNumberEnabled() const;
bool isIgnoreWhitespace() const;
QString makePatch(bool revert, bool addPrefix = false) const;
@@ -69,6 +70,7 @@ public slots:
void setDescription(const QString &description);
void setDescriptionEnabled(bool on);
void setContextLinesNumber(int lines);
void setContextLinesNumberEnabled(bool on);
void setIgnoreWhitespace(bool ignore);
void requestReload();
void requestChunkActions(QMenu *menu,
@@ -86,12 +88,13 @@ signals:
void descriptionChanged(const QString &description);
void descriptionEnablementChanged(bool on);
void contextLinesNumberChanged(int lines);
void contextLinesNumberEnablementChanged(bool on);
void ignoreWhitespaceChanged(bool ignore);
void chunkActionsRequested(QMenu *menu, bool isValid);
void saveStateRequested();
void restoreStateRequested();
void expandBranchesRequested(const QString &revision);
void reloaderChanged(DiffEditorReloader *reloader);
void reloaderChanged();
private:
QString prepareBranchesForCommit(const QString &output);
@@ -104,6 +107,7 @@ private:
QString m_description;
bool m_descriptionEnabled;
int m_contextLinesNumber;
bool m_contextLinesNumberEnabled;
bool m_ignoreWhitespace;
DiffEditorReloader *m_reloader;
};

View File

@@ -894,6 +894,66 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
fileDataList7 << fileData1;
QTest::newRow("Dirty submodule") << patch
<< fileDataList7;
//////////////
// Subversion New
patch = _("Index: src/plugins/subversion/subversioneditor.cpp\n"
"===================================================================\n"
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
"+++ src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
"@@ -0,0 +125 @@\n\n");
fileData1 = FileData();
fileData1.leftFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
fileData1.rightFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
chunkData1 = ChunkData();
chunkData1.leftStartingLineNumber = -1;
chunkData1.rightStartingLineNumber = 124;
fileData1.chunks << chunkData1;
QList<FileData> fileDataList8;
fileDataList8 << fileData1;
QTest::newRow("Subversion New") << patch
<< fileDataList8;
//////////////
// Subversion Deleted
patch = _("Index: src/plugins/subversion/subversioneditor.cpp\n"
"===================================================================\n"
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
"@@ -1,125 +0,0 @@\n\n");
fileData1 = FileData();
fileData1.leftFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
fileData1.rightFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
chunkData1 = ChunkData();
chunkData1.leftStartingLineNumber = 0;
chunkData1.rightStartingLineNumber = -1;
fileData1.chunks << chunkData1;
QList<FileData> fileDataList9;
fileDataList9 << fileData1;
QTest::newRow("Subversion Deleted") << patch
<< fileDataList9;
//////////////
// Subversion Normal
patch = _("Index: src/plugins/subversion/subversioneditor.cpp\n"
"===================================================================\n"
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
"@@ -120,7 +120,7 @@\n\n");
fileData1 = FileData();
fileData1.leftFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
fileData1.rightFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
chunkData1 = ChunkData();
chunkData1.leftStartingLineNumber = 119;
chunkData1.rightStartingLineNumber = 119;
fileData1.chunks << chunkData1;
QList<FileData> fileDataList10;
fileDataList10 << fileData1;
QTest::newRow("Subversion Normal") << patch
<< fileDataList10;
}
void DiffEditor::Internal::DiffEditorPlugin::testReadPatch()

View File

@@ -540,8 +540,11 @@ static QList<RowData> readLines(const QString &patch,
int i;
for (i = 0; i < lines.count(); i++) {
const QString line = lines.at(i);
if (line.isEmpty())
break; // need to have at least one character (1 column)
if (line.isEmpty()) { // need to have at least one character (1 column)
if (lastChunk)
i = lines.count(); // pretend as we've read all the lines (we just ignore the rest)
break;
}
QChar firstCharacter = line.at(0);
if (firstCharacter == QLatin1Char('\\')) { // no new line marker
if (!lastChunk) // can only appear in last chunk of the file
@@ -567,14 +570,17 @@ static QList<RowData> readLines(const QString &patch,
}
} else {
Diff::Command command = Diff::Equal;
if (firstCharacter == QLatin1Char(' ')) // common line
if (firstCharacter == QLatin1Char(' ')) { // common line
command = Diff::Equal;
else if (firstCharacter == QLatin1Char('-')) // deleted line
} else if (firstCharacter == QLatin1Char('-')) { // deleted line
command = Diff::Delete;
else if (firstCharacter == QLatin1Char('+')) // inserted line
} else if (firstCharacter == QLatin1Char('+')) { // inserted line
command = Diff::Insert;
else
break; // no other character may exist as the first character
} else { // no other character may exist as the first character
if (lastChunk)
i = lines.count(); // pretend as we've read all the lines (we just ignore the rest)
break;
}
Diff diffToBeAdded(command, line.mid(1) + newLine);

View File

@@ -828,6 +828,7 @@ GitDiffEditorReloader *GitClient::findOrCreateDiffEditor(const QString &document
reloader->setWorkingDirectory(workingDirectory);
}
QTC_ASSERT(reloader, return 0);
VcsBasePlugin::setSource(diffEditorDocument, source);
EditorManager::activateEditorForDocument(diffEditorDocument);
@@ -2464,6 +2465,12 @@ QString GitClient::extendedShowDescription(const QString &workingDirectory, cons
modText.insert(lastHeaderLine, QLatin1String("Precedes: ") + precedes + QLatin1Char('\n'));
if (!follows.isEmpty())
modText.insert(lastHeaderLine, QLatin1String("Follows: ") + follows + QLatin1Char('\n'));
// Empty line before headers and commit message
const int emptyLine = modText.indexOf(QLatin1String("\n\n"));
if (emptyLine != -1)
modText.insert(emptyLine, QLatin1Char('\n') + QLatin1String(DiffEditor::Constants::EXPAND_BRANCHES));
return modText;
}

View File

@@ -4,4 +4,5 @@ QTC_LIB_DEPENDS += \
QTC_PLUGIN_DEPENDS += \
texteditor \
coreplugin \
vcsbase
vcsbase \
diffeditor

View File

@@ -29,14 +29,23 @@
****************************************************************************/
#include "subversionclient.h"
#include "subversionsettings.h"
#include "subversionconstants.h"
#include "subversionplugin.h"
#include "subversionsettings.h"
#include <vcsbase/vcscommand.h>
#include <vcsbase/vcsbaseplugin.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseeditorparameterwidget.h>
#include <vcsbase/vcsbaseplugin.h>
#include <utils/qtcassert.h>
#include <utils/synchronousprocess.h>
#include <diffeditor/diffeditorcontroller.h>
#include <diffeditor/diffeditordocument.h>
#include <diffeditor/diffeditormanager.h>
#include <diffeditor/diffeditorreloader.h>
#include <diffeditor/diffutils.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QDir>
#include <QFileInfo>
@@ -45,61 +54,11 @@
using namespace Utils;
using namespace VcsBase;
using namespace Core;
namespace Subversion {
namespace Internal {
// Collect all parameters required for a diff to be able to associate them
// with a diff editor and re-run the diff with parameters.
struct SubversionDiffParameters
{
QString workingDir;
QStringList extraOptions;
QStringList files;
};
// Parameter widget controlling whitespace diff mode, associated with a parameter
class SubversionDiffParameterWidget : public VcsBaseEditorParameterWidget
{
Q_OBJECT
public:
explicit SubversionDiffParameterWidget(SubversionClient *client,
const SubversionDiffParameters &p,
QWidget *parent = 0);
QStringList arguments() const;
void executeCommand();
private:
SubversionClient *m_client;
const SubversionDiffParameters m_params;
};
SubversionDiffParameterWidget::SubversionDiffParameterWidget(SubversionClient *client,
const SubversionDiffParameters &p,
QWidget *parent)
: VcsBaseEditorParameterWidget(parent), m_client(client), m_params(p)
{
mapSetting(addToggleButton(QLatin1String("w"), tr("Ignore Whitespace")),
client->settings()->boolPointer(SubversionSettings::diffIgnoreWhiteSpaceKey));
}
QStringList SubversionDiffParameterWidget::arguments() const
{
QStringList args;
// Subversion wants" -x -<ext-args>", default being -u
const QStringList formatArguments = VcsBaseEditorParameterWidget::arguments();
if (!formatArguments.isEmpty()) {
args << QLatin1String("-x")
<< (QLatin1String("-u") + formatArguments.join(QString()));
}
return args;
}
void SubversionDiffParameterWidget::executeCommand()
{
m_client->diff(m_params.workingDir, m_params.files, m_params.extraOptions);
}
SubversionClient::SubversionClient(SubversionSettings *settings) :
VcsBaseClient(settings)
{
@@ -143,13 +102,10 @@ void SubversionClient::commit(const QString &repositoryRoot,
Core::Id SubversionClient::vcsEditorKind(VcsCommandTag cmd) const
{
switch (cmd) {
case DiffCommand:
return "Subversion Diff Editor"; // TODO: create subversionconstants.h
default:
// TODO: add some code here
Q_UNUSED(cmd)
return Core::Id();
}
}
// Add authorization options to the command line arguments.
QStringList SubversionClient::addAuthenticationOptions(const SubversionSettings &settings)
@@ -192,14 +148,207 @@ QString SubversionClient::synchronousTopic(const QString &repository)
return QString();
}
void SubversionClient::diff(const QString &workingDir, const QStringList &files,
const QStringList &extraOptions)
class SubversionDiffEditorReloader : public DiffEditor::DiffEditorReloader
{
Q_OBJECT
public:
SubversionDiffEditorReloader(const SubversionClient *client);
void setWorkingDirectory(const QString &workingDirectory);
void setFilesList(const QStringList &filesList);
void setChangeNumber(int changeNumber);
protected:
void reload();
private slots:
void slotTextualDiffOutputReceived(const QString &contents);
private:
QString getDescription() const;
void postCollectTextualDiffOutput();
int timeout() const;
FileName subversionPath() const;
QProcessEnvironment processEnvironment() const;
const SubversionClient *m_client;
QString m_workingDirectory;
QStringList m_filesList;
int m_changeNumber;
const QString m_waitMessage;
};
SubversionDiffEditorReloader::SubversionDiffEditorReloader(const SubversionClient *client)
: DiffEditor::DiffEditorReloader(),
m_client(client),
m_changeNumber(0),
m_waitMessage(tr("Waiting for data..."))
{
}
int SubversionDiffEditorReloader::timeout() const
{
return m_client->settings()->intValue(VcsBaseClientSettings::timeoutKey);
}
FileName SubversionDiffEditorReloader::subversionPath() const
{
return m_client->settings()->binaryPath();
}
QProcessEnvironment SubversionDiffEditorReloader::processEnvironment() const
{
return m_client->processEnvironment();
}
void SubversionDiffEditorReloader::setWorkingDirectory(const QString &workingDirectory)
{
if (isReloading())
return;
m_workingDirectory = workingDirectory;
}
void SubversionDiffEditorReloader::setFilesList(const QStringList &filesList)
{
if (isReloading())
return;
m_filesList = filesList;
}
void SubversionDiffEditorReloader::setChangeNumber(int changeNumber)
{
if (isReloading())
return;
m_changeNumber = qMax(changeNumber, 0);
}
QString SubversionDiffEditorReloader::getDescription() const
{
QStringList args(QLatin1String("log"));
args << SubversionClient::addAuthenticationOptions(*m_client->settings());
args << QLatin1String("-r");
args << QString::number(m_changeNumber);
const SubversionResponse logResponse =
SubversionPlugin::instance()->runSvn(m_workingDirectory, args,
m_client->settings()->timeOutMs(),
VcsBasePlugin::SshPasswordPrompt);
if (logResponse.error)
return QString();
return logResponse.stdOut;
}
void SubversionDiffEditorReloader::postCollectTextualDiffOutput()
{
if (!controller())
return;
controller()->requestSaveState();
controller()->clear(m_waitMessage);
VcsCommand *command = new VcsCommand(subversionPath(), m_workingDirectory, processEnvironment());
command->setCodec(EditorManager::defaultTextCodec());
connect(command, SIGNAL(output(QString)),
this, SLOT(slotTextualDiffOutputReceived(QString)));
// command->addFlags(diffExecutionFlags());
QStringList args;
args << addAuthenticationOptions(*settings());
args.append(QLatin1String("--internal-diff"));
args << extraOptions;
VcsBaseClient::diff(workingDir, files, args);
args << QLatin1String("diff");
args << m_client->addAuthenticationOptions(*m_client->settings());
args << QLatin1String("--internal-diff");
if (controller()->isIgnoreWhitespace())
args << QLatin1String("-x") << QLatin1String("-uw");
if (m_changeNumber) {
args << QLatin1String("-r") << QString::number(m_changeNumber - 1)
+ QLatin1String(":") + QString::number(m_changeNumber);
} else {
args << m_filesList;
}
command->addJob(args, timeout());
command->execute();
}
void SubversionDiffEditorReloader::slotTextualDiffOutputReceived(const QString &contents)
{
if (!controller())
return;
bool ok;
QList<DiffEditor::FileData> fileDataList
= DiffEditor::DiffUtils::readPatch(contents, &ok);
controller()->setDiffFiles(fileDataList, m_workingDirectory);
controller()->requestRestoreState();
reloadFinished();
}
void SubversionDiffEditorReloader::reload()
{
if (!controller())
return;
const QString description = m_changeNumber
? getDescription() : QString();
postCollectTextualDiffOutput();
controller()->setDescription(description);
}
SubversionDiffEditorReloader *SubversionClient::findOrCreateDiffEditor(const QString &documentId,
const QString &source,
const QString &title,
const QString &workingDirectory) const
{
DiffEditor::DiffEditorController *controller = 0;
SubversionDiffEditorReloader *reloader = 0;
DiffEditor::DiffEditorDocument *diffEditorDocument = DiffEditor::DiffEditorManager::find(documentId);
if (diffEditorDocument) {
controller = diffEditorDocument->controller();
reloader = static_cast<SubversionDiffEditorReloader *>(controller->reloader());
} else {
diffEditorDocument = DiffEditor::DiffEditorManager::findOrCreate(documentId, title);
QTC_ASSERT(diffEditorDocument, return 0);
controller = diffEditorDocument->controller();
reloader = new SubversionDiffEditorReloader(this);
controller->setReloader(reloader);
controller->setContextLinesNumberEnabled(false);
}
QTC_ASSERT(reloader, return 0);
reloader->setWorkingDirectory(workingDirectory);
VcsBasePlugin::setSource(diffEditorDocument, source);
return reloader;
}
void SubversionClient::diff(const QString &workingDirectory, const QStringList &files)
{
const QString vcsCmdString = vcsCommandString(DiffCommand);
const QString documentId = VcsBaseEditor::getTitleId(workingDirectory, files);
const QString title = vcsEditorTitle(vcsCmdString, documentId);
SubversionDiffEditorReloader *reloader = findOrCreateDiffEditor(documentId, workingDirectory, title, workingDirectory);
QTC_ASSERT(reloader, return);
reloader->setFilesList(files);
reloader->requestReload();
}
void SubversionClient::describe(const QString &workingDirectory, int changeNumber, const QString &title)
{
const QString documentId = VcsBaseEditor::editorTag(DiffOutput,
workingDirectory,
QStringList(),
QString::number(changeNumber));
SubversionDiffEditorReloader *reloader = findOrCreateDiffEditor(documentId, workingDirectory, title, workingDirectory);
QTC_ASSERT(reloader, return);
reloader->setChangeNumber(changeNumber);
reloader->controller()->setDescriptionEnabled(true);
reloader->requestReload();
}
QString SubversionClient::findTopLevelForFile(const QFileInfo &file) const
@@ -220,17 +369,6 @@ VcsBaseClient::StatusItem SubversionClient::parseStatusLine(const QString &line)
return VcsBaseClient::StatusItem();
}
VcsBaseEditorParameterWidget *SubversionClient::createDiffEditor(
const QString &workingDir, const QStringList &files, const QStringList &extraOptions)
{
Q_UNUSED(extraOptions)
SubversionDiffParameters p;
p.workingDir = workingDir;
p.files = files;
p.extraOptions = extraOptions;
return new SubversionDiffParameterWidget(this, p);
}
} // namespace Internal
} // namespace Subversion

View File

@@ -41,6 +41,7 @@ namespace Subversion {
namespace Internal {
class SubversionSettings;
class SubversionDiffEditorReloader;
class SubversionClient : public VcsBase::VcsBaseClient
{
@@ -60,8 +61,8 @@ public:
const QString &commitMessageFile,
const QStringList &extraOptions = QStringList());
void diff(const QString &workingDir, const QStringList &files,
const QStringList &extraOptions = QStringList());
void diff(const QString &workingDirectory, const QStringList &files);
void describe(const QString &workingDirectory, int changeNumber, const QString &title);
QString findTopLevelForFile(const QFileInfo &file) const;
QStringList revisionSpec(const QString &revision) const;
StatusItem parseStatusLine(const QString &line) const;
@@ -73,12 +74,15 @@ public:
protected:
Core::Id vcsEditorKind(VcsCommandTag cmd) const;
VcsBase::VcsBaseEditorParameterWidget *createDiffEditor(const QString &workingDir,
const QStringList &files,
const QStringList &extraOptions);
private:
Utils::FileName m_svnVersionBinary;
QString m_svnVersion;
SubversionDiffEditorReloader *findOrCreateDiffEditor(const QString &documentId,
const QString &source,
const QString &title,
const QString &workingDirectory) const;
mutable Utils::FileName m_svnVersionBinary;
mutable QString m_svnVersion;
};
} // namespace Internal

View File

@@ -128,11 +128,7 @@ const VcsBaseEditorParameters editorParameters[] = {
{ AnnotateOutput,
"Subversion Annotation Editor", // id
QT_TRANSLATE_NOOP("VCS", "Subversion Annotation Editor"), // display_name
"text/vnd.qtcreator.svn.annotation"},
{ DiffOutput,
"Subversion Diff Editor", // id
QT_TRANSLATE_NOOP("VCS", "Subversion Diff Editor"), // display_name
"text/x-patch"}
"text/vnd.qtcreator.svn.annotation"}
};
// Utility to find a parameter set by type
@@ -912,49 +908,14 @@ void SubversionPlugin::describe(const QString &source, const QString &changeNr)
qDebug() << Q_FUNC_INFO << source << topLevel << changeNr;
// Number must be >= 1
bool ok;
const int number = changeNr.toInt(&ok);
if (!ok || number < 1)
return;
// Run log to obtain message (local utf8)
QString description;
QStringList args(QLatin1String("log"));
args << SubversionClient::addAuthenticationOptions(settings());
args.push_back(QLatin1String("-r"));
args.push_back(changeNr);
const SubversionResponse logResponse =
runSvn(topLevel, args, m_settings.timeOutMs(), SshPasswordPrompt);
if (logResponse.error)
return;
description = logResponse.stdOut;
// Run diff (encoding via source codec)
args.clear();
args.push_back(QLatin1String("diff"));
args << SubversionClient::addAuthenticationOptions(settings());
args.push_back(QLatin1String("-r"));
QString diffArg;
QTextStream(&diffArg) << (number - 1) << ':' << number;
args.push_back(diffArg);
QTextCodec *codec = VcsBaseEditor::getCodec(source);
const SubversionResponse response =
runSvn(topLevel, args, m_settings.timeOutMs(),
SshPasswordPrompt, codec);
if (response.error)
return;
description += response.stdOut;
// Re-use an existing view if possible to support
// the common usage pattern of continuously changing and diffing a file
const QString tag = VcsBaseEditor::editorTag(DiffOutput, source, QStringList(), changeNr);
if (IEditor *editor = VcsBaseEditor::locateEditorByTag(tag)) {
editor->document()->setContents(description.toUtf8());
EditorManager::activateEditor(editor);
} else {
const QString title = QString::fromLatin1("svn describe %1#%2").arg(fi.fileName(), changeNr);
IEditor *newEditor = showOutputInEditor(title, description, DiffOutput, source, codec);
VcsBaseEditor::tagEditor(newEditor, tag);
}
m_client->describe(topLevel, number, title);
}
void SubversionPlugin::slotDescribe()
@@ -1233,39 +1194,6 @@ SubversionControl *SubversionPlugin::subVersionControl() const
}
#ifdef WITH_TESTS
void SubversionPlugin::testDiffFileResolving_data()
{
QTest::addColumn<QByteArray>("header");
QTest::addColumn<QByteArray>("fileName");
QTest::newRow("New") << QByteArray(
"Index: src/plugins/subversion/subversioneditor.cpp\n"
"===================================================================\n"
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
"+++ src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
"@@ -0,0 +125 @@\n\n")
<< QByteArray("src/plugins/subversion/subversioneditor.cpp");
QTest::newRow("Deleted") << QByteArray(
"Index: src/plugins/subversion/subversioneditor.cpp\n"
"===================================================================\n"
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
"@@ -1,125 +0,0 @@\n\n")
<< QByteArray("src/plugins/subversion/subversioneditor.cpp");
QTest::newRow("Normal") << QByteArray(
"Index: src/plugins/subversion/subversioneditor.cpp\n"
"===================================================================\n"
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
"@@ -120,7 +120,7 @@\n\n")
<< QByteArray("src/plugins/subversion/subversioneditor.cpp");
}
void SubversionPlugin::testDiffFileResolving()
{
VcsBaseEditorWidget::testDiffFileResolving(editorParameters[2].id);
}
void SubversionPlugin::testLogResolving()
{
QByteArray data(

View File

@@ -93,6 +93,9 @@ public:
QString monitorFile(const QString &repository) const;
QString synchronousTopic(const QString &repository) const;
SubversionResponse runSvn(const QString &workingDir,
const QStringList &arguments, int timeOut,
unsigned flags, QTextCodec *outputCodec = 0) const;
public slots:
void vcsAnnotate(const QString &workingDir, const QString &file,
@@ -123,8 +126,6 @@ private slots:
void statusRepository();
void updateRepository();
#ifdef WITH_TESTS
void testDiffFileResolving_data();
void testDiffFileResolving();
void testLogResolving();
#endif
@@ -137,9 +138,6 @@ private:
Core::IEditor * showOutputInEditor(const QString& title, const QString &output,
int editorType, const QString &source,
QTextCodec *codec);
SubversionResponse runSvn(const QString &workingDir,
const QStringList &arguments, int timeOut,
unsigned flags, QTextCodec *outputCodec = 0) const;
void filelog(const QString &workingDir,
const QString &file = QString(),