mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-25 17:44:59 +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)
|
bool Buffer::loadLyXFile(FileName const & s)
|
||||||
{
|
{
|
||||||
if (s.isReadableFile()) {
|
// If the file is not readable, we try to
|
||||||
if (readFileHelper(s)) {
|
// retrieve the file from version control.
|
||||||
lyxvc().file_found_hook(s);
|
if (!s.isReadableFile()
|
||||||
if (!s.isWritable())
|
&& !LyXVC::file_not_found_hook(s))
|
||||||
setReadonly(true);
|
return false;
|
||||||
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) {
|
if (s.isReadableFile()
|
||||||
// How can we know _how_ to do the checkout?
|
&& readFileHelper(s)) {
|
||||||
// With the current VC support it has to be,
|
lyxvc().file_found_hook(s);
|
||||||
// a RCS file since CVS do not have special ,v files.
|
setReadonly(!s.isWritable());
|
||||||
RCS::retrieve(s);
|
return true;
|
||||||
return loadLyXFile(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3790,12 +3776,13 @@ bool Buffer::reload()
|
|||||||
if (success) {
|
if (success) {
|
||||||
updateLabels();
|
updateLabels();
|
||||||
changed(true);
|
changed(true);
|
||||||
errors("Parse");
|
markClean();
|
||||||
message(bformat(_("Document %1$s reloaded."), disp_fn));
|
message(bformat(_("Document %1$s reloaded."), disp_fn));
|
||||||
} else {
|
} else {
|
||||||
message(bformat(_("Could not reload document %1$s."), disp_fn));
|
message(bformat(_("Could not reload document %1$s."), disp_fn));
|
||||||
}
|
}
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
|
errors("Parse");
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +79,22 @@ bool LyXVC::file_not_found_hook(FileName const & fn)
|
|||||||
// file on disk, but existent in ,v version.
|
// file on disk, but existent in ,v version.
|
||||||
// Seems there is no reasonable scenario for adding implementation
|
// Seems there is no reasonable scenario for adding implementation
|
||||||
// of retrieve for cvs or svn.
|
// of retrieve for cvs or svn.
|
||||||
if (!RCS::findFile(fn).empty())
|
if (!RCS::findFile(fn).empty()) {
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user