]> git.lyx.org Git - lyx.git/blob - src/VCBackend.cpp
Shortcut for LyX HTML output. (Makes my life easier!)
[lyx.git] / src / VCBackend.cpp
1 /**
2  * \file VCBackend.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "VCBackend.h"
14 #include "Buffer.h"
15
16 #include "frontends/alert.h"
17
18 #include "support/debug.h"
19 #include "support/filetools.h"
20 #include "support/gettext.h"
21 #include "support/lstrings.h"
22 #include "support/Path.h"
23 #include "support/Systemcall.h"
24
25 #include <boost/regex.hpp>
26
27 #include <fstream>
28
29 using namespace std;
30 using namespace lyx::support;
31
32 using boost::regex;
33 using boost::regex_match;
34 using boost::smatch;
35
36 namespace lyx {
37
38
39 int VCS::doVCCommandCall(string const & cmd, FileName const & path)
40 {
41         LYXERR(Debug::LYXVC, "doVCCommandCall: " << cmd);
42         Systemcall one;
43         support::PathChanger p(path);
44         return one.startscript(Systemcall::Wait, cmd);
45 }
46
47
48 int VCS::doVCCommand(string const & cmd, FileName const & path)
49 {
50         if (owner_)
51                 owner_->setBusy(true);
52
53         int const ret = doVCCommandCall(cmd, path);
54
55         if (owner_)
56                 owner_->setBusy(false);
57         if (ret)
58                 frontend::Alert::error(_("Revision control error."),
59                         bformat(_("Some problem occured while running the command:\n"
60                                   "'%1$s'."),
61                         from_utf8(cmd)));
62         return ret;
63 }
64
65
66 /////////////////////////////////////////////////////////////////////
67 //
68 // RCS
69 //
70 /////////////////////////////////////////////////////////////////////
71
72 RCS::RCS(FileName const & m)
73 {
74         master_ = m;
75         scanMaster();
76 }
77
78
79 FileName const RCS::findFile(FileName const & file)
80 {
81         // Check if *,v exists.
82         FileName tmp(file.absFilename() + ",v");
83         LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
84         if (tmp.isReadableFile()) {
85                 LYXERR(Debug::LYXVC, "Yes, " << file << " is under rcs.");
86                 return tmp;
87         }
88
89         // Check if RCS/*,v exists.
90         tmp = FileName(addName(addPath(onlyPath(file.absFilename()), "RCS"), file.absFilename()) + ",v");
91         LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
92         if (tmp.isReadableFile()) {
93                 LYXERR(Debug::LYXVC, "Yes, " << file << " is under rcs.");
94                 return tmp;
95         }
96
97         return FileName();
98 }
99
100
101 void RCS::retrieve(FileName const & file)
102 {
103         LYXERR(Debug::LYXVC, "LyXVC::RCS: retrieve.\n\t" << file);
104         doVCCommandCall("co -q -r " + quoteName(file.toFilesystemEncoding()),
105                          FileName());
106 }
107
108
109 void RCS::scanMaster()
110 {
111         if (master_.empty())
112                 return;
113
114         LYXERR(Debug::LYXVC, "LyXVC::RCS: scanMaster: " << master_);
115
116         ifstream ifs(master_.toFilesystemEncoding().c_str());
117
118         string token;
119         bool read_enough = false;
120
121         while (!read_enough && ifs >> token) {
122                 LYXERR(Debug::LYXVC, "LyXVC::scanMaster: current lex text: `"
123                         << token << '\'');
124
125                 if (token.empty())
126                         continue;
127                 else if (token == "head") {
128                         // get version here
129                         string tmv;
130                         ifs >> tmv;
131                         tmv = rtrim(tmv, ";");
132                         version_ = tmv;
133                         LYXERR(Debug::LYXVC, "LyXVC: version found to be " << tmv);
134                 } else if (contains(token, "access")
135                            || contains(token, "symbols")
136                            || contains(token, "strict")) {
137                         // nothing
138                 } else if (contains(token, "locks")) {
139                         // get locker here
140                         if (contains(token, ';')) {
141                                 locker_ = "Unlocked";
142                                 vcstatus = UNLOCKED;
143                                 continue;
144                         }
145                         string tmpt;
146                         string s1;
147                         string s2;
148                         do {
149                                 ifs >> tmpt;
150                                 s1 = rtrim(tmpt, ";");
151                                 // tmp is now in the format <user>:<version>
152                                 s1 = split(s1, s2, ':');
153                                 // s2 is user, and s1 is version
154                                 if (s1 == version_) {
155                                         locker_ = s2;
156                                         vcstatus = LOCKED;
157                                         break;
158                                 }
159                         } while (!contains(tmpt, ';'));
160
161                 } else if (token == "comment") {
162                         // we don't need to read any further than this.
163                         read_enough = true;
164                 } else {
165                         // unexpected
166                         LYXERR(Debug::LYXVC, "LyXVC::scanMaster(): unexpected token");
167                 }
168         }
169 }
170
171
172 void RCS::registrer(string const & msg)
173 {
174         string cmd = "ci -q -u -i -t-\"";
175         cmd += msg;
176         cmd += "\" ";
177         cmd += quoteName(onlyFilename(owner_->absFileName()));
178         doVCCommand(cmd, FileName(owner_->filePath()));
179 }
180
181
182 string RCS::checkIn(string const & msg)
183 {
184         int ret = doVCCommand("ci -q -u -m\"" + msg + "\" "
185                     + quoteName(onlyFilename(owner_->absFileName())),
186                     FileName(owner_->filePath()));
187         return ret ? string() : "RCS: Proceeded";
188 }
189
190
191 bool RCS::checkInEnabled()
192 {
193         return owner_ && !owner_->isReadonly();
194 }
195
196
197 string RCS::checkOut()
198 {
199         owner_->markClean();
200         int ret = doVCCommand("co -q -l " + quoteName(onlyFilename(owner_->absFileName())),
201                     FileName(owner_->filePath()));
202         return ret ? string() : "RCS: Proceeded";
203 }
204
205
206 bool RCS::checkOutEnabled()
207 {
208         return owner_ && owner_->isReadonly();
209 }
210
211
212 string RCS::repoUpdate()
213 {
214         lyxerr << "Sorry, not implemented." << endl;
215         return string();
216 }
217
218
219 bool RCS::repoUpdateEnabled()
220 {
221         return false;
222 }
223
224
225 string RCS::lockingToggle()
226 {
227         lyxerr << "Sorry, not implemented." << endl;
228         return string();
229 }
230
231
232 bool RCS::lockingToggleEnabled()
233 {
234         return false;
235 }
236
237
238 void RCS::revert()
239 {
240         doVCCommand("co -f -u" + version() + " "
241                     + quoteName(onlyFilename(owner_->absFileName())),
242                     FileName(owner_->filePath()));
243         // We ignore changes and just reload!
244         owner_->markClean();
245 }
246
247
248 void RCS::undoLast()
249 {
250         LYXERR(Debug::LYXVC, "LyXVC: undoLast");
251         doVCCommand("rcs -o" + version() + " "
252                     + quoteName(onlyFilename(owner_->absFileName())),
253                     FileName(owner_->filePath()));
254 }
255
256
257 bool RCS::undoLastEnabled()
258 {
259         return true;
260 }
261
262
263 void RCS::getLog(FileName const & tmpf)
264 {
265         doVCCommand("rlog " + quoteName(onlyFilename(owner_->absFileName()))
266                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
267                     FileName(owner_->filePath()));
268 }
269
270
271 bool RCS::toggleReadOnlyEnabled()
272 {
273         return true;
274 }
275
276
277 /////////////////////////////////////////////////////////////////////
278 //
279 // CVS
280 //
281 /////////////////////////////////////////////////////////////////////
282
283 CVS::CVS(FileName const & m, FileName const & f)
284 {
285         master_ = m;
286         file_ = f;
287         scanMaster();
288 }
289
290
291 FileName const CVS::findFile(FileName const & file)
292 {
293         // First we look for the CVS/Entries in the same dir
294         // where we have file.
295         FileName const entries(onlyPath(file.absFilename()) + "/CVS/Entries");
296         string const tmpf = '/' + onlyFilename(file.absFilename()) + '/';
297         LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under cvs in `" << entries
298                              << "' for `" << tmpf << '\'');
299         if (entries.isReadableFile()) {
300                 // Ok we are at least in a CVS dir. Parse the CVS/Entries
301                 // and see if we can find this file. We do a fast and
302                 // dirty parse here.
303                 ifstream ifs(entries.toFilesystemEncoding().c_str());
304                 string line;
305                 while (getline(ifs, line)) {
306                         LYXERR(Debug::LYXVC, "\tEntries: " << line);
307                         if (contains(line, tmpf))
308                                 return entries;
309                 }
310         }
311         return FileName();
312 }
313
314
315 void CVS::scanMaster()
316 {
317         LYXERR(Debug::LYXVC, "LyXVC::CVS: scanMaster. \n     Checking: " << master_);
318         // Ok now we do the real scan...
319         ifstream ifs(master_.toFilesystemEncoding().c_str());
320         string tmpf = '/' + onlyFilename(file_.absFilename()) + '/';
321         LYXERR(Debug::LYXVC, "\tlooking for `" << tmpf << '\'');
322         string line;
323         static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
324         while (getline(ifs, line)) {
325                 LYXERR(Debug::LYXVC, "\t  line: " << line);
326                 if (contains(line, tmpf)) {
327                         // Ok extract the fields.
328                         smatch sm;
329
330                         regex_match(line, sm, reg);
331
332                         //sm[0]; // whole matched string
333                         //sm[1]; // filename
334                         version_ = sm.str(2);
335                         string const file_date = sm.str(3);
336
337                         //sm[4]; // options
338                         //sm[5]; // tag or tagdate
339                         // FIXME: must double check file is stattable/existing
340                         time_t mod = file_.lastModified();
341                         string mod_date = rtrim(asctime(gmtime(&mod)), "\n");
342                         LYXERR(Debug::LYXVC, "Date in Entries: `" << file_date
343                                 << "'\nModification date of file: `" << mod_date << '\'');
344                         //FIXME this whole locking bussiness is not working under cvs and the machinery
345                         // conforms to the ci usage, not cvs.
346                         if (file_date == mod_date) {
347                                 locker_ = "Unlocked";
348                                 vcstatus = UNLOCKED;
349                         } else {
350                                 // Here we should also to some more checking
351                                 // to see if there are conflicts or not.
352                                 locker_ = "Locked";
353                                 vcstatus = LOCKED;
354                         }
355                         break;
356                 }
357         }
358 }
359
360
361 void CVS::registrer(string const & msg)
362 {
363         doVCCommand("cvs -q add -m \"" + msg + "\" "
364                     + quoteName(onlyFilename(owner_->absFileName())),
365                     FileName(owner_->filePath()));
366 }
367
368
369 string CVS::checkIn(string const & msg)
370 {
371         int ret = doVCCommand("cvs -q commit -m \"" + msg + "\" "
372                     + quoteName(onlyFilename(owner_->absFileName())),
373                     FileName(owner_->filePath()));
374         return ret ? string() : "CVS: Proceeded";
375 }
376
377
378 bool CVS::checkInEnabled()
379 {
380         return true;
381 }
382
383
384 string CVS::checkOut()
385 {
386         // cvs update or perhaps for cvs this should be a noop
387         // we need to detect conflict (eg "C" in output)
388         // before we can do this.
389         lyxerr << "Sorry, not implemented." << endl;
390         return string();
391 }
392
393
394 bool CVS::checkOutEnabled()
395 {
396         return false;
397 }
398
399
400 string CVS::repoUpdate()
401 {
402         lyxerr << "Sorry, not implemented." << endl;
403         return string();
404 }
405
406
407 bool CVS::repoUpdateEnabled()
408 {
409         return false;
410 }
411
412
413 string CVS::lockingToggle()
414 {
415         lyxerr << "Sorry, not implemented." << endl;
416         return string();
417 }
418
419
420 bool CVS::lockingToggleEnabled()
421 {
422         return false;
423 }
424
425
426 void CVS::revert()
427 {
428         // Reverts to the version in CVS repository and
429         // gets the updated version from the repository.
430         string const fil = quoteName(onlyFilename(owner_->absFileName()));
431         // This is sensitive operation, so at lest some check about
432         // existence of cvs program and its file
433         if (doVCCommand("cvs log "+ fil, FileName(owner_->filePath())))
434                 return;
435         FileName f(owner_->absFileName());
436         f.removeFile();
437         doVCCommand("cvs update " + fil,
438                     FileName(owner_->filePath()));
439         owner_->markClean();
440 }
441
442
443 void CVS::undoLast()
444 {
445         // merge the current with the previous version
446         // in a reverse patch kind of way, so that the
447         // result is to revert the last changes.
448         lyxerr << "Sorry, not implemented." << endl;
449 }
450
451
452 bool CVS::undoLastEnabled()
453 {
454         return false;
455 }
456
457
458 void CVS::getLog(FileName const & tmpf)
459 {
460         doVCCommand("cvs log " + quoteName(onlyFilename(owner_->absFileName()))
461                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
462                     FileName(owner_->filePath()));
463 }
464
465
466 bool CVS::toggleReadOnlyEnabled()
467 {
468         return false;
469 }
470
471 /////////////////////////////////////////////////////////////////////
472 //
473 // SVN
474 //
475 /////////////////////////////////////////////////////////////////////
476
477 SVN::SVN(FileName const & m, FileName const & f)
478 {
479         owner_ = 0;
480         master_ = m;
481         file_ = f;
482         locked_mode_ = 0;
483         scanMaster();
484 }
485
486
487 FileName const SVN::findFile(FileName const & file)
488 {
489         // First we look for the .svn/entries in the same dir
490         // where we have file.
491         FileName const entries(onlyPath(file.absFilename()) + "/.svn/entries");
492         string const tmpf = onlyFilename(file.absFilename());
493         LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under svn in `" << entries
494                              << "' for `" << tmpf << '\'');
495         if (entries.isReadableFile()) {
496                 // Ok we are at least in a SVN dir. Parse the .svn/entries
497                 // and see if we can find this file. We do a fast and
498                 // dirty parse here.
499                 ifstream ifs(entries.toFilesystemEncoding().c_str());
500                 string line, oldline;
501                 while (getline(ifs, line)) {
502                         if (line == "dir" || line == "file")
503                                 LYXERR(Debug::LYXVC, "\tEntries: " << oldline);
504                         if (oldline == tmpf && line == "file")
505                                 return entries;
506                         oldline = line;
507                 }
508         }
509         return FileName();
510 }
511
512
513 void SVN::scanMaster()
514 {
515         locker_.clear();
516         vcstatus = NOLOCKING;
517         if (checkLockMode()) {
518                 if (isLocked()) {
519                         locker_ = "Locked";
520                         vcstatus = LOCKED;
521                 } else {
522                         locker_ = "Unlocked";
523                         vcstatus = LOCKED;
524                 }
525         }
526 }
527
528
529 bool SVN::checkLockMode()
530 {
531         FileName tmpf = FileName::tempName("lyxvcout");
532         if (tmpf.empty()){
533                 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
534                 return N_("Error: Could not generate logfile.");
535         }
536
537         LYXERR(Debug::LYXVC, "Detecting locking mode...");
538         if (doVCCommandCall("svn proplist " + quoteName(file_.onlyFileName())
539                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
540                     file_.onlyPath()))
541                 return false;
542
543         ifstream ifs(tmpf.toFilesystemEncoding().c_str());
544         string line;
545         bool ret = false;
546
547         while (ifs) {
548                 getline(ifs, line);
549                 LYXERR(Debug::LYXVC, line);
550                 if (contains(line, "svn:needs-lock"))
551                         ret = true;
552         }
553         LYXERR(Debug::LYXVC, "Locking enabled: " << ret);
554         ifs.close();
555         locked_mode_ = ret;
556         return ret;
557
558 }
559
560
561 bool SVN::isLocked() const
562 {
563         //refresh file info
564         FileName file(file_.absFilename());
565         return !file.isReadOnly();
566 }
567
568
569 void SVN::registrer(string const & /*msg*/)
570 {
571         doVCCommand("svn add -q " + quoteName(onlyFilename(owner_->absFileName())),
572                     FileName(owner_->filePath()));
573 }
574
575
576 string SVN::checkIn(string const & msg)
577 {
578         FileName tmpf = FileName::tempName("lyxvcout");
579         if (tmpf.empty()){
580                 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
581                 return N_("Error: Could not generate logfile.");
582         }
583
584         doVCCommand("svn commit -m \"" + msg + "\" "
585                     + quoteName(onlyFilename(owner_->absFileName()))
586                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
587                     FileName(owner_->filePath()));
588
589         string log;
590         string res = scanLogFile(tmpf, log);
591         if (!res.empty())
592                 frontend::Alert::error(_("Revision control error."),
593                                 _("Error when committing to repository.\n"
594                                 "You have to manually resolve the problem.\n"
595                                 "After pressing OK, LyX will reopen the document."));
596         else
597                 fileLock(false, tmpf, log);
598
599         tmpf.erase();
600         return "SVN: " + log;
601 }
602
603
604 bool SVN::checkInEnabled()
605 {
606         if (locked_mode_)
607                 return isLocked();
608         else
609                 return true;
610 }
611
612
613 // FIXME Correctly return code should be checked instead of this.
614 // This would need another solution than just plain startscript.
615 // Hint from Andre': QProcess::readAllStandardError()...
616 string SVN::scanLogFile(FileName const & f, string & status)
617 {
618         ifstream ifs(f.toFilesystemEncoding().c_str());
619         string line;
620
621         while (ifs) {
622                 getline(ifs, line);
623                 lyxerr << line << "\n";
624                 if (!line.empty()) status += line + "; ";
625                 if (prefixIs(line, "C ") || contains(line, "Commit failed")) {
626                         ifs.close();
627                         return line;
628                 }
629                 if (contains(line, "svn:needs-lock")) {
630                         ifs.close();
631                         return line;
632                 }
633         }
634         ifs.close();
635         return string();
636 }
637
638
639 void SVN::fileLock(bool lock, FileName const & tmpf, string &status)
640 {
641         if (!locked_mode_ || (isLocked() == lock))
642                 return;
643
644         string arg = lock ? "lock " : "unlock ";
645         doVCCommand("svn "+ arg + quoteName(onlyFilename(owner_->absFileName()))
646                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
647                     FileName(owner_->filePath()));
648
649         // Lock error messages go unfortunately on stderr and are unreachible this way.
650         ifstream ifs(tmpf.toFilesystemEncoding().c_str());
651         string line;
652         while (ifs) {
653                 getline(ifs, line);
654                 if (!line.empty()) status += line + "; ";
655         }
656         ifs.close();
657
658         if (!isLocked() && lock)
659                 frontend::Alert::error(_("Revision control error."),
660                         _("Error when acquiring write lock.\n"
661                         "Most probably another user is editing\n"
662                         "the current document now!\n"
663                         "Also check the access to the repository."));
664         if (isLocked() && !lock)
665                 frontend::Alert::error(_("Revision control error."),
666                         _("Error when releasing write lock.\n"
667                         "Check the access to the repository."));
668 }
669
670
671 string SVN::checkOut()
672 {
673         FileName tmpf = FileName::tempName("lyxvcout");
674         if (tmpf.empty()) {
675                 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
676                 return N_("Error: Could not generate logfile.");
677         }
678
679         doVCCommand("svn update " + quoteName(onlyFilename(owner_->absFileName()))
680                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
681                     FileName(owner_->filePath()));
682
683         string log;
684         string res = scanLogFile(tmpf, log);
685         if (!res.empty())
686                 frontend::Alert::error(_("Revision control error."),
687                         bformat(_("Error when updating from repository.\n"
688                                 "You have to manually resolve the conflicts NOW!\n'%1$s'.\n\n"
689                                 "After pressing OK, LyX will try to reopen resolved document."),
690                         from_local8bit(res)));
691
692         fileLock(true, tmpf, log);
693
694         tmpf.erase();
695         return "SVN: " + log;
696 }
697
698
699 bool SVN::checkOutEnabled()
700 {
701         if (locked_mode_)
702                 return !isLocked();
703         else
704                 return true;
705 }
706
707
708 string SVN::repoUpdate()
709 {
710         FileName tmpf = FileName::tempName("lyxvcout");
711         if (tmpf.empty()) {
712                 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
713                 return N_("Error: Could not generate logfile.");
714         }
715
716         doVCCommand("svn diff " + quoteName(owner_->filePath())
717         + " > " + quoteName(tmpf.toFilesystemEncoding()),
718         FileName(owner_->filePath()));
719         docstring res = tmpf.fileContents("UTF-8");
720         if (!res.empty()) {
721                 LYXERR(Debug::LYXVC, "Diff detected:\n" << res);
722                 docstring const file = from_utf8(owner_->filePath());
723                 docstring text = bformat(_("There were detected changes "
724                                 "in the working directory:\n%1$s\n\n"
725                                 "In case of file conflict version of the local directory files "
726                                 "will be preferred."
727                                 "\n\nContinue?"), file);
728                 int const ret = frontend::Alert::prompt(_("Changes detected"),
729                                 text, 0, 1, _("&Yes"), _("&No"));
730                 if (ret) {
731                         tmpf.erase();
732                         return string();
733                 }
734         }
735
736         // Reverting looks too harsh, see bug #6255.
737         // doVCCommand("svn revert -R " + quoteName(owner_->filePath())
738         // + " > " + quoteName(tmpf.toFilesystemEncoding()),
739         // FileName(owner_->filePath()));
740         // res = "Revert log:\n" + tmpf.fileContents("UTF-8");
741         doVCCommand("svn update --accept mine-full " + quoteName(owner_->filePath())
742         + " > " + quoteName(tmpf.toFilesystemEncoding()),
743         FileName(owner_->filePath()));
744         res += "Update log:\n" + tmpf.fileContents("UTF-8");
745
746         LYXERR(Debug::LYXVC, res);
747         tmpf.erase();
748         return to_utf8(res);
749 }
750
751
752 bool SVN::repoUpdateEnabled()
753 {
754         return true;
755 }
756
757
758 string SVN::lockingToggle()
759 {
760         FileName tmpf = FileName::tempName("lyxvcout");
761         if (tmpf.empty()) {
762                 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
763                 return N_("Error: Could not generate logfile.");
764         }
765
766         int ret = doVCCommand("svn proplist " + quoteName(onlyFilename(owner_->absFileName()))
767                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
768                     FileName(owner_->filePath()));
769         if (ret)
770                 return string();
771
772         string log;
773         string res = scanLogFile(tmpf, log);
774         bool locking = contains(res, "svn:needs-lock");
775         if (!locking)
776                 ret = doVCCommand("svn propset svn:needs-lock ON "
777                     + quoteName(onlyFilename(owner_->absFileName()))
778                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
779                     FileName(owner_->filePath()));
780         else
781                 ret = doVCCommand("svn propdel svn:needs-lock "
782                     + quoteName(onlyFilename(owner_->absFileName()))
783                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
784                     FileName(owner_->filePath()));
785         if (ret)
786                 return string();
787
788         tmpf.erase();
789         frontend::Alert::warning(_("VCN File Locking"),
790                 (locking ? _("Locking property unset.") : _("Locking property set.")) + "\n"
791                 + _("Do not forget to commit the locking property into the repository."),
792                 true);
793
794         return string("SVN: ") +  N_("Locking property set.");
795 }
796
797
798 bool SVN::lockingToggleEnabled()
799 {
800         return true;
801 }
802
803
804 void SVN::revert()
805 {
806         // Reverts to the version in CVS repository and
807         // gets the updated version from the repository.
808         string const fil = quoteName(onlyFilename(owner_->absFileName()));
809
810         doVCCommand("svn revert -q " + fil,
811                     FileName(owner_->filePath()));
812         owner_->markClean();
813 }
814
815
816 void SVN::undoLast()
817 {
818         // merge the current with the previous version
819         // in a reverse patch kind of way, so that the
820         // result is to revert the last changes.
821         lyxerr << "Sorry, not implemented." << endl;
822 }
823
824
825 bool SVN::undoLastEnabled()
826 {
827         return false;
828 }
829
830
831 void SVN::getLog(FileName const & tmpf)
832 {
833         doVCCommand("svn log " + quoteName(onlyFilename(owner_->absFileName()))
834                     + " > " + quoteName(tmpf.toFilesystemEncoding()),
835                     FileName(owner_->filePath()));
836 }
837
838
839 bool SVN::toggleReadOnlyEnabled()
840 {
841         return false;
842 }
843
844
845 } // namespace lyx