]> git.lyx.org Git - lyx.git/blobdiff - src/VCBackend.cpp
This should bring cvs revision control to usable state.
[lyx.git] / src / VCBackend.cpp
index c92a648ffd7b6d6e3e6074d47b13786ed8f9940c..1673072797bf8f056fc6860b766a31601968b007 100644 (file)
 #include <config.h>
 
 #include "VCBackend.h"
-#include "support/debug.h"
 #include "Buffer.h"
 
-#include "support/Path.h"
+#include "support/debug.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
+#include "support/Path.h"
 #include "support/Systemcall.h"
 
 #include <boost/regex.hpp>
@@ -24,6 +24,7 @@
 #include <fstream>
 
 using namespace std;
+using namespace lyx::support;
 
 using boost::regex;
 using boost::regex_match;
@@ -31,17 +32,6 @@ using boost::smatch;
 
 namespace lyx {
 
-using support::addName;
-using support::addPath;
-using support::contains;
-using support::FileName;
-using support::onlyFilename;
-using support::onlyPath;
-using support::quoteName;
-using support::rtrim;
-using support::split;
-using support::Systemcall;
-
 
 int VCS::doVCCommand(string const & cmd, FileName const & path)
 {
@@ -70,7 +60,7 @@ FileName const RCS::findFile(FileName const & file)
 {
        // Check if *,v exists.
        FileName tmp(file.absFilename() + ",v");
-       LYXERR(Debug::LYXVC, "Checking if file is under rcs: " << tmp);
+       LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
        if (tmp.isReadableFile()) {
                LYXERR(Debug::LYXVC, "Yes " << file << " is under rcs.");
                return tmp;
@@ -78,7 +68,7 @@ FileName const RCS::findFile(FileName const & file)
 
        // Check if RCS/*,v exists.
        tmp = FileName(addName(addPath(onlyPath(file.absFilename()), "RCS"), file.absFilename()) + ",v");
-       LYXERR(Debug::LYXVC, "Checking if file is under rcs: " << tmp);
+       LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
        if (tmp.isReadableFile()) {
                LYXERR(Debug::LYXVC, "Yes " << file << " it is under rcs.");
                return tmp;
@@ -173,6 +163,10 @@ void RCS::checkIn(string const & msg)
                    FileName(owner_->filePath()));
 }
 
+bool RCS::checkInEnabled()
+{
+       return owner_ && !owner_->isReadonly();
+}
 
 void RCS::checkOut()
 {
@@ -182,6 +176,12 @@ void RCS::checkOut()
 }
 
 
+bool RCS::checkOutEnabled()
+{
+       return owner_ && owner_->isReadonly();
+}
+
+
 void RCS::revert()
 {
        doVCCommand("co -f -u" + version() + " "
@@ -201,6 +201,12 @@ void RCS::undoLast()
 }
 
 
+bool RCS::undoLastEnabled()
+{
+       return true;
+}
+
+
 void RCS::getLog(FileName const & tmpf)
 {
        doVCCommand("rlog " + quoteName(onlyFilename(owner_->absFileName()))
@@ -227,20 +233,20 @@ FileName const CVS::findFile(FileName const & file)
 {
        // First we look for the CVS/Entries in the same dir
        // where we have file.
-       FileName const dir(onlyPath(file.absFilename()) + "/CVS/Entries");
+       FileName const entries(onlyPath(file.absFilename()) + "/CVS/Entries");
        string const tmpf = '/' + onlyFilename(file.absFilename()) + '/';
-       LYXERR(Debug::LYXVC, "LyXVC: checking in `" << dir
+       LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under cvs in `" << entries
                             << "' for `" << tmpf << '\'');
-       if (dir.isReadableDirectory()) {
+       if (entries.isReadableFile()) {
                // Ok we are at least in a CVS dir. Parse the CVS/Entries
                // and see if we can find this file. We do a fast and
                // dirty parse here.
-               ifstream ifs(dir.toFilesystemEncoding().c_str());
+               ifstream ifs(entries.toFilesystemEncoding().c_str());
                string line;
                while (getline(ifs, line)) {
                        LYXERR(Debug::LYXVC, "\tEntries: " << line);
                        if (contains(line, tmpf))
-                               return dir;
+                               return entries;
                }
        }
        return FileName();
@@ -307,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
@@ -314,6 +326,12 @@ void CVS::checkOut()
 }
 
 
+bool CVS::checkOutEnabled()
+{
+       return false;
+}
+
+
 void CVS::revert()
 {
        // Reverts to the version in CVS repository and
@@ -335,6 +353,12 @@ void CVS::undoLast()
 }
 
 
+bool CVS::undoLastEnabled()
+{
+       return false;
+}
+
+
 void CVS::getLog(FileName const & tmpf)
 {
        doVCCommand("cvs log " + quoteName(onlyFilename(owner_->absFileName()))