From 4b00e7f5272c3db6dbd1cd1bb484390c64c24574 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Mon, 21 Jul 2008 01:55:58 +0000 Subject: [PATCH] This should bring cvs revision control to usable state. LyXVC API was too narrow to master both cvs and rcs, so we have to change interface. We still need one more operation for cvs update, but i need to sleep sometimes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25750 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 8 +++++--- src/LyXVC.cpp | 18 ++++++++++++++++++ src/LyXVC.h | 6 ++++++ src/VCBackend.cpp | 34 ++++++++++++++++++++++++++++++++++ src/VCBackend.h | 18 ++++++++++++++++++ 5 files changed, 81 insertions(+), 3 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index baea6d962c..2a8bcb3dbc 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -461,15 +461,17 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const enable = !buf->lyxvc().inUse(); break; case LFUN_VC_CHECK_IN: - enable = buf->lyxvc().inUse() && !buf->isReadonly(); + enable = buf->lyxvc().checkInEnabled(); break; case LFUN_VC_CHECK_OUT: - enable = buf->lyxvc().inUse() && buf->isReadonly(); + enable = buf->lyxvc().checkOutEnabled(); break; case LFUN_VC_REVERT: - case LFUN_VC_UNDO_LAST: enable = buf->lyxvc().inUse(); break; + case LFUN_VC_UNDO_LAST: + enable = buf->lyxvc().undoLastEnabled(); + break; case LFUN_BUFFER_RELOAD: enable = !buf->isUnnamed() && buf->fileName().exists() && (!buf->isClean() || buf->isExternallyModified(Buffer::timestamp_method)); diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index b79d4f9426..e156396fe2 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -228,4 +228,22 @@ string const LyXVC::getLogFile() const } +bool LyXVC::checkOutEnabled() +{ + return vcs && vcs->checkOutEnabled(); +} + + +bool LyXVC::checkInEnabled() +{ + return vcs && vcs->checkInEnabled(); +} + + +bool LyXVC::undoLastEnabled() +{ + return vcs && vcs->undoLastEnabled(); +} + + } // namespace lyx diff --git a/src/LyXVC.h b/src/LyXVC.h index 59413e2153..337f797293 100644 --- a/src/LyXVC.h +++ b/src/LyXVC.h @@ -70,15 +70,21 @@ public: /// Unlock and commit changes. void checkIn(); + /// Does the current VC supports this operation? + bool checkInEnabled(); /// Lock and prepare to edit document. void checkOut(); + /// Does the current VC supports this operation? + bool checkOutEnabled(); /// Revert to last version void revert(); /// Undo last check-in. void undoLast(); + /// Does the current VC supports this operation? + bool undoLastEnabled(); /** * Generate a log file and return the filename. diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index c933aece49..1673072797 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -163,6 +163,10 @@ void RCS::checkIn(string const & msg) FileName(owner_->filePath())); } +bool RCS::checkInEnabled() +{ + return owner_ && !owner_->isReadonly(); +} void RCS::checkOut() { @@ -172,6 +176,12 @@ void RCS::checkOut() } +bool RCS::checkOutEnabled() +{ + return owner_ && owner_->isReadonly(); +} + + void RCS::revert() { doVCCommand("co -f -u" + version() + " " @@ -191,6 +201,12 @@ void RCS::undoLast() } +bool RCS::undoLastEnabled() +{ + return true; +} + + void RCS::getLog(FileName const & tmpf) { doVCCommand("rlog " + quoteName(onlyFilename(owner_->absFileName())) @@ -297,6 +313,12 @@ void CVS::checkIn(string const & msg) } +bool CVS::checkInEnabled() +{ + return true; +} + + void CVS::checkOut() { // cvs update or perhaps for cvs this should be a noop @@ -304,6 +326,12 @@ void CVS::checkOut() } +bool CVS::checkOutEnabled() +{ + return false; +} + + void CVS::revert() { // Reverts to the version in CVS repository and @@ -325,6 +353,12 @@ void CVS::undoLast() } +bool CVS::undoLastEnabled() +{ + return false; +} + + void CVS::getLog(FileName const & tmpf) { doVCCommand("cvs log " + quoteName(onlyFilename(owner_->absFileName())) diff --git a/src/VCBackend.h b/src/VCBackend.h index 551874f3d1..43e1027a9f 100644 --- a/src/VCBackend.h +++ b/src/VCBackend.h @@ -36,12 +36,18 @@ public: virtual void registrer(std::string const & msg) = 0; /// check in the current revision virtual void checkIn(std::string const & msg) = 0; + // can be this operation processed in the current RCS? + virtual bool checkInEnabled() = 0; /// check out for editing virtual void checkOut() = 0; + // can be this operation processed in the current RCS? + virtual bool checkOutEnabled() = 0; /// revert current edits virtual void revert() = 0; /// FIXME virtual void undoLast() = 0; + // can be this operation processed in the current RCS? + virtual bool undoLastEnabled() = 0; /** * getLog - read the revision log into the given file * @param fname file name to read into @@ -109,12 +115,18 @@ public: virtual void checkIn(std::string const & msg); + virtual bool checkInEnabled(); + virtual void checkOut(); + virtual bool checkOutEnabled(); + virtual void revert(); virtual void undoLast(); + virtual bool undoLastEnabled(); + virtual void getLog(support::FileName const &); virtual std::string const versionString() const { @@ -140,12 +152,18 @@ public: virtual void checkIn(std::string const & msg); + virtual bool checkInEnabled(); + virtual void checkOut(); + virtual bool checkOutEnabled(); + virtual void revert(); virtual void undoLast(); + virtual bool undoLastEnabled(); + virtual void getLog(support::FileName const &); virtual std::string const versionString() const {