Am 06.11.2010 um 03:21 schrieb sa...@lyx.org:

> Author: sanda
> Date: Sat Nov  6 03:21:04 2010
> New Revision: 36153
> URL: http://www.lyx.org/trac/changeset/36153
> 
> Log:
> Fix RCS part of #6396. Btw revert is slightly broken now...

Patch 1 should fix it... ok?

Patch 2 implements "Compare with older revision" for CVS... ok?

Stephan

Index: src/LyXVC.cpp
===================================================================
--- src/LyXVC.cpp       (Revision 36154)
+++ src/LyXVC.cpp       (Arbeitskopie)
@@ -208,7 +208,7 @@
 }
 
 
-void LyXVC::revert()
+bool LyXVC::revert()
 {
        LYXERR(Debug::LYXVC, "LyXVC: revert");
 
@@ -223,6 +223,7 @@
 
        if (ret == 0)
                vcs->revert();
+       return ret == 0;
 }
 
 
Index: src/frontends/qt4/GuiView.cpp
===================================================================
--- src/frontends/qt4/GuiView.cpp       (Revision 36154)
+++ src/frontends/qt4/GuiView.cpp       (Arbeitskopie)
@@ -2701,9 +2701,10 @@
 
        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:

Index: src/VCBackend.h
===================================================================
--- src/VCBackend.h     (Revision 36152)
+++ src/VCBackend.h     (Arbeitskopie)
@@ -91,6 +91,10 @@
        /// parse information from the version file
        virtual void scanMaster() = 0;
 
+       /// make a relative version identifier
+       /// suitable for RCS and CVS
+       bool makeRCSRevision(std::string const &version, std::string &revis) 
const;
+       
        // GUI container for doVCCommandCall
        int doVCCommand(std::string const & cmd, support::FileName const & 
path, bool reportError = true);
        /**
Index: src/VCBackend.cpp
===================================================================
--- src/VCBackend.cpp   (Revision 36152)
+++ src/VCBackend.cpp   (Arbeitskopie)
@@ -65,6 +65,40 @@
 }
 
 
+bool VCS::makeRCSRevision(string const &version, string &revis) const
+{
+       string rev = revis;
+       
+       if (isStrInt(rev)) {
+               int back = convert<int>(rev);
+               // if positive use as the last number in the whole revision 
string
+               if (back > 0) {
+                       string base;
+                       rsplit(version, base , '.' );
+                       rev = base + "." + rev;
+               }
+               if (back == 0)
+                       rev = version;
+               // we care about the last number from revision string
+               // in case of backward indexing
+               if (back < 0) {
+                       string cur, base;
+                       cur = rsplit(version, base , '.' );
+                       if (!isStrInt(cur))
+                               return false;
+                       int want = convert<int>(cur) + back;
+                       if (want <= 0)
+                               return false;
+                       
+                       rev = base + "." + convert<string>(want);
+               }
+       }
+
+       revis = rev;
+       return true;
+}
+       
+       
 /////////////////////////////////////////////////////////////////////
 //
 // RCS
@@ -306,32 +340,9 @@
 bool RCS::prepareFileRevision(string const &revis, string & f)
 {
        string rev = revis;
+       if (!VCS::makeRCSRevision(version_, rev))
+               return false;
 
-       if (isStrInt(rev)) {
-               int back = convert<int>(rev);
-               // if positive use as the last number in the whole revision 
string
-               if (back > 0) {
-                       string base;
-                       rsplit(version_, base , '.' );
-                       rev = base + "." + rev;
-               }
-               if (back == 0)
-                       rev = version_;
-               // we care about the last number from revision string
-               // in case of backward indexing
-               if (back < 0) {
-                       string cur, base;
-                       cur = rsplit(version_, base , '.' );
-                       if (!isStrInt(cur))
-                               return false;
-                       int want = convert<int>(cur) + back;
-                       if (want <= 0)
-                               return false;
-
-                       rev = base + "." + convert<string>(want);
-               }
-       }
-
        FileName tmpf = FileName::tempName("lyxvcrev_" + rev + "_");
        if (tmpf.empty()) {
                LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
@@ -898,15 +909,32 @@
 }
 
 
-bool CVS::prepareFileRevision(string const &, string &)
+bool CVS::prepareFileRevision(string const & revis, string & f)
 {
-       return false;
+       string rev = revis;
+       if (!VCS::makeRCSRevision(version_, rev))
+               return false;
+
+       FileName tmpf = FileName::tempName("lyxvcrev_" + rev + "_");
+       if (tmpf.empty()) {
+               LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+               return false;
+       }
+
+       doVCCommandWithOutput("cvs update -p -r" + rev + " "
+               + getTarget(File),
+               FileName(owner_->filePath()), tmpf);
+       if (tmpf.isFileEmpty())
+               return false;
+
+       f = tmpf.absFileName();
+       return true;
 }
 
 
 bool CVS::prepareFileRevisionEnabled()
 {
-       return false;
+       return true;
 }
 
 
@@ -1435,7 +1463,7 @@
        FileName tmpf = FileName::tempName("lyxvcrev_" + revname + "_");
        if (tmpf.empty()) {
                LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
-               return N_("Error: Could not generate logfile.");
+               return false;
        }
 
        doVCCommand("svn cat -r " + revname + " "

Reply via email to