1999-11-09 23:52:04 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file VCBackend.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-02-26 10:50:48 +00:00
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-08-23 00:17:00 +00:00
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-02-26 10:50:48 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
#ifndef VC_BACKEND_H
|
|
|
|
|
#define VC_BACKEND_H
|
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
#include "support/filename.h"
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
1999-11-09 23:52:04 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
class Buffer;
|
|
|
|
|
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// A simple version control system interface
|
1999-11-09 23:52:04 +00:00
|
|
|
|
class VCS {
|
|
|
|
|
public:
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// the status of the managed file
|
1999-11-09 23:52:04 +00:00
|
|
|
|
enum VCStatus {
|
|
|
|
|
UNLOCKED,
|
|
|
|
|
LOCKED
|
|
|
|
|
};
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual ~VCS() {}
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
|
|
|
|
/// register a file for version control
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual void registrer(std::string const & msg) = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// check in the current revision
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual void checkIn(std::string const & msg) = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// check out for editing
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void checkOut() = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// revert current edits
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void revert() = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// FIXME
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void undoLast() = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* getLog - read the revision log into the given file
|
|
|
|
|
* @param fname file name to read into
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*/
|
2006-12-02 16:07:15 +00:00
|
|
|
|
virtual void getLog(support::FileName const &) = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// return the current version description
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const versionString() const = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// return the current version
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const & version() const {
|
2002-03-21 17:27:08 +00:00
|
|
|
|
return version_;
|
2001-08-19 14:06:27 +00:00
|
|
|
|
}
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// return the user who has locked the file
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const & locker() const { return locker_; }
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// set the owning buffer
|
1999-11-09 23:52:04 +00:00
|
|
|
|
void owner(Buffer * b) { owner_ = b; }
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// return the owning buffer
|
1999-11-09 23:52:04 +00:00
|
|
|
|
Buffer * owner() const { return owner_; }
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// return the lock status of this file
|
2000-05-17 16:42:35 +00:00
|
|
|
|
VCStatus status() const { return vcstatus; }
|
1999-11-09 23:52:04 +00:00
|
|
|
|
protected:
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// parse information from the version file
|
|
|
|
|
virtual void scanMaster() = 0;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* doVCCommand - call out to the version control utility
|
|
|
|
|
* @param cmd the command to execute
|
|
|
|
|
* @param path the path from which to execute
|
|
|
|
|
* @return exit status
|
|
|
|
|
*/
|
2007-04-06 18:03:29 +00:00
|
|
|
|
static int doVCCommand(std::string const & cmd, support::FileName const & path);
|
1999-11-09 23:52:04 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
/**
|
2002-02-26 10:50:48 +00:00
|
|
|
|
* The master VC file. For RCS this is *,v or RCS/ *,v. master should
|
|
|
|
|
* have full path.
|
|
|
|
|
*/
|
2006-12-02 16:07:15 +00:00
|
|
|
|
support::FileName master_;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
/// The status of the VC controlled file.
|
2000-05-17 16:42:35 +00:00
|
|
|
|
VCStatus vcstatus;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2002-02-26 10:50:48 +00:00
|
|
|
|
* The version of the VC file. I am not sure if this can be a
|
2002-03-21 17:27:08 +00:00
|
|
|
|
* string or if it must be a float/int.
|
2002-02-26 10:50:48 +00:00
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string version_;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
/// The user currently keeping the lock on the VC file.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string locker_;
|
1999-11-09 23:52:04 +00:00
|
|
|
|
/// The buffer using this VC
|
|
|
|
|
Buffer * owner_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
class RCS : public VCS {
|
|
|
|
|
public:
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
explicit
|
2006-12-02 16:07:15 +00:00
|
|
|
|
RCS(support::FileName const & m);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
|
|
|
|
/// return the revision file for the given file, if found
|
2006-12-02 16:07:15 +00:00
|
|
|
|
static support::FileName const find_file(support::FileName const & file);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
static void retrieve(support::FileName const & file);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual void registrer(std::string const & msg);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual void checkIn(std::string const & msg);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void checkOut();
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void revert();
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void undoLast();
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
virtual void getLog(support::FileName const &);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const versionString() const {
|
2001-08-19 14:06:27 +00:00
|
|
|
|
return "RCS: " + version_;
|
|
|
|
|
}
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void scanMaster();
|
1999-11-09 23:52:04 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
class CVS : public VCS {
|
|
|
|
|
public:
|
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
explicit
|
2006-12-02 16:07:15 +00:00
|
|
|
|
CVS(support::FileName const & m, support::FileName const & f);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
|
|
|
|
/// return the revision file for the given file, if found
|
2006-12-02 16:07:15 +00:00
|
|
|
|
static support::FileName const find_file(support::FileName const & file);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual void registrer(std::string const & msg);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual void checkIn(std::string const & msg);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void checkOut();
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void revert();
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void undoLast();
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
virtual void getLog(support::FileName const &);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const versionString() const {
|
2001-08-19 14:06:27 +00:00
|
|
|
|
return "CVS: " + version_;
|
|
|
|
|
}
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void scanMaster();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
private:
|
2006-12-02 16:07:15 +00:00
|
|
|
|
support::FileName file_;
|
1999-11-09 23:52:04 +00:00
|
|
|
|
};
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-02-26 10:50:48 +00:00
|
|
|
|
#endif // VCBACKEND_H
|