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
10 * Full author contact details are available in file CREDITS.
16 #include "support/FileName.h"
27 /// A simple version control system interface
30 /// the status of the managed file
39 /// register a file for version control
40 virtual void registrer(std::string const & msg) = 0;
41 /// check in the current revision, returns log
42 virtual std::string checkIn(std::string const & msg) = 0;
43 // can be this operation processed in the current RCS?
44 virtual bool checkInEnabled() = 0;
45 /// check out for editing, returns log
46 virtual std::string checkOut() = 0;
47 // can be this operation processed in the current RCS?
48 virtual bool checkOutEnabled() = 0;
49 /// synchronize with repository, returns log
50 virtual std::string repoUpdate() = 0;
51 // can be this operation processed in the current RCS?
52 virtual bool repoUpdateEnabled() = 0;
53 // toggle locking property of the file
54 virtual std::string lockingToggle() = 0;
55 // can be this operation processed in the current RCS?
56 virtual bool lockingToggleEnabled() = 0;
57 /// revert current edits
58 virtual void revert() = 0;
60 virtual void undoLast() = 0;
61 // can be this operation processed in the current RCS?
62 virtual bool undoLastEnabled() = 0;
64 * getLog - read the revision log into the given file
65 * @param fname file name to read into
67 virtual void getLog(support::FileName const &) = 0;
68 /// return the current version description
69 virtual std::string const versionString() const = 0;
70 /// return the user who has locked the file
71 std::string const & locker() const { return locker_; }
72 /// set the owning buffer
73 void owner(Buffer * b) { owner_ = b; }
74 /// return the owning buffer
75 Buffer * owner() const { return owner_; }
76 /// return the lock status of this file
77 VCStatus status() const { return vcstatus; }
78 /// do we need special handling for read-only toggling?
79 /// (also used for check-out operation)
80 virtual bool toggleReadOnlyEnabled() = 0;
81 /// Return revision info specified by the argument.
82 virtual std::string revisionInfo(LyXVC::RevisionInfo const info) = 0;
84 /// parse information from the version file
85 virtual void scanMaster() = 0;
87 // GUI container for doVCCommandCall
88 int doVCCommand(std::string const & cmd, support::FileName const & path);
90 * doVCCommandCall - call out to the version control utility
91 * @param cmd the command to execute
92 * @param path the path from which to execute
95 static int doVCCommandCall(std::string const & cmd, support::FileName const & path);
98 * The master VC file. For RCS this is *,v or RCS/ *,v. master should
101 support::FileName master_;
103 /// The status of the VC controlled file.
106 /// The user currently keeping the lock on the VC file.
108 /// The buffer using this VC
114 class RCS : public VCS {
118 RCS(support::FileName const & m);
120 /// return the revision file for the given file, if found
121 static support::FileName const findFile(support::FileName const & file);
123 static void retrieve(support::FileName const & file);
125 virtual void registrer(std::string const & msg);
127 virtual std::string checkIn(std::string const & msg);
129 virtual bool checkInEnabled();
131 virtual std::string checkOut();
133 virtual bool checkOutEnabled();
135 virtual std::string repoUpdate();
137 virtual bool repoUpdateEnabled();
139 virtual std::string lockingToggle();
141 virtual bool lockingToggleEnabled();
143 virtual void revert();
145 virtual void undoLast();
147 virtual bool undoLastEnabled();
149 virtual void getLog(support::FileName const &);
151 virtual std::string const versionString() const {
152 return "RCS: " + version_;
155 virtual bool toggleReadOnlyEnabled();
157 virtual std::string revisionInfo(LyXVC::RevisionInfo const info);
160 virtual void scanMaster();
163 * The version of the VC file. I am not sure if this can be a
164 * string or if it must be a float/int.
166 std::string version_;
171 class CVS : public VCS {
175 CVS(support::FileName const & m, support::FileName const & f);
177 /// return the revision file for the given file, if found
178 static support::FileName const findFile(support::FileName const & file);
180 virtual void registrer(std::string const & msg);
182 virtual std::string checkIn(std::string const & msg);
184 virtual bool checkInEnabled();
186 virtual std::string checkOut();
188 virtual bool checkOutEnabled();
190 virtual std::string repoUpdate();
192 virtual bool repoUpdateEnabled();
194 virtual std::string lockingToggle();
196 virtual bool lockingToggleEnabled();
198 virtual void revert();
200 virtual void undoLast();
202 virtual bool undoLastEnabled();
204 virtual void getLog(support::FileName const &);
206 virtual std::string const versionString() const {
207 return "CVS: " + version_;
210 virtual bool toggleReadOnlyEnabled();
212 virtual std::string revisionInfo(LyXVC::RevisionInfo const info);
215 virtual void scanMaster();
218 support::FileName file_;
219 // revision number from scanMaster
220 std::string version_;
225 class SVN : public VCS {
229 SVN(support::FileName const & m, support::FileName const & f);
231 /// return the revision file for the given file, if found
232 static support::FileName const findFile(support::FileName const & file);
234 virtual void registrer(std::string const & msg);
236 virtual std::string checkIn(std::string const & msg);
238 virtual bool checkInEnabled();
240 virtual std::string checkOut();
242 virtual bool checkOutEnabled();
244 virtual std::string repoUpdate();
246 virtual bool repoUpdateEnabled();
248 virtual std::string lockingToggle();
250 virtual bool lockingToggleEnabled();
252 virtual void revert();
254 virtual void undoLast();
256 virtual bool undoLastEnabled();
258 virtual void getLog(support::FileName const &);
260 virtual std::string const versionString() const {
261 return "SVN: " + rev_file_cache_;
264 virtual bool toggleReadOnlyEnabled();
266 virtual std::string revisionInfo(LyXVC::RevisionInfo const info);
269 virtual void scanMaster();
270 /// Check for messages in svn output. Returns error.
271 std::string scanLogFile(support::FileName const & f, std::string & status);
272 /// checks locking policy and setup locked_mode_
273 bool checkLockMode();
274 /// is the loaded file locked?
275 bool isLocked() const;
276 /// acquire/release write lock for the current file
277 void fileLock(bool lock, support::FileName const & tmpf, std::string & status);
280 support::FileName file_;
281 /// is the loaded file under locking policy?
284 * Real code for obtaining file revision info. Fills all file-related caches
285 * and returns true if successfull.
286 * "?" is stored in rev_file_cache_ as a signal if request for obtaining info
287 * was already unsuccessful.
289 bool getFileRevisionInfo();
290 /// cache for file revision number, "?" if already unsuccessful
291 std::string rev_file_cache_;
292 /// cache for author of last commit
293 std::string rev_author_cache_;
294 /// cache for date of last commit
295 std::string rev_date_cache_;
296 /// cache for time of last commit
297 std::string rev_time_cache_;
298 /// fills rev_tree_cache_, returns true if successfull.
299 bool getTreeRevisionInfo();
300 /// cache for tree revision number, "?" if already unsuccessful
301 std::string rev_tree_cache_;
306 #endif // VCBACKEND_H