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 // toggle locking property of the file
47 virtual std::string lockingToggle() = 0;
48 // can be this operation processed in the current RCS?
49 virtual bool lockingToggleEnabled() = 0;
50 /// revert current edits
51 virtual void revert() = 0;
53 virtual void undoLast() = 0;
54 // can be this operation processed in the current RCS?
55 virtual bool undoLastEnabled() = 0;
57 * getLog - read the revision log into the given file
58 * @param fname file name to read into
60 virtual void getLog(support::FileName const &) = 0;
61 /// return the current version description
62 virtual std::string const versionString() const = 0;
63 /// return the current version
64 std::string const & version() const { return version_; }
65 /// return the user who has locked the file
66 std::string const & locker() const { return locker_; }
67 /// set the owning buffer
68 void owner(Buffer * b) { owner_ = b; }
69 /// return the owning buffer
70 Buffer * owner() const { return owner_; }
71 /// return the lock status of this file
72 VCStatus status() const { return vcstatus; }
73 /// do we need special handling for read-only toggling?
74 /// (also used for check-out operation)
75 virtual bool toggleReadOnlyEnabled() = 0;
77 /// parse information from the version file
78 virtual void scanMaster() = 0;
80 // GUI container for doVCCommandCall
81 int doVCCommand(std::string const & cmd, support::FileName const & path);
83 * doVCCommandCall - call out to the version control utility
84 * @param cmd the command to execute
85 * @param path the path from which to execute
88 static int doVCCommandCall(std::string const & cmd, support::FileName const & path);
91 * The master VC file. For RCS this is *,v or RCS/ *,v. master should
94 support::FileName master_;
96 /// The status of the VC controlled file.
100 * The version of the VC file. I am not sure if this can be a
101 * string or if it must be a float/int.
103 std::string version_;
105 /// The user currently keeping the lock on the VC file.
107 /// The buffer using this VC
113 class RCS : public VCS {
117 RCS(support::FileName const & m);
119 /// return the revision file for the given file, if found
120 static support::FileName const findFile(support::FileName const & file);
122 static void retrieve(support::FileName const & file);
124 virtual void registrer(std::string const & msg);
126 virtual std::string checkIn(std::string const & msg);
128 virtual bool checkInEnabled();
130 virtual std::string checkOut();
132 virtual bool checkOutEnabled();
134 virtual std::string lockingToggle();
136 virtual bool lockingToggleEnabled();
138 virtual void revert();
140 virtual void undoLast();
142 virtual bool undoLastEnabled();
144 virtual void getLog(support::FileName const &);
146 virtual std::string const versionString() const {
147 return "RCS: " + version_;
150 virtual bool toggleReadOnlyEnabled();
153 virtual void scanMaster();
158 class CVS : public VCS {
162 CVS(support::FileName const & m, support::FileName const & f);
164 /// return the revision file for the given file, if found
165 static support::FileName const findFile(support::FileName const & file);
167 virtual void registrer(std::string const & msg);
169 virtual std::string checkIn(std::string const & msg);
171 virtual bool checkInEnabled();
173 virtual std::string checkOut();
175 virtual bool checkOutEnabled();
177 virtual std::string lockingToggle();
179 virtual bool lockingToggleEnabled();
181 virtual void revert();
183 virtual void undoLast();
185 virtual bool undoLastEnabled();
187 virtual void getLog(support::FileName const &);
189 virtual std::string const versionString() const {
190 return "CVS: " + version_;
193 virtual bool toggleReadOnlyEnabled();
196 virtual void scanMaster();
199 support::FileName file_;
204 class SVN : public VCS {
208 SVN(support::FileName const & m, support::FileName const & f);
210 /// return the revision file for the given file, if found
211 static support::FileName const findFile(support::FileName const & file);
213 virtual void registrer(std::string const & msg);
215 virtual std::string checkIn(std::string const & msg);
217 virtual bool checkInEnabled();
219 virtual std::string checkOut();
221 virtual bool checkOutEnabled();
223 virtual std::string lockingToggle();
225 virtual bool lockingToggleEnabled();
227 virtual void revert();
229 virtual void undoLast();
231 virtual bool undoLastEnabled();
233 virtual void getLog(support::FileName const &);
235 virtual std::string const versionString() const {
236 return "SVN: " + version_;
239 virtual bool toggleReadOnlyEnabled();
242 virtual void scanMaster();
243 /// Check for messages in svn output. Returns error.
244 std::string scanLogFile(support::FileName const & f, std::string & status);
245 /// checks locking policy and setup locked_mode_
246 bool checkLockMode();
247 /// is the loaded file locked?
248 bool isLocked() const;
249 /// acquire/release write lock for the current file
250 void fileLock(bool lock, support::FileName const & tmpf, std::string & status);
253 support::FileName file_;
254 /// is the loaded file under locking policy?
260 #endif // VCBACKEND_H