From: Pavel Sanda Date: Mon, 15 Feb 2010 09:05:24 +0000 (+0000) Subject: Support revision fetching also for RCS. X-Git-Tag: 2.0.0~4025 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=74c70e39cb95e2cb2bea6e4dae597e394157b153;p=features.git Support revision fetching also for RCS. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33477 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index fe9916aea3..6c7d4c9277 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -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 [] * \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 : Older file.\n : Newer file. Used only if REV1 > 0. diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index bf52e7006b..82b16e4b35 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -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(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(cur) + back; + if (want <= 0) + return false; + + rev = base + "." + convert(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; }