1999-11-09 23:52:04 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file vc-backend.h
|
|
|
|
|
* Copyright 1995-2002 the LyX Team
|
|
|
|
|
* Read the file COPYING
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*/
|
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
|
|
|
|
|
#ifndef VC_BACKEND_H
|
|
|
|
|
#define VC_BACKEND_H
|
|
|
|
|
|
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
|
|
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
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void registrer(string const & msg) = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// check in the current revision
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void checkIn(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
|
|
|
|
*/
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void getLog(string const &) = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// return the current version description
|
2001-08-19 14:06:27 +00:00
|
|
|
|
virtual string const versionString() const = 0;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// return the current version
|
2001-08-19 14:06:27 +00:00
|
|
|
|
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
|
1999-11-09 23:52:04 +00:00
|
|
|
|
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
|
|
|
|
|
2003-03-08 05:37:54 +00:00
|
|
|
|
/// reload the document
|
|
|
|
|
void reload();
|
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
static int doVCCommand(string const & cmd, string 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.
|
|
|
|
|
*/
|
1999-11-09 23:52:04 +00:00
|
|
|
|
string 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
|
|
|
|
*/
|
1999-11-09 23:52:04 +00:00
|
|
|
|
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.
|
|
|
|
|
string locker_;
|
|
|
|
|
/// 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
|
1999-11-09 23:52:04 +00:00
|
|
|
|
RCS(string const & m);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
|
|
|
|
/// return the revision file for the given file, if found
|
2000-09-14 17:53:12 +00:00
|
|
|
|
static string const find_file(string const & file);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
|
|
|
|
static void retrieve(string const & file);
|
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void registrer(string const & msg);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void checkIn(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
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void getLog(string const &);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2001-08-19 14:06:27 +00:00
|
|
|
|
virtual string const versionString() const {
|
|
|
|
|
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
|
1999-11-09 23:52:04 +00:00
|
|
|
|
CVS(string const & m, string const & f);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
|
|
|
|
/// return the revision file for the given file, if found
|
2000-09-14 17:53:12 +00:00
|
|
|
|
static string const find_file(string const & file);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void registrer(string const & msg);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void checkIn(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
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
virtual void getLog(string const &);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
|
2001-08-19 14:06:27 +00:00
|
|
|
|
virtual string const versionString() const {
|
|
|
|
|
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:
|
|
|
|
|
string file_;
|
|
|
|
|
};
|
2002-02-26 10:50:48 +00:00
|
|
|
|
#endif // VCBACKEND_H
|