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