From 2c7a7e72c2f24cf3cccbd2a73e980fd83b730d1a Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Sat, 6 Nov 2010 12:18:09 +0000 Subject: [PATCH] implementation for "Compare with older revision" for CVS, correct return value of SVN::prepareFileRevision for failure to create tmp file git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36161 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/VCBackend.cpp | 86 +++++++++++++++++++++++++++++++---------------- src/VCBackend.h | 4 +++ 2 files changed, 61 insertions(+), 29 deletions(-) diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index 723cbde5fa..bfa1efbf68 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -65,6 +65,40 @@ int VCS::doVCCommand(string const & cmd, FileName const & path, bool reportError } +bool VCS::makeRCSRevision(string const &version, string &revis) const +{ + string rev = revis; + + if (isStrInt(rev)) { + int back = convert(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(cur) + back; + if (want <= 0) + return false; + + rev = base + "." + convert(want); + } + } + + revis = rev; + return true; +} + + ///////////////////////////////////////////////////////////////////// // // RCS @@ -329,31 +363,8 @@ string RCS::revisionInfo(LyXVC::RevisionInfo const info) bool RCS::prepareFileRevision(string const &revis, string & f) { string rev = revis; - - if (isStrInt(rev)) { - int back = convert(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(cur) + back; - if (want <= 0) - return false; - - rev = base + "." + convert(want); - } - } + if (!VCS::makeRCSRevision(version_, rev)) + return false; FileName tmpf = FileName::tempName("lyxvcrev_" + rev + "_"); if (tmpf.empty()) { @@ -922,15 +933,32 @@ string CVS::revisionInfo(LyXVC::RevisionInfo const info) } -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; } @@ -1478,7 +1506,7 @@ bool SVN::prepareFileRevision(string const & revis, string & f) 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 + " " diff --git a/src/VCBackend.h b/src/VCBackend.h index 5832f11d8f..8042fc0577 100644 --- a/src/VCBackend.h +++ b/src/VCBackend.h @@ -91,6 +91,10 @@ protected: /// 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); /**