]> git.lyx.org Git - features.git/commitdiff
Support revision fetching also for RCS.
authorPavel Sanda <sanda@lyx.org>
Mon, 15 Feb 2010 09:05:24 +0000 (09:05 +0000)
committerPavel Sanda <sanda@lyx.org>
Mon, 15 Feb 2010 09:05:24 +0000 (09:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33477 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyXAction.cpp
src/VCBackend.cpp

index fe9916aea3b8fa9bab52c603b0b8e464d7ea5a31..6c7d4c92770e042cff0a05b49119a31751cad8c3 100644 (file)
@@ -2193,10 +2193,11 @@ void LyXAction::init()
 /*!
  * \var lyx::FuncCode lyx::LFUN_VC_COMPARE
  * \li Action: Compares two revisions of the same file under version control.
- * \li Notion: This is currently implemented only for SVN.
+ * \li Notion: This is currently implemented only for SVN and RCS.
  * \li Syntax: vc-compare <REV1> [<REV2>]
  * \li Params: Revision number either points directly to commit in history
-               or - if negative number -x - it points to last commit - x.
+               or if negative number -x it points to last commit - x.\n
+              In RCS we subtract only in the last part of revision specification.
                Special case "0" is reserved for the last committed revision.\n
                <REV1>: Older file.\n
               <REV2>: Newer file. Used only if REV1 > 0.
index bf52e7006b7ec430142b8980ea2cf3850e3d527e..82b16e4b35859ebd8190d99963742184b0b02d37 100644 (file)
@@ -290,15 +290,52 @@ string RCS::revisionInfo(LyXVC::RevisionInfo const info)
 }
 
 
-bool RCS::prepareFileRevision(string const &, string &)
+bool RCS::prepareFileRevision(string const &revis, string & f)
 {
-       return false;
+       string rev = revis;
+
+       if (isStrInt(rev)) {
+               int back = convert<int>(rev);
+               if (back > 0)
+                       return false;
+               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");
+       if (tmpf.empty()) {
+               LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+               return N_("Error: Could not generate logfile.");
+       }
+
+       doVCCommand("co -p" + rev + " "
+                     + quoteName(onlyFilename(owner_->absFileName()))
+                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
+               FileName(owner_->filePath()));
+       if (tmpf.isFileEmpty())
+               return false;
+
+       f = tmpf.absFilename();
+       return true;
 }
 
 
 bool RCS::prepareFileRevisionEnabled()
 {
-       return false;
+       return true;
 }