4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
15 #include "support/FileName.h"
24 /// A simple version control system interface
27 /// the status of the managed file
36 /// register a file for version control
37 virtual void registrer(std::string const & msg) = 0;
38 /// check in the current revision, returns log
39 virtual std::string checkIn(std::string const & msg) = 0;
40 // can be this operation processed in the current RCS?
41 virtual bool checkInEnabled() = 0;
42 /// check out for editing, returns log
43 virtual std::string checkOut() = 0;
44 // can be this operation processed in the current RCS?
45 virtual bool checkOutEnabled() = 0;
46 /// revert current edits
47 virtual void revert() = 0;
49 virtual void undoLast() = 0;
50 // can be this operation processed in the current RCS?
51 virtual bool undoLastEnabled() = 0;
53 * getLog - read the revision log into the given file
54 * @param fname file name to read into
56 virtual void getLog(support::FileName const &) = 0;
57 /// return the current version description
58 virtual std::string const versionString() const = 0;
59 /// return the current version
60 std::string const & version() const { return version_; }
61 /// return the user who has locked the file
62 std::string const & locker() const { return locker_; }
63 /// set the owning buffer
64 void owner(Buffer * b) { owner_ = b; }
65 /// return the owning buffer
66 Buffer * owner() const { return owner_; }
67 /// return the lock status of this file
68 VCStatus status() const { return vcstatus; }
69 /// do we need special handling for read-only toggling?
70 /// (also used for check-out operation)
71 virtual bool toggleReadOnlyEnabled() = 0;
73 /// parse information from the version file
74 virtual void scanMaster() = 0;
76 // GUI container for doVCCommandCall
77 int doVCCommand(std::string const & cmd, support::FileName const & path);
79 * doVCCommandCall - call out to the version control utility
80 * @param cmd the command to execute
81 * @param path the path from which to execute
84 static int doVCCommandCall(std::string const & cmd, support::FileName const & path);
87 * The master VC file. For RCS this is *,v or RCS/ *,v. master should
90 support::FileName master_;
92 /// The status of the VC controlled file.
96 * The version of the VC file. I am not sure if this can be a
97 * string or if it must be a float/int.
101 /// The user currently keeping the lock on the VC file.
103 /// The buffer using this VC
109 class RCS : public VCS {
113 RCS(support::FileName const & m);
115 /// return the revision file for the given file, if found
116 static support::FileName const findFile(support::FileName const & file);
118 static void retrieve(support::FileName const & file);
120 virtual void registrer(std::string const & msg);
122 virtual std::string checkIn(std::string const & msg);
124 virtual bool checkInEnabled();
126 virtual std::string checkOut();
128 virtual bool checkOutEnabled();
130 virtual void revert();
132 virtual void undoLast();
134 virtual bool undoLastEnabled();
136 virtual void getLog(support::FileName const &);
138 virtual std::string const versionString() const {
139 return "RCS: " + version_;
142 virtual bool toggleReadOnlyEnabled();
145 virtual void scanMaster();
150 class CVS : public VCS {
154 CVS(support::FileName const & m, support::FileName const & f);
156 /// return the revision file for the given file, if found
157 static support::FileName const findFile(support::FileName const & file);
159 virtual void registrer(std::string const & msg);
161 virtual std::string checkIn(std::string const & msg);
163 virtual bool checkInEnabled();
165 virtual std::string checkOut();
167 virtual bool checkOutEnabled();
169 virtual void revert();
171 virtual void undoLast();
173 virtual bool undoLastEnabled();
175 virtual void getLog(support::FileName const &);
177 virtual std::string const versionString() const {
178 return "CVS: " + version_;
181 virtual bool toggleReadOnlyEnabled();
184 virtual void scanMaster();
187 support::FileName file_;
192 class SVN : public VCS {
196 SVN(support::FileName const & m, support::FileName const & f);
198 /// return the revision file for the given file, if found
199 static support::FileName const findFile(support::FileName const & file);
201 virtual void registrer(std::string const & msg);
203 virtual std::string checkIn(std::string const & msg);
205 virtual bool checkInEnabled();
207 virtual std::string checkOut();
209 virtual bool checkOutEnabled();
211 virtual void revert();
213 virtual void undoLast();
215 virtual bool undoLastEnabled();
217 virtual void getLog(support::FileName const &);
219 virtual std::string const versionString() const {
220 return "SVN: " + version_;
223 virtual bool toggleReadOnlyEnabled();
226 virtual void scanMaster();
227 /// Check for messages in svn output. Returns error.
228 std::string scanLogFile(support::FileName const & f, std::string & status);
229 /// checks locking policy and setup locked_mode_
230 bool checkLockMode();
231 /// is the loaded file locked?
232 bool isLocked() const;
233 /// acquire/release write lock for the current file
234 void fileLock(bool lock, support::FileName const & tmpf, std::string & status);
237 support::FileName file_;
238 /// is the loaded file under locking policy?
244 #endif // VCBACKEND_H