mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
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
This commit is contained in:
parent
67ddc3944c
commit
e0a6a7a542
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user