VCS: Extended API for revision info

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33425 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2010-02-12 01:43:59 +00:00
parent 22b98a7ca4
commit 7b227d6899
4 changed files with 67 additions and 4 deletions

View File

@ -287,6 +287,15 @@ string const LyXVC::getLogFile() const
} }
std::string const LyXVC::revisionInfo(RevisionInfo const info)
{
if (!vcs)
return string();
return vcs->revisionInfo(info);
}
bool LyXVC::checkOutEnabled() const bool LyXVC::checkOutEnabled() const
{ {
return vcs && vcs->checkOutEnabled(); return vcs && vcs->checkOutEnabled();

View File

@ -123,8 +123,7 @@ public:
/// Is the document under administration by VCS? /// Is the document under administration by VCS?
bool inUse() const; bool inUse() const;
/// FIXME resurrect version once we add version info /// FIXME Either rename or kill, we have revisionInfo now.
/// into SVN. RCS parser is already prepared.
/// Returns the version number. /// Returns the version number.
//std::string const & version() const; //std::string const & version() const;
/// Returns the version number. /// Returns the version number.
@ -144,6 +143,18 @@ public:
*/ */
std::string const & locker() const; std::string const & locker() const;
// type of the revision information
enum RevisionInfo {
File = 1
};
/**
* Return revision info specified by the argument.
* Its safe to call it regardless VCS is in usage or this
* info is (un)available. Returns empty string in such a case.
*/
std::string const revisionInfo(RevisionInfo const info);
private: private:
/// ///
Buffer * owner_; Buffer * owner_;

View File

@ -280,6 +280,12 @@ bool RCS::toggleReadOnlyEnabled()
return false; return false;
} }
// FIXME This could be implemented with cache from scanMaster
string const RCS::revisionInfo(LyXVC::RevisionInfo const)
{
return string();
}
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// //
@ -475,6 +481,13 @@ bool CVS::toggleReadOnlyEnabled()
return false; return false;
} }
string const CVS::revisionInfo(LyXVC::RevisionInfo const)
{
return string();
}
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// //
// SVN // SVN
@ -844,7 +857,25 @@ bool SVN::undoLastEnabled()
} }
string SVN::getFileRevisionInfo(){ string const SVN::revisionInfo(LyXVC::RevisionInfo const info)
{
switch (info) {
case LyXVC::File:
if (_rev_file_cache.empty())
_rev_file_cache = getFileRevisionInfo();
if (_rev_file_cache.empty())
_rev_file_cache = "?";
if (_rev_file_cache == "?")
return string();
return _rev_file_cache;
}
return string();
}
std::string SVN::getFileRevisionInfo()
{
FileName tmpf = FileName::tempName("lyxvcout"); FileName tmpf = FileName::tempName("lyxvcout");
doVCCommand("svn info --xml " + quoteName(onlyFilename(owner_->absFileName())) doVCCommand("svn info --xml " + quoteName(onlyFilename(owner_->absFileName()))

View File

@ -16,6 +16,8 @@
#include <string> #include <string>
#include "LyXVC.h"
namespace lyx { namespace lyx {
@ -77,6 +79,8 @@ public:
/// do we need special handling for read-only toggling? /// do we need special handling for read-only toggling?
/// (also used for check-out operation) /// (also used for check-out operation)
virtual bool toggleReadOnlyEnabled() = 0; virtual bool toggleReadOnlyEnabled() = 0;
/// Return revision info specified by the argument.
virtual std::string const revisionInfo(LyXVC::RevisionInfo const info) = 0;
protected: protected:
/// parse information from the version file /// parse information from the version file
virtual void scanMaster() = 0; virtual void scanMaster() = 0;
@ -157,6 +161,8 @@ public:
virtual bool toggleReadOnlyEnabled(); virtual bool toggleReadOnlyEnabled();
virtual std::string const revisionInfo(LyXVC::RevisionInfo const info);
protected: protected:
virtual void scanMaster(); virtual void scanMaster();
}; };
@ -204,6 +210,8 @@ public:
virtual bool toggleReadOnlyEnabled(); virtual bool toggleReadOnlyEnabled();
virtual std::string const revisionInfo(LyXVC::RevisionInfo const info);
protected: protected:
virtual void scanMaster(); virtual void scanMaster();
@ -254,7 +262,7 @@ public:
virtual bool toggleReadOnlyEnabled(); virtual bool toggleReadOnlyEnabled();
std::string getFileRevisionInfo(); virtual std::string const revisionInfo(LyXVC::RevisionInfo const info);
protected: protected:
virtual void scanMaster(); virtual void scanMaster();
@ -271,6 +279,10 @@ private:
support::FileName file_; support::FileName file_;
/// is the loaded file under locking policy? /// is the loaded file under locking policy?
bool locked_mode_; bool locked_mode_;
/// real code for obtaining file revision info
std::string getFileRevisionInfo();
/// cache for file revision number, "?" if already unsuccessful
std::string _rev_file_cache;
}; };
} // namespace lyx } // namespace lyx