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"
26 /// A simple version control system interface
29 /// the status of the managed file
38 /// register a file for version control
39 virtual void registrer(std::string const & msg) = 0;
40 /// check in the current revision, returns log
41 virtual std::string checkIn(std::string const & msg) = 0;
42 // can be this operation processed in the current RCS?
43 virtual bool checkInEnabled() = 0;
44 /// check out for editing, returns log
45 virtual std::string checkOut() = 0;
46 // can be this operation processed in the current RCS?
47 virtual bool checkOutEnabled() = 0;
48 /// synchronize with repository, returns log
49 virtual std::string repoUpdate() = 0;
50 // can be this operation processed in the current RCS?
51 virtual bool repoUpdateEnabled() = 0;
52 // toggle locking property of the file
53 virtual std::string lockingToggle() = 0;
54 // can be this operation processed in the current RCS?
55 virtual bool lockingToggleEnabled() = 0;
56 /// revert current edits
57 virtual void revert() = 0;
59 virtual void undoLast() = 0;
60 // can be this operation processed in the current RCS?
61 virtual bool undoLastEnabled() = 0;
63 * getLog - read the revision log into the given file
64 * @param fname file name to read into
66 virtual void getLog(support::FileName const &) = 0;
67 /// return the current version description
68 virtual std::string const versionString() const = 0;
69 /// return the current version
70 std::string const & version() const { return version_; }
71 /// return the user who has locked the file
72 std::string const & locker() const { return locker_; }
73 /// set the owning buffer
74 void owner(Buffer * b) { owner_ = b; }
75 /// return the owning buffer
76 Buffer * owner() const { return owner_; }
77 /// return the lock status of this file
78 VCStatus status() const { return vcstatus; }
79 /// do we need special handling for read-only toggling?
80 /// (also used for check-out operation)
81 virtual bool toggleReadOnlyEnabled() = 0;
82 /// Return revision info specified by the argument.
83 virtual std::string revisionInfo(LyXVC::RevisionInfo const info) = 0;
85 /// parse information from the version file
86 virtual void scanMaster() = 0;
88 // GUI container for doVCCommandCall
89 int doVCCommand(std::string const & cmd, support::FileName const & path);
91 * doVCCommandCall - call out to the version control utility
92 * @param cmd the command to execute
93 * @param path the path from which to execute
96 static int doVCCommandCall(std::string const & cmd, support::FileName const & path);
99 * The master VC file. For RCS this is *,v or RCS/ *,v. master should
102 support::FileName master_;
104 /// The status of the VC controlled file.
108 * The version of the VC file. I am not sure if this can be a
109 * string or if it must be a float/int.
111 std::string version_;
113 /// The user currently keeping the lock on the VC file.
115 /// The buffer using this VC
121 class RCS : public VCS {
125 RCS(support::FileName const & m);
127 /// return the revision file for the given file, if found
128 static support::FileName const findFile(support::FileName const & file);
130 static void retrieve(support::FileName const & file);
132 virtual void registrer(std::string const & msg);
134 virtual std::string checkIn(std::string const & msg);
136 virtual bool checkInEnabled();
138 virtual std::string checkOut();
140 virtual bool checkOutEnabled();
142 virtual std::string repoUpdate();
144 virtual bool repoUpdateEnabled();
146 virtual std::string lockingToggle();
148 virtual bool lockingToggleEnabled();
150 virtual void revert();
152 virtual void undoLast();
154 virtual bool undoLastEnabled();
156 virtual void getLog(support::FileName const &);
158 virtual std::string const versionString() const {
159 return "RCS: " + version_;
162 virtual bool toggleReadOnlyEnabled();
164 virtual std::string revisionInfo(LyXVC::RevisionInfo const info);
167 virtual void scanMaster();
172 class CVS : public VCS {
176 CVS(support::FileName const & m, support::FileName const & f);
178 /// return the revision file for the given file, if found
179 static support::FileName const findFile(support::FileName const & file);
181 virtual void registrer(std::string const & msg);
183 virtual std::string checkIn(std::string const & msg);
185 virtual bool checkInEnabled();
187 virtual std::string checkOut();
189 virtual bool checkOutEnabled();
191 virtual std::string repoUpdate();
193 virtual bool repoUpdateEnabled();
195 virtual std::string lockingToggle();
197 virtual bool lockingToggleEnabled();
199 virtual void revert();
201 virtual void undoLast();
203 virtual bool undoLastEnabled();
205 virtual void getLog(support::FileName const &);
207 virtual std::string const versionString() const {
208 return "CVS: " + version_;
211 virtual bool toggleReadOnlyEnabled();
213 virtual std::string revisionInfo(LyXVC::RevisionInfo const info);
216 virtual void scanMaster();
219 support::FileName file_;
224 class SVN : public VCS {
228 SVN(support::FileName const & m, support::FileName const & f);
230 /// return the revision file for the given file, if found
231 static support::FileName const findFile(support::FileName const & file);
233 virtual void registrer(std::string const & msg);
235 virtual std::string checkIn(std::string const & msg);
237 virtual bool checkInEnabled();
239 virtual std::string checkOut();
241 virtual bool checkOutEnabled();
243 virtual std::string repoUpdate();
245 virtual bool repoUpdateEnabled();
247 virtual std::string lockingToggle();
249 virtual bool lockingToggleEnabled();
251 virtual void revert();
253 virtual void undoLast();
255 virtual bool undoLastEnabled();
257 virtual void getLog(support::FileName const &);
259 virtual std::string const versionString() const {
260 return "SVN: " + version_;
263 virtual bool toggleReadOnlyEnabled();
265 virtual std::string revisionInfo(LyXVC::RevisionInfo const info);
268 virtual void scanMaster();
269 /// Check for messages in svn output. Returns error.
270 std::string scanLogFile(support::FileName const & f, std::string & status);
271 /// checks locking policy and setup locked_mode_
272 bool checkLockMode();
273 /// is the loaded file locked?
274 bool isLocked() const;
275 /// acquire/release write lock for the current file
276 void fileLock(bool lock, support::FileName const & tmpf, std::string & status);
279 support::FileName file_;
280 /// is the loaded file under locking policy?
282 /// real code for obtaining file revision info
283 std::string getFileRevisionInfo();
284 /// cache for file revision number, "?" if already unsuccessful
285 std::string rev_file_cache_;
286 /// real code for obtaining file revision info
287 std::string getTreeRevisionInfo();
288 /// cache for tree revision number, "?" if already unsuccessful
289 std::string rev_tree_cache_;
294 #endif // VCBACKEND_H