From ba00acbd6583d33f358a01d42965ea7e0ed9ec54 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Sat, 6 Nov 2010 11:54:08 +0000 Subject: [PATCH] check for user cancel or errors on vcs revert before reload of buffer in LFUN_VC_REVERT git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36160 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXVC.cpp | 5 ++--- src/LyXVC.h | 2 +- src/VCBackend.cpp | 25 +++++++++++++++---------- src/VCBackend.h | 8 ++++---- src/frontends/qt4/GuiView.cpp | 7 ++++--- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index 65e83a33f6..ba7b020255 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -208,7 +208,7 @@ string LyXVC::lockingToggle() } -void LyXVC::revert() +bool LyXVC::revert() { LYXERR(Debug::LYXVC, "LyXVC: revert"); @@ -221,8 +221,7 @@ void LyXVC::revert() ret = Alert::prompt(_("Revert to stored version of document?"), text, 0, 1, _("&Revert"), _("&Cancel")); - if (ret == 0) - vcs->revert(); + return ret == 0 && vcs->revert(); } diff --git a/src/LyXVC.h b/src/LyXVC.h index f0302eee66..a75dc97453 100644 --- a/src/LyXVC.h +++ b/src/LyXVC.h @@ -98,7 +98,7 @@ public: bool lockingToggleEnabled() const; /// Revert to last version - void revert(); + bool revert(); /// Undo last check-in. void undoLast(); diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index 9f065eb221..723cbde5fa 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -267,13 +267,15 @@ bool RCS::lockingToggleEnabled() } -void RCS::revert() +bool RCS::revert() { - doVCCommand("co -f -u" + version_ + " " + if (doVCCommand("co -f -u" + version_ + " " + quoteName(onlyFileName(owner_->absFileName())), - FileName(owner_->filePath())); + FileName(owner_->filePath()))) + return false; // We ignore changes and just reload! owner_->markClean(); + return true; } @@ -831,7 +833,7 @@ bool CVS::isRevertWithConfirmation() } -void CVS::revert() +bool CVS::revert() { // Reverts to the version in CVS repository and // gets the updated version from the repository. @@ -839,7 +841,7 @@ void CVS::revert() switch (status) { case UpToDate: if (vcstatus != NOLOCKING) - unedit(); + return 0 == unedit(); break; case NeedsMerge: case NeedsCheckout: @@ -856,7 +858,7 @@ void CVS::revert() bformat(_("The document %1$s is not in repository.\n" "You have to check in the first revision before you can revert."), file)) ; - break; + return false; } default: { docstring const file = owner_->fileName().displayName(20); @@ -864,9 +866,10 @@ void CVS::revert() bformat(_("Cannot revert document %1$s to repository version.\n" "The status '%2$s' is unexpected."), file, toString(status))); - break; + return false; } } + return true; } @@ -1294,15 +1297,17 @@ bool SVN::lockingToggleEnabled() } -void SVN::revert() +bool SVN::revert() { // Reverts to the version in SVN repository and // gets the updated version from the repository. string const fil = quoteName(onlyFileName(owner_->absFileName())); - doVCCommand("svn revert -q " + fil, - FileName(owner_->filePath())); + if (doVCCommand("svn revert -q " + fil, + FileName(owner_->filePath()))) + return false; owner_->markClean(); + return true; } diff --git a/src/VCBackend.h b/src/VCBackend.h index 54dbc1775d..5832f11d8f 100644 --- a/src/VCBackend.h +++ b/src/VCBackend.h @@ -57,7 +57,7 @@ public: // can be this operation processed in the current RCS? virtual bool lockingToggleEnabled() = 0; /// revert current edits - virtual void revert() = 0; + virtual bool revert() = 0; // should a confirmation before revert requested? virtual bool isRevertWithConfirmation() = 0; /// FIXME @@ -147,7 +147,7 @@ public: virtual bool lockingToggleEnabled(); - virtual void revert(); + virtual bool revert(); virtual bool isRevertWithConfirmation(); @@ -214,7 +214,7 @@ public: virtual bool isRevertWithConfirmation(); - virtual void revert(); + virtual bool revert(); virtual void undoLast(); @@ -340,7 +340,7 @@ public: virtual bool lockingToggleEnabled(); - virtual void revert(); + virtual bool revert(); virtual bool isRevertWithConfirmation(); diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index c571a37380..5b5ccf6e2c 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2701,9 +2701,10 @@ void GuiView::dispatchVC(FuncRequest const & cmd, DispatchResult & dr) case LFUN_VC_REVERT: LASSERT(buffer, return); - buffer->lyxvc().revert(); - reloadBuffer(*buffer); - dr.suppressMessageUpdate(); + if (buffer->lyxvc().revert()) { + reloadBuffer(*buffer); + dr.suppressMessageUpdate(); + } break; case LFUN_VC_UNDO_LAST: