X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXVC.cpp;h=806d5e81436790e8bc6ed4b949fb9e68e5353443;hb=801d7dc9f42baf331642606a6641606779985439;hp=2dd5ac154cc83cd21f1cf23e8f1b1e9b921217cd;hpb=2f9ef2b98a6170d4c890ce3325ddc3ad9105bbad;p=lyx.git diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index 2dd5ac154c..806d5e8143 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -25,6 +25,7 @@ #include "support/filetools.h" #include "support/gettext.h" #include "support/lstrings.h" +#include "support/TempFile.h" using namespace std; using namespace lyx::support; @@ -36,13 +37,19 @@ namespace Alert = frontend::Alert; LyXVC::LyXVC() { - owner_ = 0; + owner_ = nullptr; } -// for the sake of boost::scoped_ptr -LyXVC::~LyXVC() -{} +docstring LyXVC::vcstatus() const +{ + if (!vcs) + return docstring(); + if (locking()) + return bformat(_("%1$s lock"), from_ascii(vcs->vcname())); + else + return from_ascii(vcs->vcname()); +} bool LyXVC::fileInVC(FileName const & fn) @@ -84,7 +91,7 @@ bool LyXVC::file_found_hook(FileName const & fn) } // file is not under any VCS. - vcs.reset(0); + vcs.reset(nullptr); return false; } @@ -179,7 +186,7 @@ bool LyXVC::registrer() _("(no initial description)")); if (!ok) { LYXERR(Debug::LYXVC, "LyXVC: user cancelled"); - vcs.reset(0); + vcs.reset(nullptr); return false; } if (response.empty()) @@ -255,7 +262,7 @@ string LyXVC::checkOut() if (!vcs) return string(); //RCS allows checkOut only in ReadOnly mode - if (vcs->toggleReadOnlyEnabled() && !owner_->isReadonly()) + if (vcs->toggleReadOnlyEnabled() && !owner_->hasReadonlyFlag()) return string(); LYXERR(Debug::LYXVC, "LyXVC: checkOut"); @@ -322,13 +329,18 @@ string LyXVC::toggleReadOnly() case VCS::LOCKED: { LYXERR(Debug::LYXVC, "LyXVC: toggle to unlocked"); string log; - if (checkIn(log) != Success) + if (checkIn(log) != VCSuccess) return string(); return log; } case VCS::NOLOCKING: - case VCS::UNVERSIONED: - break; + Buffer * b = vcs->owner(); + bool const newstate = !b->hasReadonlyFlag(); + string result = "LyXVC: toggle to "; + result += (newstate ? "readonly" : "readwrite"); + LYXERR(Debug::LYXVC, result); + b->setReadonly(newstate); + return result; } return string(); } @@ -337,7 +349,7 @@ string LyXVC::toggleReadOnly() bool LyXVC::inUse() const { if (vcs) - return vcs->status() != VCS::UNVERSIONED; + return true; return false; } @@ -363,7 +375,9 @@ string const LyXVC::getLogFile() const if (!vcs) return string(); - FileName const tmpf = FileName::tempName("lyxvclog"); + TempFile tempfile("lyxvclog"); + tempfile.setAutoRemove(false); + FileName const tmpf = tempfile.name(); if (tmpf.empty()) { LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf); return string(); @@ -433,8 +447,8 @@ bool LyXVC::repoUpdateEnabled() const { return vcs && vcs->repoUpdateEnabled(); } - - + + bool LyXVC::prepareFileRevision(string const & rev, std::string & f) { return vcs && vcs->prepareFileRevision(rev, f);