X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FVCBackend.cpp;h=957c69f585b48890ed38fdcfa1730da82f1dbf4c;hb=35f0117b5fbeee20e49e0b1e46f1ac938ae84afb;hp=f799587177d719ce57717cb8de1fa43c2aab6fbb;hpb=06cfd26d5e55a8d72e01c422f40619641ceebf90;p=lyx.git diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index f799587177..957c69f585 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -13,6 +13,7 @@ #include "VCBackend.h" #include "Buffer.h" +#include "DispatchResult.h" #include "LyX.h" #include "FuncRequest.h" @@ -30,6 +31,8 @@ #include "support/TempFile.h" #include +#include +#include using namespace std; using namespace lyx::support; @@ -43,7 +46,7 @@ int VCS::doVCCommandCall(string const & cmd, FileName const & path) LYXERR(Debug::LYXVC, "doVCCommandCall: " << cmd); Systemcall one; support::PathChanger p(path); - return one.startscript(Systemcall::Wait, cmd, string(), false); + return one.startscript(Systemcall::Wait, cmd, string(), string(), false); } @@ -58,7 +61,7 @@ int VCS::doVCCommand(string const & cmd, FileName const & path, bool reportError owner_->setBusy(false); if (ret && reportError) frontend::Alert::error(_("Revision control error."), - bformat(_("Some problem occured while running the command:\n" + bformat(_("Some problem occurred while running the command:\n" "'%1$s'."), from_utf8(cmd))); return ret; @@ -168,6 +171,8 @@ void RCS::scanMaster() LYXERR(Debug::LYXVC, "LyXVC::RCS: scanMaster: " << master_); ifstream ifs(master_.toFilesystemEncoding().c_str()); + // limit the size of strings we read to avoid memory problems + ifs >> setw(65636); string token; bool read_enough = false; @@ -282,7 +287,7 @@ LyXVC::CommandResult RCS::checkIn(string const & msg, string & log) bool RCS::checkInEnabled() { - return owner_ && !owner_->isReadonly(); + return owner_ && !owner_->hasReadonlyFlag(); } @@ -324,7 +329,7 @@ string RCS::checkOut() bool RCS::checkOutEnabled() { - return owner_ && owner_->isReadonly(); + return owner_ && owner_->hasReadonlyFlag(); } @@ -387,7 +392,7 @@ void RCS::undoLast() bool RCS::undoLastEnabled() { - return true; + return owner_->hasReadonlyFlag(); } @@ -425,7 +430,8 @@ string RCS::revisionInfo(LyXVC::RevisionInfo const info) return rev_date_cache_; case LyXVC::Time: return rev_time_cache_; - default: ; + default: + break; } return string(); @@ -494,6 +500,7 @@ bool RCS::prepareFileRevision(string const &revis, string & f) + quoteName(onlyFileName(owner_->absFileName())) + " > " + quoteName(tmpf.toFilesystemEncoding()), FileName(owner_->filePath())); + tmpf.refresh(); if (tmpf.isFileEmpty()) return false; @@ -563,8 +570,10 @@ void CVS::scanMaster() if (contains(line, tmpf)) { // Ok extract the fields. smatch sm; - - regex_match(line, sm, reg); + if (!regex_match(line, sm, reg)) { + LYXERR(Debug::LYXVC, "\t Cannot parse line. Skipping."); + continue; + } //sm[0]; // whole matched string //sm[1]; // filename @@ -1094,7 +1103,8 @@ string CVS::revisionInfo(LyXVC::RevisionInfo const info) return rev_date_cache_; case LyXVC::Time: return rev_time_cache_; - default: ; + default: + break; } } return string(); @@ -1118,6 +1128,7 @@ bool CVS::prepareFileRevision(string const & revis, string & f) doVCCommandWithOutput("cvs update -p -r" + rev + ' ' + getTarget(File), FileName(owner_->filePath()), tmpf); + tmpf.refresh(); if (tmpf.isFileEmpty()) return false; @@ -1429,7 +1440,7 @@ bool SVN::fileLock(bool lock, FileName const & tmpf, string &status) + " > " + quoteName(tmpf.toFilesystemEncoding()), FileName(owner_->filePath())); - // Lock error messages go unfortunately on stderr and are unreachible this way. + // Lock error messages go unfortunately on stderr and are unreachable this way. ifstream ifs(tmpf.toFilesystemEncoding().c_str()); string line; while (ifs) { @@ -1657,8 +1668,8 @@ string SVN::revisionInfo(LyXVC::RevisionInfo const info) return rev_date_cache_; case LyXVC::Time: return rev_time_cache_; - default: ; - + default: + break; } return string(); @@ -1783,6 +1794,7 @@ bool SVN::prepareFileRevision(string const & revis, string & f) + quoteName(onlyFileName(owner_->absFileName())) + " > " + quoteName(tmpf.toFilesystemEncoding()), FileName(owner_->filePath())); + tmpf.refresh(); if (tmpf.isFileEmpty()) return false; @@ -1842,6 +1854,7 @@ FileName const GIT::findFile(FileName const & file) quoteName(fname) + " > " + quoteName(tmpf.toFilesystemEncoding()), file.onlyPath()); + tmpf.refresh(); bool found = !tmpf.isFileEmpty(); LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : "disabled")); return found ? file : FileName(); @@ -2124,8 +2137,8 @@ string GIT::revisionInfo(LyXVC::RevisionInfo const info) return rev_date_cache_; case LyXVC::Time: return rev_time_cache_; - default: ; - + default: + break; } return string(); @@ -2232,6 +2245,7 @@ bool GIT::prepareFileRevision(string const & revis, string & f) + quoteName(onlyFileName(owner_->absFileName())) + " > " + quoteName(tmpf.toFilesystemEncoding()), FileName(owner_->filePath())); + tmpf.refresh(); if (tmpf.isFileEmpty()) return false; @@ -2248,7 +2262,7 @@ bool GIT::prepareFileRevisionEnabled() bool GIT::toggleReadOnlyEnabled() { - return false; + return true; }