4 #include "vc-backend.h"
8 #include "funcrequest.h"
10 #include "frontends/Alert.h"
11 #include "frontends/LyXView.h"
13 #include "support/filetools.h"
14 #include "support/lyxlib.h"
18 using namespace lyx::support;
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 string const filename = owner_->fileName();
78 // there must be a file to save
79 if (!IsFileReadable(filename)) {
80 Alert::error(_("Document not saved"),
81 _("You must save the document "
82 "before it can be registered."));
86 // it is very likely here that the vcs is not created yet...
88 string const cvs_entries = "CVS/Entries";
90 if (IsFileReadable(cvs_entries)) {
92 << "LyXVC: registering "
93 << MakeDisplayPath(filename)
94 << " with CVS" << endl;
95 vcs = new CVS(cvs_entries, filename);
99 << "LyXVC: registering "
100 << MakeDisplayPath(filename)
101 << " with RCS" << endl;
102 vcs = new RCS(filename);
108 lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl;
109 pair<bool, string> tmp =
110 Alert::askForText(_("LyX VC: Initial description"),
111 _("(no initial description)"));
112 if (!tmp.first || tmp.second.empty()) {
113 // should we insist on checking tmp.second.empty()?
114 lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
118 vcs->registrer(tmp.second);
122 void LyXVC::checkIn()
125 lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
126 pair<bool, string> tmp = Alert::askForText(_("LyX VC: Log Message"));
128 if (tmp.second.empty()) {
129 tmp.second = _("(no log message)");
131 vcs->checkIn(tmp.second);
133 lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
138 void LyXVC::checkOut()
140 lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl;
148 lyxerr[Debug::LYXVC] << "LyXVC: revert" << endl;
150 string const file = MakeDisplayPath(owner_->fileName(), 20);
151 string text = bformat(_("Reverting to the stored version of the "
152 "document %1$s will lose all current changes.\n\n"
153 "Do you want to revert to the saved version?"), file);
154 int const ret = Alert::prompt(_("Revert to stored version of document?"),
155 text, 0, 1, _("&Revert"), _("&Cancel"));
162 void LyXVC::undoLast()
168 void LyXVC::toggleReadOnly()
170 switch (vcs->status()) {
172 lyxerr[Debug::LYXVC] << "LyXVC: toggle to locked" << endl;
176 lyxerr[Debug::LYXVC] << "LyXVC: toggle to unlocked" << endl;
185 if (vcs) return true;
190 //string const & LyXVC::version() const
192 // return vcs->version();
195 string const LyXVC::versionString() const
197 return vcs->versionString();
201 string const & LyXVC::locker() const
203 return vcs->locker();
207 string const LyXVC::getLogFile() const
212 string tmpf = tempName(string(), "lyxvclog");
213 lyxerr[Debug::LYXVC] << "Generating logfile " << tmpf << endl;