]> git.lyx.org Git - features.git/commitdiff
Move some code from Buffer::loadLyXFile to LyXVC::file_not_found_hook. Accoring to...
authorVincent van Ravesteijn <vfr@lyx.org>
Fri, 8 Jan 2010 18:48:36 +0000 (18:48 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Fri, 8 Jan 2010 18:48:36 +0000 (18:48 +0000)
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

src/Buffer.cpp
src/LyXVC.cpp

index b3e0864c7454b196af5de0ebc51bfc0f9fe4b0a3..807803cc93ae531dd2792efc8b620954e4063250 100644 (file)
@@ -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;
 }
 
index e55f0c6c6c482094047abf8c761ccc76a10110b6..4ead9126f535088d93afa4190db9c937036b93cb 100644 (file)
@@ -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;
 }