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 <boost/scoped_ptr.hpp>
22 namespace support { class FileName; }
27 /** Version Control for LyX.
28 This is the class giving the version control features to LyX. It is
29 intended to support different kinds of version control.
30 The support in LyX is based loosely upon the version control in GNU Emacs,
31 but is not as extensive as that one. See Extended Manual for a simple
32 tutorial and manual for the use of the version control system in LyX.
34 LyXVC use this algorithm when it searches for VC files:
35 for RCS it searches for <filename>,v and RCS/<filename>,v similarly
36 CVS/Entries for cvs and .svn/entries. By doing this there doesn't need to be any
37 special support for VC in the lyx format, and this is especially good
38 when the lyx format will be a subset of LaTeX.
46 /// Is \p fn under version control?
47 static bool fileInVC(support::FileName const & fn);
48 /** Not a good name perhaps. This function should be called whenever
49 LyX loads a file. This function then checks for a master VC file (for
50 RCS this is *,v or RCS/ *,v ; for CVS this is CVS/Entries and .svn/entries
51 for SVN) if this file or entry is found, the loaded file is assumed to be
52 under control by VC, and the appropiate actions is taken.
53 Returns true if the file is under control by a VCS.
55 bool file_found_hook(support::FileName const & fn);
57 /** Is \p fn under version control?
58 This function should be run when a file is requested for loading,
59 but it does not exist. This function will then check for a VC master
60 file with the same name (see above function). If this exists the
61 user should be asked if he/her wants to checkout a version for
62 viewing/editing. Returns true if the file is under control by a VCS
63 and the user wants to view/edit it.
65 static bool file_not_found_hook(support::FileName const & fn);
68 void setBuffer(Buffer *);
70 /// Register the document as a VC file.
74 // std::string used as a return value in functions below are
75 // workaround to defer messages to be displayed in UI. If message()
76 // is used directly, message string is immediately overwritten
77 // by the next multiple messages on the top of the processed dispatch
80 /// Unlock and commit changes. Returns log.
81 std::string checkIn();
82 /// Does the current VC supports this operation?
83 bool checkInEnabled() const;
85 /// Lock/update and prepare to edit document. Returns log.
86 std::string checkOut();
87 /// Does the current VC supports this operation?
88 bool checkOutEnabled() const;
90 /// Synchronize the whole archive with repository
91 std::string repoUpdate();
92 /// Does the current VC supports this operation?
93 bool repoUpdateEnabled() const;
96 * Toggle locking property of the edited file,
97 * i.e. whether the file uses locking mechanism.
99 std::string lockingToggle();
100 /// Does the current VC support this operation?
101 bool lockingToggleEnabled() const;
103 /// Revert to last version
106 /// Undo last check-in.
108 /// Does the current VC supports this operation?
109 bool undoLastEnabled() const;
111 * Prepare revision rev of the file into newly created temporary file
112 * and save the filename into parameter f.
113 * Parameter rev can be either revision number or negative number
114 * which is interpreted as how many revision back from the current
115 * one do we want. rev=0 is reserved for the last (committed) revision.
116 * We need rev to be string, since in various VCS revision is not integer.
117 * If RCS addressed by a single number, it is automatically used
118 * as the last number in the whole revision specification (it applies
119 * for retrieving normal revisions (rev>0) or backtracking (rev<0).
121 bool prepareFileRevision(std::string const & rev, std::string & f);
122 /// Does the current VC supports this operation?
123 bool prepareFileRevisionEnabled();
126 * Generate a log file and return the filename.
127 * It is the caller's responsibility to remove the
130 const std::string getLogFile() const;
133 * We do not support this generally. In RCS/SVN file read-only flag
134 * is often connected with locking state and one has to be careful to
135 * keep things in synchro once we would allow user to toggle
138 void toggleReadOnly();
140 /// Is the document under administration by VCS?
143 /// Returns the RCS + version number for messages
144 std::string const versionString() const;
147 * Returns whether we use locking for the given file.
149 bool locking() const;
151 // type of the revision information
162 * Return revision info specified by the argument.
163 * Its safe to call it regardless VCS is in usage or this
164 * info is (un)available. Returns empty string in such a case.
166 std::string revisionInfo(RevisionInfo const info) const;
173 boost::scoped_ptr<VCS> vcs;