diff options
author | Alexander Neundorf <neundorf@kde.org> | 2023-02-02 21:44:52 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-02-06 15:23:03 (GMT) |
commit | e7f7bff4f54f72bed6ca0dfac8a9989e8a44223c (patch) | |
tree | fd37c7069a88e8a1a0aebfe586f60258bd45cb89 /Source/cmExtraKateGenerator.cxx | |
parent | 96389b4cd3dfa2632619fee5e1a16ca872f55973 (diff) | |
download | CMake-e7f7bff4f54f72bed6ca0dfac8a9989e8a44223c.zip CMake-e7f7bff4f54f72bed6ca0dfac8a9989e8a44223c.tar.gz CMake-e7f7bff4f54f72bed6ca0dfac8a9989e8a44223c.tar.bz2 |
Kate: improve the way the VCS-specific files are searched
Before, CMake only checked for the .svn etc. directory only in
${CMAKE_SOURCE_DIR}, now it also goes the directories up to check
whether those VCS directories exist in one of the parent directories.
Diffstat (limited to 'Source/cmExtraKateGenerator.cxx')
-rw-r--r-- | Source/cmExtraKateGenerator.cxx | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 5be8f26..0d0b513 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -8,6 +8,7 @@ #include <set> #include <vector> +#include "cmCMakePath.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -241,31 +242,38 @@ std::string cmExtraKateGenerator::GenerateFilesString( return fossilString; } - std::string s; - // check for the VCS files except when "forced" to "FILES" mode: if (mode != "LIST") { - s = cmStrCat(lg.GetSourceDirectory(), "/.git"); - if (cmSystemTools::FileExists(s)) { - return gitString; - } + cmCMakePath startDir(lg.GetSourceDirectory(), cmCMakePath::auto_format); + // move the directories up to the root directory to see whether we are in + // a subdir of a svn, git, hg or fossil checkout + for (;;) { + std::string s = startDir.String() + "/.git"; + if (cmSystemTools::FileExists(s)) { + return gitString; + } - s = cmStrCat(lg.GetSourceDirectory(), "/.svn"); - if (cmSystemTools::FileExists(s)) { - return svnString; - } - s = cmStrCat(lg.GetSourceDirectory(), "/.hg"); - if (cmSystemTools::FileExists(s)) { - return hgString; - } - s = cmStrCat(lg.GetSourceDirectory(), "/.fslckout"); - if (cmSystemTools::FileExists(s)) { - return fossilString; + s = startDir.String() + "/.svn"; + if (cmSystemTools::FileExists(s)) { + return svnString; + } + + s = startDir.String() + "/.hg"; + if (cmSystemTools::FileExists(s)) { + return hgString; + } + s = startDir.String() + "/.fslckout"; + if (cmSystemTools::FileExists(s)) { + return fossilString; + } + + if (!startDir.HasRelativePath()) { // have we reached the root dir ? + break; + } + startDir = startDir.GetParentPath(); } } - s = cmStrCat(lg.GetSourceDirectory(), '/'); - std::set<std::string> files; std::string tmp; const auto& lgs = this->GlobalGenerator->GetLocalGenerators(); |