]> git.lyx.org Git - lyx.git/blobdiff - src/vc-backend.C
Fix working of the spellchecker dialog with ispell when there are no
[lyx.git] / src / vc-backend.C
index 81efc9f6ce2a6a7c6e0c085ec47c82d81f6a599e..c745b38fb2c2ac2a80e9748c5fade3c1e6411ff3 100644 (file)
@@ -13,7 +13,9 @@
 #include "support/LSubstring.h"
 #include "support/path.h"
 #include "support/filetools.h"
+#include "support/lstrings.h"
 #include "buffer.h"
+#include "BufferView.h"
 #include "LyXView.h"
 #include "lyxfunc.h"
 
@@ -26,7 +28,7 @@ int VCS::doVCCommand(string const & cmd, string const & path)
        lyxerr[Debug::LYXVC] << "doVCCommand: " << cmd << endl;
         Systemcalls one;
        Path p(path);
-       int ret = one.startscript(Systemcalls::System, cmd);
+       int const ret = one.startscript(Systemcalls::System, cmd);
        return ret;
 }
 
@@ -110,7 +112,9 @@ void RCS::scanMaster()
                                vcstatus = UNLOCKED;
                                continue;
                        }
-                       string tmpt, s1, s2;
+                       string tmpt;
+                       string s1;
+                       string s2;
                        do {
                                ifs >> tmpt;
                                s1 = strip(tmpt, ';');
@@ -134,7 +138,6 @@ void RCS::scanMaster()
                                << endl;
                }
        }
-       version_ = "RCS: " + version_;
 }
 
 
@@ -146,7 +149,7 @@ void RCS::registrer(string const & msg)
        cmd += OnlyFilename(owner_->fileName());
        cmd += "\"";
        doVCCommand(cmd, owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
+       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
 }
 
 
@@ -154,7 +157,7 @@ void RCS::checkIn(string const & msg)
 {
        doVCCommand("ci -q -u -m\"" + msg + "\" \""
                    + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
+       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
 }
 
 
@@ -163,7 +166,7 @@ void RCS::checkOut()
        owner_->markLyxClean();
        doVCCommand("co -q -l \""
                    + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
+       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
 }
 
 
@@ -174,7 +177,7 @@ void RCS::revert()
        // We ignore changes and just reload!
        owner_->markLyxClean();
        owner_->getUser()->owner()
-               ->getLyXFunc()->Dispatch("buffer-reload");
+               ->getLyXFunc()->dispatch("buffer-reload");
 }
 
 
@@ -182,7 +185,8 @@ void RCS::undoLast()
 {
        lyxerr[Debug::LYXVC] << "LyXVC: undoLast" << endl;
        doVCCommand("rcs -o" + version() + " \""
-                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
+                   + OnlyFilename(owner_->fileName()) + "\"",
+                   owner_->filepath);
 }
 
 
@@ -205,12 +209,11 @@ string const CVS::find_file(string const & file)
 {
        // First we look for the CVS/Entries in the same dir
        // where we have file.
-       string dir = OnlyPath(file);
-       string tmpf = "/" + OnlyFilename(file) + "/";
-       dir += "/CVS/Entries";
+       string const dir = OnlyPath(file) + "/CVS/Entries";
+       string const tmpf = "/" + OnlyFilename(file) + "/";
        lyxerr[Debug::LYXVC] << "LyXVC: checking in `" << dir
                             << "' for `" << tmpf << "'" << endl;
-       FileInfo f(dir);
+       FileInfo const f(dir);
        if (f.readable()) {
                // 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
@@ -243,8 +246,7 @@ void CVS::scanMaster()
                        LRegex::SubMatches const & sm = reg.exec(line);
                        //sm[0]; // whole matched string
                        //sm[1]; // filename
-                       version_ = "CVS: ";
-                       version_ += LSubstring(line, sm[2].first,
+                       version_ = LSubstring(line, sm[2].first,
                                              sm[2].second);
                        string file_date = LSubstring(line, sm[3].first,
                                                      sm[3].second);
@@ -276,15 +278,16 @@ void CVS::registrer(string const & msg)
 {
        doVCCommand("cvs -q add -m \"" + msg + "\" \""
                    + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
+       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
 }
 
 
 void CVS::checkIn(string const & msg)
 {
        doVCCommand("cvs -q commit -m \"" + msg + "\" \""
-                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
-       owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload");
+                   + OnlyFilename(owner_->fileName()) + "\"",
+                   owner_->filepath);
+       owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
 }
 
 
@@ -297,10 +300,15 @@ void CVS::checkOut()
 
 void CVS::revert()
 {
-       // not sure how to do this...
-       // rm file
-       // cvs update
-       lyxerr << "Sorry not implemented." << endl;
+       // Reverts to the version in CVS repository and
+       // gets the updated version from the repository.
+       string const fil = OnlyFilename(owner_->fileName());
+       
+       doVCCommand("rm -f \"" + fil + "\"; cvs update \"" + fil + "\"",
+                   owner_->filepath);
+       owner_->markLyxClean();
+       owner_->getUser()->owner()
+               ->getLyXFunc()->dispatch("buffer-reload");
 }
 
 
@@ -313,7 +321,9 @@ void CVS::undoLast()
 }
 
 
-void CVS::getLog(string const &)
+void CVS::getLog(string const & tmpf)
 {
-       lyxerr << "Sorry not implemented." << endl;
+       doVCCommand("cvs log \""
+                   + OnlyFilename(owner_->fileName()) + "\" > " + tmpf,
+                   owner_->filepath);
 }