From dd5ccf3d854912704d9abff68bf63acb1c567937 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 2 Aug 2011 09:40:04 +0000 Subject: [PATCH] P4: Allow for reversal of unchanged files Allow for reversal of unchanged files in perforce: Just close them again. Task-number: QTCREATORBUG-3786 Change-Id: I52266b9f7d0bbaf3139cf9fd0ee5e3b47e7a3d58 Reviewed-on: http://codereview.qt.nokia.com/2501 Reviewed-by: Tobias Hunger Reviewed-by: Qt Sanity Bot --- src/plugins/perforce/perforceplugin.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 554a3c5d5aa..a3a68d3a433 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -489,12 +489,15 @@ void PerforcePlugin::revertCurrentFile() if (result.error) return; // "foo.cpp - file(s) not opened on this client." - if (result.stdOut.isEmpty() || result.stdOut.contains(QLatin1String(" - "))) + // also revert when the output is empty: The file is unchanged but open then. + if (result.stdOut.contains(QLatin1String(" - ")) || result.stdErr.contains(QLatin1String(" - "))) return; - const bool doNotRevert = QMessageBox::warning(0, tr("p4 revert"), - tr("The file has been changed. Do you want to revert it?"), - QMessageBox::Yes, QMessageBox::No) == QMessageBox::No; + bool doNotRevert = false; + if (!result.stdOut.isEmpty()) + doNotRevert = (QMessageBox::warning(0, tr("p4 revert"), + tr("The file has been changed. Do you want to revert it?"), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::No); if (doNotRevert) return;