9 #include FORMS_H_LOCATION
11 #include "vc-backend.h"
13 #include "lyx_gui_misc.h"
16 #include "support/filetools.h"
17 #include "support/lyxlib.h"
37 bool LyXVC::file_found_hook(string const & fn)
40 // Check if file is under RCS
41 if (!(found_file = RCS::find_file(fn)).empty()) {
42 vcs = new RCS(found_file);
46 // Check if file is under CVS
47 if (!(found_file = CVS::find_file(fn)).empty()) {
48 vcs = new CVS(found_file, fn);
52 // file is not under any VCS.
57 bool LyXVC::file_not_found_hook(string const & fn)
59 // Check if file is under RCS
60 if (!RCS::find_file(fn).empty())
62 if (!CVS::find_file(fn).empty())
68 void LyXVC::buffer(Buffer * buf)
74 void LyXVC::registrer()
76 // it is very likely here that the vcs is not created yet...
77 // so... we use RCS as default, later this should perhaps be
80 vcs = new RCS(owner_->fileName());
84 // If the document is changed, we might want to save it
85 if (!vcs->owner()->isLyxClean() &&
86 AskQuestion(_("Changes in document:"),
87 MakeDisplayPath(vcs->owner()->fileName(), 50),
88 _("Save document and proceed?"))) {
89 vcs->owner()->getUser()->owner()
90 ->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
93 // Maybe the save fails, or we answered "no". In both cases,
94 // the document will be dirty, and we abort.
95 if (!vcs->owner()->isLyxClean()) {
99 lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl;
100 pair<bool, string> tmp =
101 askForText(_("LyX VC: Initial description"),
102 _("(no initial description)"));
103 if (!tmp.first || tmp.second.empty()) {
104 // should we insist on checking tmp.second.empty()?
105 lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
106 WriteAlert(_("Info"),
107 _("This document has NOT been registered."));
111 vcs->registrer(tmp.second);
115 void LyXVC::checkIn()
117 // If the document is changed, we might want to save it
118 if (!vcs->owner()->isLyxClean() &&
119 AskQuestion(_("Changes in document:"),
120 MakeDisplayPath(vcs->owner()->fileName(), 50),
121 _("Save document and proceed?"))) {
122 vcs->owner()->getUser()->owner()
123 ->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
126 // Maybe the save fails, or we answered "no". In both cases,
127 // the document will be dirty, and we abort.
128 if (!vcs->owner()->isLyxClean()) {
132 lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
133 pair<bool, string> tmp = askForText(_("LyX VC: Log Message"));
135 if (tmp.second.empty()) {
136 tmp.second = _("(no log message)");
138 vcs->checkIn(tmp.second);
140 lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
145 void LyXVC::checkOut()
147 lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl;
148 if (!vcs->owner()->isLyxClean()
149 && !AskQuestion(_("Changes in document:"),
150 MakeDisplayPath(vcs->owner()->fileName(), 50),
151 _("Ignore changes and proceed with check out?"))) {
162 lyxerr[Debug::LYXVC] << "LyXVC: revert" << endl;
163 // Here we should check if the buffer is dirty. And if it is
164 // we should warn the user that reverting will discard all
165 // changes made since the last check in.
166 if (AskQuestion(_("When you revert, you will loose all changes made"),
167 _("to the document since the last check in."),
168 _("Do you still want to do it?"))) {
175 void LyXVC::undoLast()
181 void LyXVC::toggleReadOnly()
183 switch (vcs->status()) {
185 lyxerr[Debug::LYXVC] << "LyXVC: toggle to locked" << endl;
189 lyxerr[Debug::LYXVC] << "LyXVC: toggle to unlocked" << endl;
198 if (vcs) return true;
203 string const & LyXVC::version() const
205 return vcs->version();
209 string const & LyXVC::locker() const
211 return vcs->locker();
215 const string LyXVC::getLogFile() const
220 string tmpf = lyx::tempName(string(), "lyxvclog");
221 lyxerr[Debug::LYXVC] << "Generating logfile " << tmpf << endl;