- // Check if file is under RCS.
- // This happens if we are trying to load non existent
- // 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;
+ // Check if file is under version control.
+ // This happens if we are trying to load file that does not exist.
+ // It may yet exist in the repository and so could be checked out.
+ bool foundRCS = !RCS::findFile(fn).empty();
+ bool foundCVS = foundRCS ? false : !CVS::findFile(fn).empty();
+ bool foundSVN = (foundRCS || foundCVS) ? false : SVN::findFile(fn);
+ bool foundGIT = (foundRCS || foundCVS || foundSVN) ? false : GIT::findFile(fn);
+ if (foundRCS || foundCVS || foundSVN || foundGIT) {
+ 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 if (foundSVN)
+ return SVN::retrieve(fn);
+ else
+ return GIT::retrieve(fn);
+ }
+ }