Author: switt
Date: Sat Nov 6 12:54:08 2010
New Revision: 36160
URL: http://www.lyx.org/trac/changeset/36160
Log:
check for user cancel or errors on vcs revert before reload of buffer in
LFUN_VC_REVERT
Modified:
lyx-devel/trunk/src/LyXVC.cpp
lyx-devel/trunk/src/LyXVC.h
lyx-devel/trunk/src/VCBackend.cpp
lyx-devel/trunk/src/VCBackend.h
lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
Modified: lyx-devel/trunk/src/LyXVC.cpp
==============================================================================
--- lyx-devel/trunk/src/LyXVC.cpp Sat Nov 6 04:17:23 2010 (r36159)
+++ lyx-devel/trunk/src/LyXVC.cpp Sat Nov 6 12:54:08 2010 (r36160)
@@ -208,7 +208,7 @@
}
-void LyXVC::revert()
+bool LyXVC::revert()
{
LYXERR(Debug::LYXVC, "LyXVC: revert");
@@ -221,8 +221,7 @@
ret = Alert::prompt(_("Revert to stored version of document?"),
text, 0, 1, _("&Revert"), _("&Cancel"));
- if (ret == 0)
- vcs->revert();
+ return ret == 0 && vcs->revert();
}
Modified: lyx-devel/trunk/src/LyXVC.h
==============================================================================
--- lyx-devel/trunk/src/LyXVC.h Sat Nov 6 04:17:23 2010 (r36159)
+++ lyx-devel/trunk/src/LyXVC.h Sat Nov 6 12:54:08 2010 (r36160)
@@ -98,7 +98,7 @@
bool lockingToggleEnabled() const;
/// Revert to last version
- void revert();
+ bool revert();
/// Undo last check-in.
void undoLast();
Modified: lyx-devel/trunk/src/VCBackend.cpp
==============================================================================
--- lyx-devel/trunk/src/VCBackend.cpp Sat Nov 6 04:17:23 2010 (r36159)
+++ lyx-devel/trunk/src/VCBackend.cpp Sat Nov 6 12:54:08 2010 (r36160)
@@ -267,13 +267,15 @@
}
-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 @@
}
-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 @@
switch (status) {
case UpToDate:
if (vcstatus != NOLOCKING)
- unedit();
+ return 0 == unedit();
break;
case NeedsMerge:
case NeedsCheckout:
@@ -856,7 +858,7 @@
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 @@
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 @@
}
-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;
}
Modified: lyx-devel/trunk/src/VCBackend.h
==============================================================================
--- lyx-devel/trunk/src/VCBackend.h Sat Nov 6 04:17:23 2010 (r36159)
+++ lyx-devel/trunk/src/VCBackend.h Sat Nov 6 12:54:08 2010 (r36160)
@@ -57,7 +57,7 @@
// 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 @@
virtual bool lockingToggleEnabled();
- virtual void revert();
+ virtual bool revert();
virtual bool isRevertWithConfirmation();
@@ -214,7 +214,7 @@
virtual bool isRevertWithConfirmation();
- virtual void revert();
+ virtual bool revert();
virtual void undoLast();
@@ -340,7 +340,7 @@
virtual bool lockingToggleEnabled();
- virtual void revert();
+ virtual bool revert();
virtual bool isRevertWithConfirmation();
Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Sat Nov 6 04:17:23
2010 (r36159)
+++ lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Sat Nov 6 12:54:08
2010 (r36160)
@@ -2701,9 +2701,10 @@
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: