- // Check if file is under RCS
- if (!RCS::find_file(fn).empty())
- return true;
- if (!CVS::find_file(fn).empty())
- return true;
+ // Check if file is under RCS.
+ // This happens if we are trying to load non existent
+ // file on disk, but existent in ,v version.
+ bool foundRCS = !RCS::findFile(fn).empty();
+ bool foundCVS = foundRCS ? false : !CVS::findFile(fn).empty();
+ bool foundSVN = (foundRCS || foundCVS) ? false : !SVN::findFile(fn).empty();
+ if (foundRCS || foundCVS || foundSVN) {
+ 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) {
+ // Since the retrieve commands are implemented using
+ // more general update commands we need to ensure that
+ // we do not change an existing file by accident.
+ if (fn.exists())
+ return false;
+ if (foundRCS)
+ return RCS::retrieve(fn);
+ else if (foundCVS)
+ return CVS::retrieve(fn);
+ else
+ return SVN::retrieve(fn);
+ }
+ }