From: Vincent van Ravesteijn Date: Fri, 8 Jan 2010 18:48:36 +0000 (+0000) Subject: Move some code from Buffer::loadLyXFile to LyXVC::file_not_found_hook. Accoring to... X-Git-Tag: 2.0.0~4491 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e0a6a7a542b97af5700b919a68ce6a3b317906f8;p=features.git Move some code from Buffer::loadLyXFile to LyXVC::file_not_found_hook. Accoring to the description of the latter, this should already be the case. Furthermore, make sure that the read-only flag is always set to both true and false, since now the buffer can be read-only during a reload. Last, set the buffer clean after a successful reload. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32896 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b3e0864c74..807803cc93 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -3399,31 +3399,17 @@ bool Buffer::readFileHelper(FileName const & s) bool Buffer::loadLyXFile(FileName const & s) { - if (s.isReadableFile()) { - if (readFileHelper(s)) { - lyxvc().file_found_hook(s); - if (!s.isWritable()) - setReadonly(true); - return true; - } - } else { - docstring const file = makeDisplayPath(s.absFilename(), 20); - // Here we probably should run - if (LyXVC::file_not_found_hook(s)) { - docstring const text = - bformat(_("Do you want to retrieve the document" - " %1$s from version control?"), file); - int const ret = Alert::prompt(_("Retrieve from version control?"), - text, 0, 1, _("&Retrieve"), _("&Cancel")); - - if (ret == 0) { - // How can we know _how_ to do the checkout? - // With the current VC support it has to be, - // a RCS file since CVS do not have special ,v files. - RCS::retrieve(s); - return loadLyXFile(s); - } - } + // If the file is not readable, we try to + // retrieve the file from version control. + if (!s.isReadableFile() + && !LyXVC::file_not_found_hook(s)) + return false; + + if (s.isReadableFile() + && readFileHelper(s)) { + lyxvc().file_found_hook(s); + setReadonly(!s.isWritable()); + return true; } return false; } @@ -3790,12 +3776,13 @@ bool Buffer::reload() if (success) { updateLabels(); changed(true); - errors("Parse"); + markClean(); message(bformat(_("Document %1$s reloaded."), disp_fn)); } else { message(bformat(_("Could not reload document %1$s."), disp_fn)); } setBusy(false); + errors("Parse"); return success; } diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index e55f0c6c6c..4ead9126f5 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -79,8 +79,22 @@ bool LyXVC::file_not_found_hook(FileName const & fn) // file on disk, but existent in ,v version. // Seems there is no reasonable scenario for adding implementation // of retrieve for cvs or svn. - if (!RCS::findFile(fn).empty()) - return true; + if (!RCS::findFile(fn).empty()) { + docstring const file = makeDisplayPath(fn.absFilename(), 20); + docstring const text = + bformat(_("Do you want to retrieve the document" + " %1$s from version control?"), file); + int const ret = Alert::prompt(_("Retrieve from version control?"), + text, 0, 1, _("&Retrieve"), _("&Cancel")); + + if (ret == 0) { + // How can we know _how_ to do the checkout? + // With the current VC support it has to be an RCS + // file since CVS and SVN do not have special ,v files. + RCS::retrieve(fn); + return true; + } + } return false; }