diff options
author | Xavier Besseron <xavier.besseron@uni.lu> | 2012-09-03 09:03:43 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-09-04 12:35:36 (GMT) |
commit | 3776690e62c631edd520f566b2ebcaffbad230b4 (patch) | |
tree | 09d368e0a5656331ce1c29ca05fa3bf155c88606 | |
parent | 41f0f83542ce8d69e4d9a4512a6dc66327f20c8d (diff) | |
download | CMake-3776690e62c631edd520f566b2ebcaffbad230b4.zip CMake-3776690e62c631edd520f566b2ebcaffbad230b4.tar.gz CMake-3776690e62c631edd520f566b2ebcaffbad230b4.tar.bz2 |
cmCTestSVN: Add a LoadExternal() function and an ExternalParser class
This call 'svn status' and parse the result to get the list of externals
repositories. The external repositories found are added to the
Repositories list.
-rw-r--r-- | Source/CTest/cmCTestSVN.cxx | 50 | ||||
-rw-r--r-- | Source/CTest/cmCTestSVN.h | 3 |
2 files changed, 53 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 32b1ef9..b27c633 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -482,6 +482,56 @@ void cmCTestSVN::WriteXMLGlobal(std::ostream& xml) } //---------------------------------------------------------------------------- +class cmCTestSVN::ExternalParser: public cmCTestVC::LineParser +{ +public: + ExternalParser(cmCTestSVN* svn, const char* prefix): SVN(svn) + { + this->SetLog(&svn->Log, prefix); + this->RegexExternal.compile("^X..... +(.+)$"); + } +private: + cmCTestSVN* SVN; + cmsys::RegularExpression RegexExternal; + bool ProcessLine() + { + if(this->RegexExternal.find(this->Line)) + { + this->DoPath(this->RegexExternal.match(1)); + } + return true; + } + + void DoPath(std::string const& path) + { + // Get local path relative to the source directory + std::string local_path; + if(path.size() > this->SVN->SourceDirectory.size() && + strncmp(path.c_str(), this->SVN->SourceDirectory.c_str(), + this->SVN->SourceDirectory.size()) == 0) + { + local_path = path.c_str() + this->SVN->SourceDirectory.size() + 1; + } + else + { + local_path = path; + } + this->SVN->Repositories.push_back( SVNInfo(local_path.c_str()) ); + } +}; + +//---------------------------------------------------------------------------- +void cmCTestSVN::LoadExternals() +{ + // Run "svn status" to get the list of external repositories + const char* svn = this->CommandLineTool.c_str(); + const char* svn_status[] = {svn, "status", 0}; + ExternalParser out(this, "external-out> "); + OutputLogger err(this->Log, "external-err> "); + this->RunChild(svn_status, &out, &err); +} + +//---------------------------------------------------------------------------- std::string cmCTestSVN::SVNInfo::BuildLocalPath(std::string const& path) const { std::string local_path; diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h index 4fb37a6..56265d0 100644 --- a/Source/CTest/cmCTestSVN.h +++ b/Source/CTest/cmCTestSVN.h @@ -68,6 +68,7 @@ private: SVNInfo* RootInfo; std::string LoadInfo(SVNInfo& svninfo); + void LoadExternals(); void LoadModifications(); void LoadRevisions(); void LoadRevisions(SVNInfo& svninfo); @@ -84,10 +85,12 @@ private: class LogParser; class StatusParser; class UpdateParser; + class ExternalParser; friend class InfoParser; friend class LogParser; friend class StatusParser; friend class UpdateParser; + friend class ExternalParser; }; #endif |