#6396 no dialog when no doc changes were done and check-in or revert is done

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35828 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stephan Witt 2010-10-25 13:27:48 +00:00
parent 80a5dd8144
commit c6d4080694
3 changed files with 77 additions and 11 deletions

View File

@ -165,7 +165,9 @@ string LyXVC::checkIn()
docstring empty(_("(no log message)"));
docstring response;
string log;
bool ok = Alert::askForText(response, _("LyX VC: Log Message"));
bool ok = true;
if (vcs->isCheckInWithConfirmation())
ok = Alert::askForText(response, _("LyX VC: Log Message"));
if (ok) {
if (response.empty())
response = empty;
@ -214,8 +216,10 @@ void LyXVC::revert()
docstring text = bformat(_("Reverting to the stored version of the "
"document %1$s will lose all current changes.\n\n"
"Do you want to revert to the older version?"), file);
int const ret = Alert::prompt(_("Revert to stored version of document?"),
text, 0, 1, _("&Revert"), _("&Cancel"));
int ret = 0;
if (vcs->isRevertWithConfirmation())
ret = Alert::prompt(_("Revert to stored version of document?"),
text, 0, 1, _("&Revert"), _("&Cancel"));
if (ret == 0)
vcs->revert();

View File

@ -195,6 +195,12 @@ bool RCS::checkInEnabled()
return owner_ && !owner_->isReadonly();
}
bool RCS::isCheckInWithConfirmation()
{
//FIXME diff
return true;
}
string RCS::checkOut()
{
@ -247,6 +253,13 @@ void RCS::revert()
}
bool RCS::isRevertWithConfirmation()
{
//FIXME owner && diff ?
return true;
}
void RCS::undoLast()
{
LYXERR(Debug::LYXVC, "LyXVC: undoLast");
@ -612,6 +625,13 @@ bool CVS::checkInEnabled()
}
bool CVS::isCheckInWithConfirmation()
{
CvsStatus status = getStatus();
return status == LocallyModified || status == LocallyAdded;
}
string CVS::checkOut()
{
if (vcstatus != NOLOCKING && edit())
@ -705,6 +725,13 @@ bool CVS::lockingToggleEnabled()
}
bool CVS::isRevertWithConfirmation()
{
CvsStatus status = getStatus();
return !owner_->isClean() || status == LocallyModified || status == NeedsMerge;
}
void CVS::revert()
{
// Reverts to the version in CVS repository and
@ -724,17 +751,22 @@ void CVS::revert()
owner_->markClean();
break;
}
case LocallyAdded:
case LocallyAdded: {
docstring const file = owner_->fileName().displayName(20);
frontend::Alert::error(_("Revision control error."),
_("The current file is not in repository.\n"
"You have to check in the first revision before you can 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;
default:
}
default: {
docstring const file = owner_->fileName().displayName(20);
frontend::Alert::error(_("Revision control error."),
bformat(_("Bad status when checking in changes.\n"
"\n'%1$s'\n\n"),
toString(status)));
bformat(_("Cannot revert document %1$s to repository version.\n"
"The status '%2$s' is unexpected."),
file, toString(status)));
break;
}
}
}
@ -928,6 +960,13 @@ bool SVN::checkInEnabled()
}
bool SVN::isCheckInWithConfirmation()
{
//FIXME diff
return true;
}
// FIXME Correctly return code should be checked instead of this.
// This would need another solution than just plain startscript.
// Hint from Andre': QProcess::readAllStandardError()...
@ -1129,7 +1168,7 @@ bool SVN::lockingToggleEnabled()
void SVN::revert()
{
// Reverts to the version in CVS repository and
// Reverts to the version in SVN repository and
// gets the updated version from the repository.
string const fil = quoteName(onlyFileName(owner_->absFileName()));
@ -1139,6 +1178,13 @@ void SVN::revert()
}
bool SVN::isRevertWithConfirmation()
{
//FIXME owner && diff
return true;
}
void SVN::undoLast()
{
// merge the current with the previous version

View File

@ -42,6 +42,8 @@ public:
virtual std::string checkIn(std::string const & msg) = 0;
// can be this operation processed in the current RCS?
virtual bool checkInEnabled() = 0;
// should a log message provided for next checkin?
virtual bool isCheckInWithConfirmation() = 0;
/// check out for editing, returns log
virtual std::string checkOut() = 0;
// can be this operation processed in the current RCS?
@ -56,6 +58,8 @@ public:
virtual bool lockingToggleEnabled() = 0;
/// revert current edits
virtual void revert() = 0;
// should a confirmation before revert requested?
virtual bool isRevertWithConfirmation() = 0;
/// FIXME
virtual void undoLast() = 0;
// can be this operation processed in the current RCS?
@ -129,6 +133,8 @@ public:
virtual bool checkInEnabled();
virtual bool isCheckInWithConfirmation();
virtual std::string checkOut();
virtual bool checkOutEnabled();
@ -143,6 +149,8 @@ public:
virtual void revert();
virtual bool isRevertWithConfirmation();
virtual void undoLast();
virtual bool undoLastEnabled();
@ -190,6 +198,8 @@ public:
virtual bool checkInEnabled();
virtual bool isCheckInWithConfirmation();
virtual std::string checkOut();
virtual bool checkOutEnabled();
@ -202,6 +212,8 @@ public:
virtual bool lockingToggleEnabled();
virtual bool isRevertWithConfirmation();
virtual void revert();
virtual void undoLast();
@ -287,6 +299,8 @@ public:
virtual bool checkInEnabled();
virtual bool isCheckInWithConfirmation();
virtual std::string checkOut();
virtual bool checkOutEnabled();
@ -301,6 +315,8 @@ public:
virtual void revert();
virtual bool isRevertWithConfirmation();
virtual void undoLast();
virtual bool undoLastEnabled();