X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXVC.cpp;h=7e7e770b10791fc9eae0c526f1c35d1db33619e3;hb=5366666c831b6ad726e848a60d738b57ec8b0501;hp=fa4d4c8aeffb09664099b15e398093acbb1fd72d;hpb=81be2e8a9b7f4a99cdc15afa457c1fa06e81fbb0;p=lyx.git diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index fa4d4c8aef..7e7e770b10 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -58,9 +58,9 @@ bool LyXVC::fileInVC(FileName const & fn) return true; if (!CVS::findFile(fn).empty()) return true; - if (!SVN::findFile(fn).empty()) + if (SVN::findFile(fn)) return true; - if (!GIT::findFile(fn).empty()) + if (GIT::findFile(fn)) return true; return false; } @@ -80,13 +80,13 @@ bool LyXVC::file_found_hook(FileName const & fn) return true; } // Check if file is under SVN - if (!(found_file = SVN::findFile(fn)).empty()) { - vcs_.reset(new SVN(found_file, owner_)); + if (SVN::findFile(fn)) { + vcs_.reset(new SVN(owner_)); return true; } // Check if file is under GIT - if (!(found_file = GIT::findFile(fn)).empty()) { - vcs_.reset(new GIT(found_file, owner_)); + if (GIT::findFile(fn)) { + vcs_.reset(new GIT(owner_)); return true; } @@ -98,13 +98,13 @@ bool LyXVC::file_found_hook(FileName const & fn) bool LyXVC::file_not_found_hook(FileName const & fn) { - // Check if file is under RCS. - // This happens if we are trying to load non existent - // file on disk, but existent in ,v version. + // 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).empty(); - bool foundGIT = (foundRCS || foundCVS || foundSVN) ? false : !GIT::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 = @@ -153,30 +153,36 @@ bool LyXVC::registrer() // it is very likely here that the vcs is not created yet... if (!vcs_) { - //check in the root directory of the document - FileName const cvs_entries(onlyPath(filename.absFileName()) + "/CVS/Entries"); - FileName const svn_entries(onlyPath(filename.absFileName()) + "/.svn/entries"); - FileName const git_index(onlyPath(filename.absFileName()) + "/.git/index"); + FileName found = VCS::checkParentDirs(filename, ".git/index"); - if (git_index.isReadableFile()) { + if (!found.empty()) { LYXERR(Debug::LYXVC, "LyXVC: registering " << to_utf8(filename.displayName()) << " with GIT"); - vcs_.reset(new GIT(git_index, owner_)); - - } else if (svn_entries.isReadableFile()) { - LYXERR(Debug::LYXVC, "LyXVC: registering " - << to_utf8(filename.displayName()) << " with SVN"); - vcs_.reset(new SVN(svn_entries, owner_)); - - } else if (cvs_entries.isReadableFile()) { - LYXERR(Debug::LYXVC, "LyXVC: registering " - << to_utf8(filename.displayName()) << " with CVS"); - vcs_.reset(new CVS(cvs_entries, owner_)); + vcs_.reset(new GIT(owner_)); } else { - LYXERR(Debug::LYXVC, "LyXVC: registering " - << to_utf8(filename.displayName()) << " with RCS"); - vcs_.reset(new RCS(FileName(), owner_)); + found = VCS::checkParentDirs(filename, ".svn/entries"); + if (!found.empty()) { + LYXERR(Debug::LYXVC, "LyXVC: registering " + << to_utf8(filename.displayName()) << " with SVN"); + vcs_.reset(new SVN(owner_)); + + } else { + // We only need to check the current directory, since CVS meta-data + // is in every sub-directory. + FileName const cvs_entries(onlyPath(filename.absFileName()) + "/CVS/Entries"); + if (cvs_entries.isReadableFile()) { + LYXERR(Debug::LYXVC, "LyXVC: registering " + << to_utf8(filename.displayName()) << " with CVS"); + vcs_.reset(new CVS(cvs_entries, owner_)); + + } else { + // If all else fails, use RCS + LYXERR(Debug::LYXVC, "LyXVC: registering " + << to_utf8(filename.displayName()) << " with RCS"); + vcs_.reset(new RCS(FileName(), owner_)); + } + } } }