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>
17 #include "support/docstring.h"
24 namespace support { class FileName; }
29 /** Version Control for LyX.
30 This is the class giving the version control features to LyX. It is
31 intended to support different kinds of version control.
32 The support in LyX is based loosely upon the version control in GNU Emacs,
33 but is not as extensive as that one. See Extended Manual for a simple
34 tutorial and manual for the use of the version control system in LyX.
36 LyXVC use this algorithm when it searches for VC files:
37 for RCS it searches for <filename>,v and RCS/<filename>,v similarly
38 CVS/Entries for cvs and .svn/entries. By doing this there doesn't need to be any
39 special support for VC in the lyx format, and this is especially good
40 when the lyx format will be a subset of LaTeX.
44 /// Return status of a command
46 Cancelled, ///< command was cancelled
47 ErrorBefore, ///< error before executing command
48 ErrorCommand, ///< error while executing command
49 VCSuccess ///< command was executed successfully
55 /// Status of the underlying VCS
56 docstring vcstatus() const;
57 /// Is \p fn under version control?
58 static bool fileInVC(support::FileName const & fn);
59 /** Not a good name perhaps. This function should be called whenever
60 LyX loads a file. This function then checks for a master VC file (for
61 RCS this is *,v or RCS/ *,v ; for CVS this is CVS/Entries and .svn/entries
62 for SVN) if this file or entry is found, the loaded file is assumed to be
63 under control by VC, and the appropiate actions is taken.
64 Returns true if the file is under control by a VCS.
66 bool file_found_hook(support::FileName const & fn);
68 /** Is \p fn under version control?
69 This function should be run when a file is requested for loading,
70 but it does not exist. This function will then check for a VC master
71 file with the same name (see above function). If this exists the
72 user should be asked if he/her wants to checkout a version for
73 viewing/editing. Returns true if the file is under control by a VCS
74 and the user wants to view/edit it.
76 static bool file_not_found_hook(support::FileName const & fn);
79 void setBuffer(Buffer *);
81 /// Register the document as a VC file.
85 // std::string used as a return value in functions below are
86 // workaround to defer messages to be displayed in UI. If message()
87 // is used directly, message string is immediately overwritten
88 // by the next multiple messages on the top of the processed dispatch
92 std::string rename(support::FileName const &);
93 /// Does the current VC support this operation?
94 bool renameEnabled() const;
96 std::string copy(support::FileName const &);
97 /// Does the current VC support this operation?
98 bool copyEnabled() const;
100 /// Unlock and commit changes.
101 /// \p log is non-empty on success and may be empty on failure.
102 CommandResult checkIn(std::string & log);
103 /// Does the current VC support this operation?
104 bool checkInEnabled() const;
105 /// Should a log message be provided for next checkin?
106 bool isCheckInWithConfirmation() const;
108 /// Lock/update and prepare to edit document. Returns log.
109 std::string checkOut();
110 /// Does the current VC support this operation?
111 bool checkOutEnabled() const;
113 /// Synchronize the whole archive with repository
114 std::string repoUpdate();
115 /// Does the current VC support this operation?
116 bool repoUpdateEnabled() const;
119 * Toggle locking property of the edited file,
120 * i.e. whether the file uses locking mechanism.
122 std::string lockingToggle();
123 /// Does the current VC support this operation?
124 bool lockingToggleEnabled() const;
126 /// Revert to last version
129 /// Undo last check-in.
131 /// Does the current VC support this operation?
132 bool undoLastEnabled() const;
134 * Prepare revision rev of the file into newly created temporary file
135 * and save the filename into parameter f.
136 * Parameter rev can be either revision number or negative number
137 * which is interpreted as how many revision back from the current
138 * one do we want. rev=0 is reserved for the last (committed) revision.
139 * We need rev to be string, since in various VCS revision is not integer.
140 * If RCS addressed by a single number, it is automatically used
141 * as the last number in the whole revision specification (it applies
142 * for retrieving normal revisions (rev>0) or backtracking (rev<0).
144 bool prepareFileRevision(std::string const & rev, std::string & f);
145 /// Does the current VC support this operation?
146 bool prepareFileRevisionEnabled();
149 * Generate a log file and return the filename.
150 * It is the caller's responsibility to remove the
153 const std::string getLogFile() const;
156 * We do not support this generally. In RCS/SVN file read-only flag
157 * is often connected with locking state and one has to be careful to
158 * keep things in synchro once we would allow user to toggle
161 std::string toggleReadOnly();
163 /// Is the document under administration by VCS?
164 /// returns false for unregistered documents in a path managed by VCS
167 /// Returns the RCS + version number for messages
168 std::string const versionString() const;
171 * Returns whether we use locking for the given file.
173 bool locking() const;
175 // type of the revision information
186 * Return revision info specified by the argument.
187 * Its safe to call it regardless VCS is in usage or this
188 * info is (un)available. Returns empty string in such a case.
190 std::string revisionInfo(RevisionInfo const info) const;
197 boost::scoped_ptr<VCS> vcs;