From ebf78d6ac26467560e66beeb106d0650aafd60f3 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 22 Jul 2009 07:07:43 +0000 Subject: - Documentation updates. - Allow the revision plugin to emit a signal which indicates a changed revision state. - Update the revision state if the state of file items has been changed. - Check also the content of a file if the size of a local and revisioned file is equal. svn path=/trunk/KDE/kdebase/apps/; revision=1000831 --- src/revisioncontrolplugin.cpp | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'src/revisioncontrolplugin.cpp') diff --git a/src/revisioncontrolplugin.cpp b/src/revisioncontrolplugin.cpp index 5e6783335..d5f2e4e5d 100644 --- a/src/revisioncontrolplugin.cpp +++ b/src/revisioncontrolplugin.cpp @@ -32,6 +32,8 @@ RevisionControlPlugin::~RevisionControlPlugin() { } +#include "revisioncontrolplugin.moc" + // ---------------------------------------------------------------------------- SubversionPlugin::SubversionPlugin() : @@ -94,18 +96,47 @@ RevisionControlPlugin::RevisionState SubversionPlugin::revisionState(const KFile const QDateTime versionedTimeStamp = info.timeStamp; if (localTimeStamp > versionedTimeStamp) { - if (info.size != item.size()) { + if ((info.size != item.size()) || !equalRevisionContent(item.name())) { return RevisionControlPlugin::EditingRevision; } - // TODO: a comparison of the content is required } else if (localTimeStamp < versionedTimeStamp) { - if (info.size != item.size()) { + if ((info.size != item.size()) || !equalRevisionContent(item.name())) { return RevisionControlPlugin::UpdateRequiredRevision; } - // TODO: a comparison of the content is required } return RevisionControlPlugin::LatestRevision; } return RevisionControlPlugin::LocalRevision; } + +QList SubversionPlugin::contextMenuActions(const KFileItemList& items) const +{ + Q_UNUSED(items); + // TODO... + return QList(); +} + +bool SubversionPlugin::equalRevisionContent(const QString& name) const +{ + QFile localFile(m_directory + '/' + name); + if (!localFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + return false; + } + + QFile revisionedFile(m_directory + "/.svn/text-base/" + name + ".svn-base"); + if (!revisionedFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + return false; + } + + QTextStream localText(&localFile); + QTextStream revisionedText(&revisionedFile); + while (!localText.atEnd() && !revisionedText.atEnd()) { + if (localText.readLine() != revisionedText.readLine()) { + return false; + } + } + + return localText.atEnd() && revisionedText.atEnd(); +} + -- cgit v1.3