mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
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
This commit is contained in:
parent
da1e7e14ce
commit
ba00acbd65
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
bool lockingToggleEnabled() const;
|
||||
|
||||
/// Revert to last version
|
||||
void revert();
|
||||
bool revert();
|
||||
|
||||
/// Undo last check-in.
|
||||
void undoLast();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user