diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 14:34:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 20:05:19 (GMT) |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/CTest/cmCTestSVN.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | CMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2 |
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.
* If you reached this commit for a line in `git blame`, re-run the blame
operation starting at the parent of this commit to see older history
for the content.
* See the parent commit for instructions to rebase a change across this
style transition commit.
Diffstat (limited to 'Source/CTest/cmCTestSVN.cxx')
-rw-r--r-- | Source/CTest/cmCTestSVN.cxx | 383 |
1 files changed, 173 insertions, 210 deletions
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 507ec29..a6885aa 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -18,13 +18,13 @@ #include <cmsys/RegularExpression.hxx> -struct cmCTestSVN::Revision: public cmCTestVC::Revision +struct cmCTestSVN::Revision : public cmCTestVC::Revision { cmCTestSVN::SVNInfo* SVNInfo; }; -cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log): - cmCTestGlobalVC(ct, log) +cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log) + : cmCTestGlobalVC(ct, log) { this->PriorRev = this->Unknown; } @@ -42,20 +42,20 @@ void cmCTestSVN::CleanupImpl() this->RunSVNCommand(svn_cleanup, &out, &err); } -class cmCTestSVN::InfoParser: public cmCTestVC::LineParser +class cmCTestSVN::InfoParser : public cmCTestVC::LineParser { public: - InfoParser(cmCTestSVN* svn, - const char* prefix, - std::string& rev, - SVNInfo& svninfo): - Rev(rev), SVNRepo(svninfo) - { + InfoParser(cmCTestSVN* svn, const char* prefix, std::string& rev, + SVNInfo& svninfo) + : Rev(rev) + , SVNRepo(svninfo) + { this->SetLog(&svn->Log, prefix); this->RegexRev.compile("^Revision: ([0-9]+)"); this->RegexURL.compile("^URL: +([^ ]+) *$"); this->RegexRoot.compile("^Repository Root: +([^ ]+) *$"); - } + } + private: std::string& Rev; cmCTestSVN::SVNInfo& SVNRepo; @@ -63,38 +63,28 @@ private: cmsys::RegularExpression RegexURL; cmsys::RegularExpression RegexRoot; virtual bool ProcessLine() - { - if(this->RegexRev.find(this->Line)) - { + { + if (this->RegexRev.find(this->Line)) { this->Rev = this->RegexRev.match(1); - } - else if(this->RegexURL.find(this->Line)) - { + } else if (this->RegexURL.find(this->Line)) { this->SVNRepo.URL = this->RegexURL.match(1); - } - else if(this->RegexRoot.find(this->Line)) - { + } else if (this->RegexRoot.find(this->Line)) { this->SVNRepo.Root = this->RegexRoot.match(1); - } - return true; } + return true; + } }; static bool cmCTestSVNPathStarts(std::string const& p1, std::string const& p2) { // Does path p1 start with path p2? - if(p1.size() == p2.size()) - { + if (p1.size() == p2.size()) { return p1 == p2; - } - else if(p1.size() > p2.size() && p1[p2.size()] == '/') - { + } else if (p1.size() > p2.size() && p1[p2.size()] == '/') { return strncmp(p1.c_str(), p2.c_str(), p2.size()) == 0; - } - else - { + } else { return false; - } + } } std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo) @@ -113,7 +103,7 @@ std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo) void cmCTestSVN::NoteOldRevision() { // Info for root repository - this->Repositories.push_back( SVNInfo("") ); + this->Repositories.push_back(SVNInfo("")); this->RootInfo = &(this->Repositories.back()); // Info for the external repositories this->LoadExternals(); @@ -121,17 +111,15 @@ void cmCTestSVN::NoteOldRevision() // Get info for all the repositories std::list<SVNInfo>::iterator itbeg = this->Repositories.begin(); std::list<SVNInfo>::iterator itend = this->Repositories.end(); - for( ; itbeg != itend ; itbeg++) - { + for (; itbeg != itend; itbeg++) { SVNInfo& svninfo = *itbeg; svninfo.OldRevision = this->LoadInfo(svninfo); this->Log << "Revision for repository '" << svninfo.LocalPath << "' before update: " << svninfo.OldRevision << "\n"; - cmCTestLog(this->CTest, HANDLER_OUTPUT, - " Old revision of external repository '" - << svninfo.LocalPath << "' is: " - << svninfo.OldRevision << "\n"); - } + cmCTestLog( + this->CTest, HANDLER_OUTPUT, " Old revision of external repository '" + << svninfo.LocalPath << "' is: " << svninfo.OldRevision << "\n"); + } // Set the global old revision to the one of the root this->OldRevision = this->RootInfo->OldRevision; @@ -143,16 +131,14 @@ void cmCTestSVN::NoteNewRevision() // Get info for the external repositories std::list<SVNInfo>::iterator itbeg = this->Repositories.begin(); std::list<SVNInfo>::iterator itend = this->Repositories.end(); - for( ; itbeg != itend ; itbeg++) - { + for (; itbeg != itend; itbeg++) { SVNInfo& svninfo = *itbeg; svninfo.NewRevision = this->LoadInfo(svninfo); this->Log << "Revision for repository '" << svninfo.LocalPath << "' after update: " << svninfo.NewRevision << "\n"; - cmCTestLog(this->CTest, HANDLER_OUTPUT, - " New revision of external repository '" - << svninfo.LocalPath << "' is: " - << svninfo.NewRevision << "\n"); + cmCTestLog( + this->CTest, HANDLER_OUTPUT, " New revision of external repository '" + << svninfo.LocalPath << "' is: " << svninfo.NewRevision << "\n"); // svninfo.Root = ""; // uncomment to test GuessBase this->Log << "Repository '" << svninfo.LocalPath @@ -162,16 +148,14 @@ void cmCTestSVN::NoteNewRevision() // Compute the base path the working tree has checked out under // the repository root. - if(!svninfo.Root.empty() - && cmCTestSVNPathStarts(svninfo.URL, svninfo.Root)) - { - svninfo.Base = cmCTest::DecodeURL( - svninfo.URL.substr(svninfo.Root.size())); + if (!svninfo.Root.empty() && + cmCTestSVNPathStarts(svninfo.URL, svninfo.Root)) { + svninfo.Base = + cmCTest::DecodeURL(svninfo.URL.substr(svninfo.Root.size())); svninfo.Base += "/"; - } + } this->Log << "Repository '" << svninfo.LocalPath << "' Base = " << svninfo.Base << "\n"; - } // Set the global new revision to the one of the root @@ -186,21 +170,18 @@ void cmCTestSVN::GuessBase(SVNInfo& svninfo, // changes under it. // Consider each possible URL suffix from longest to shortest. - for(std::string::size_type slash = svninfo.URL.find('/'); - svninfo.Base.empty() && slash != std::string::npos; - slash = svninfo.URL.find('/', slash+1)) - { + for (std::string::size_type slash = svninfo.URL.find('/'); + svninfo.Base.empty() && slash != std::string::npos; + slash = svninfo.URL.find('/', slash + 1)) { // If the URL suffix is a prefix of at least one path then it is the base. std::string base = cmCTest::DecodeURL(svninfo.URL.substr(slash)); - for(std::vector<Change>::const_iterator ci = changes.begin(); - svninfo.Base.empty() && ci != changes.end(); ++ci) - { - if(cmCTestSVNPathStarts(ci->Path, base)) - { + for (std::vector<Change>::const_iterator ci = changes.begin(); + svninfo.Base.empty() && ci != changes.end(); ++ci) { + if (cmCTestSVNPathStarts(ci->Path, base)) { svninfo.Base = base; - } } } + } // We always append a slash so that we know paths beginning in the // base lie under its path. If no base was found then the working @@ -211,76 +192,76 @@ void cmCTestSVN::GuessBase(SVNInfo& svninfo, this->Log << "Guessed Base = " << svninfo.Base << "\n"; } -class cmCTestSVN::UpdateParser: public cmCTestVC::LineParser +class cmCTestSVN::UpdateParser : public cmCTestVC::LineParser { public: - UpdateParser(cmCTestSVN* svn, const char* prefix): SVN(svn) - { + UpdateParser(cmCTestSVN* svn, const char* prefix) + : SVN(svn) + { this->SetLog(&svn->Log, prefix); this->RegexUpdate.compile("^([ADUCGE ])([ADUCGE ])[B ] +(.+)$"); - } + } + private: cmCTestSVN* SVN; cmsys::RegularExpression RegexUpdate; bool ProcessLine() - { - if(this->RegexUpdate.find(this->Line)) - { + { + if (this->RegexUpdate.find(this->Line)) { this->DoPath(this->RegexUpdate.match(1)[0], - this->RegexUpdate.match(2)[0], - this->RegexUpdate.match(3)); - } - return true; + this->RegexUpdate.match(2)[0], this->RegexUpdate.match(3)); } + return true; + } void DoPath(char path_status, char prop_status, std::string const& path) - { - char status = (path_status != ' ')? path_status : prop_status; + { + char status = (path_status != ' ') ? path_status : prop_status; std::string dir = cmSystemTools::GetFilenamePath(path); std::string name = cmSystemTools::GetFilenameName(path); // See "svn help update". - switch(status) - { + switch (status) { case 'G': this->SVN->Dirs[dir][name].Status = PathModified; break; case 'C': this->SVN->Dirs[dir][name].Status = PathConflicting; break; - case 'A': case 'D': case 'U': + case 'A': + case 'D': + case 'U': this->SVN->Dirs[dir][name].Status = PathUpdated; break; case 'E': // TODO? - case '?': case ' ': default: + case '?': + case ' ': + default: break; - } } + } }; bool cmCTestSVN::UpdateImpl() { // Get user-specified update options. std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions"); - if(opts.empty()) - { + if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions"); - } + } std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); // Specify the start time for nightly testing. - if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) - { + if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { args.push_back("-r{" + this->GetNightlyTime() + " +0000}"); - } + } std::vector<char const*> svn_update; svn_update.push_back("update"); - for(std::vector<std::string>::const_iterator ai = args.begin(); - ai != args.end(); ++ai) - { + for (std::vector<std::string>::const_iterator ai = args.begin(); + ai != args.end(); ++ai) { svn_update.push_back(ai->c_str()); - } + } UpdateParser out(this, "up-out> "); OutputLogger err(this->Log, "up-err> "); @@ -288,9 +269,10 @@ bool cmCTestSVN::UpdateImpl() } bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, - OutputParser* out, OutputParser* err) + OutputParser* out, OutputParser* err) { - if(parameters.empty()) return false; + if (parameters.empty()) + return false; std::vector<char const*> args; args.push_back(this->CommandLineTool.c_str()); @@ -299,36 +281,35 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, args.push_back("--non-interactive"); - std::string userOptions = - this->CTest->GetCTestConfiguration("SVNOptions"); + std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions"); std::vector<std::string> parsedUserOptions = cmSystemTools::ParseArguments(userOptions.c_str()); - for(std::vector<std::string>::iterator i = parsedUserOptions.begin(); - i != parsedUserOptions.end(); ++i) - { + for (std::vector<std::string>::iterator i = parsedUserOptions.begin(); + i != parsedUserOptions.end(); ++i) { args.push_back(i->c_str()); - } + } args.push_back(0); - if(strcmp(parameters[0], "update") == 0) - { + if (strcmp(parameters[0], "update") == 0) { return RunUpdateCommand(&args[0], out, err); - } - else - { + } else { return RunChild(&args[0], out, err); - } + } } -class cmCTestSVN::LogParser: public cmCTestVC::OutputLogger, - private cmXMLParser +class cmCTestSVN::LogParser : public cmCTestVC::OutputLogger, + private cmXMLParser { public: - LogParser(cmCTestSVN* svn, const char* prefix, SVNInfo& svninfo): - OutputLogger(svn->Log, prefix), SVN(svn), SVNRepo(svninfo) - { this->InitializeParser(); } + LogParser(cmCTestSVN* svn, const char* prefix, SVNInfo& svninfo) + : OutputLogger(svn->Log, prefix) + , SVN(svn) + , SVNRepo(svninfo) + { + this->InitializeParser(); + } ~LogParser() { this->CleanupParser(); } private: cmCTestSVN* SVN; @@ -342,72 +323,58 @@ private: std::vector<char> CData; virtual bool ProcessChunk(const char* data, int length) - { + { this->OutputLogger::ProcessChunk(data, length); this->ParseChunk(data, length); return true; - } + } virtual void StartElement(const std::string& name, const char** atts) - { + { this->CData.clear(); - if(name == "logentry") - { + if (name == "logentry") { this->Rev = Revision(); this->Rev.SVNInfo = &SVNRepo; - if(const char* rev = this->FindAttribute(atts, "revision")) - { + if (const char* rev = this->FindAttribute(atts, "revision")) { this->Rev.Rev = rev; - } - this->Changes.clear(); } - else if(name == "path") - { + this->Changes.clear(); + } else if (name == "path") { this->CurChange = Change(); - if(const char* action = this->FindAttribute(atts, "action")) - { + if (const char* action = this->FindAttribute(atts, "action")) { this->CurChange.Action = action[0]; - } } } + } virtual void CharacterDataHandler(const char* data, int length) - { - this->CData.insert(this->CData.end(), data, data+length); - } + { + this->CData.insert(this->CData.end(), data, data + length); + } virtual void EndElement(const std::string& name) - { - if(name == "logentry") - { + { + if (name == "logentry") { this->SVN->DoRevisionSVN(this->Rev, this->Changes); - } - else if(!this->CData.empty() && name == "path") - { + } else if (!this->CData.empty() && name == "path") { std::string orig_path(&this->CData[0], this->CData.size()); - std::string new_path = SVNRepo.BuildLocalPath( orig_path ); + std::string new_path = SVNRepo.BuildLocalPath(orig_path); this->CurChange.Path.assign(new_path); this->Changes.push_back(this->CurChange); - } - else if(!this->CData.empty() && name == "author") - { + } else if (!this->CData.empty() && name == "author") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); - } - else if(!this->CData.empty() && name == "date") - { + } else if (!this->CData.empty() && name == "date") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); - } - else if(!this->CData.empty() && name == "msg") - { + } else if (!this->CData.empty() && name == "msg") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); - } - this->CData.clear(); } + this->CData.clear(); + } virtual void ReportError(int, int, const char* msg) - { + { this->SVN->Log << "Error parsing svn log xml: " << msg << "\n"; - } + } }; void cmCTestSVN::LoadRevisions() @@ -415,25 +382,21 @@ void cmCTestSVN::LoadRevisions() // Get revisions for all the external repositories std::list<SVNInfo>::iterator itbeg = this->Repositories.begin(); std::list<SVNInfo>::iterator itend = this->Repositories.end(); - for( ; itbeg != itend ; itbeg++) - { + for (; itbeg != itend; itbeg++) { SVNInfo& svninfo = *itbeg; LoadRevisions(svninfo); - } + } } -void cmCTestSVN::LoadRevisions(SVNInfo &svninfo) +void cmCTestSVN::LoadRevisions(SVNInfo& svninfo) { // We are interested in every revision included in the update. std::string revs; - if(atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str())) - { + if (atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str())) { revs = "-r" + svninfo.OldRevision + ":" + svninfo.NewRevision; - } - else - { + } else { revs = "-r" + svninfo.NewRevision; - } + } // Run "svn log" to get all global revisions of interest. std::vector<const char*> svn_log; @@ -451,59 +414,65 @@ void cmCTestSVN::DoRevisionSVN(Revision const& revision, std::vector<Change> const& changes) { // Guess the base checkout path from the changes if necessary. - if(this->RootInfo->Base.empty() && !changes.empty()) - { + if (this->RootInfo->Base.empty() && !changes.empty()) { this->GuessBase(*this->RootInfo, changes); - } + } // Ignore changes in the old revision for external repositories - if(revision.Rev == revision.SVNInfo->OldRevision - && revision.SVNInfo->LocalPath != "") - { + if (revision.Rev == revision.SVNInfo->OldRevision && + revision.SVNInfo->LocalPath != "") { return; - } + } this->cmCTestGlobalVC::DoRevision(revision, changes); } -class cmCTestSVN::StatusParser: public cmCTestVC::LineParser +class cmCTestSVN::StatusParser : public cmCTestVC::LineParser { public: - StatusParser(cmCTestSVN* svn, const char* prefix): SVN(svn) - { + StatusParser(cmCTestSVN* svn, const char* prefix) + : SVN(svn) + { this->SetLog(&svn->Log, prefix); this->RegexStatus.compile("^([ACDIMRX?!~ ])([CM ])[ L]... +(.+)$"); - } + } + private: cmCTestSVN* SVN; cmsys::RegularExpression RegexStatus; bool ProcessLine() - { - if(this->RegexStatus.find(this->Line)) - { + { + if (this->RegexStatus.find(this->Line)) { this->DoPath(this->RegexStatus.match(1)[0], - this->RegexStatus.match(2)[0], - this->RegexStatus.match(3)); - } - return true; + this->RegexStatus.match(2)[0], this->RegexStatus.match(3)); } + return true; + } void DoPath(char path_status, char prop_status, std::string const& path) - { - char status = (path_status != ' ')? path_status : prop_status; + { + char status = (path_status != ' ') ? path_status : prop_status; // See "svn help status". - switch(status) - { - case 'M': case '!': case 'A': case 'D': case 'R': + switch (status) { + case 'M': + case '!': + case 'A': + case 'D': + case 'R': this->SVN->DoModification(PathModified, path); break; - case 'C': case '~': + case 'C': + case '~': this->SVN->DoModification(PathConflicting, path); break; - case 'X': case 'I': case '?': case ' ': default: + case 'X': + case 'I': + case '?': + case ' ': + default: break; - } } + } }; void cmCTestSVN::LoadModifications() @@ -523,42 +492,40 @@ void cmCTestSVN::WriteXMLGlobal(cmXMLWriter& xml) xml.Element("SVNPath", this->RootInfo->Base); } -class cmCTestSVN::ExternalParser: public cmCTestVC::LineParser +class cmCTestSVN::ExternalParser : public cmCTestVC::LineParser { public: - ExternalParser(cmCTestSVN* svn, const char* prefix): SVN(svn) - { + 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)) - { + { + if (this->RegexExternal.find(this->Line)) { this->DoPath(this->RegexExternal.match(1)); - } - return true; } + 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) - { + 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 - { + } else { local_path = path; - } - this->SVN->Repositories.push_back( SVNInfo(local_path.c_str()) ); } + this->SVN->Repositories.push_back(SVNInfo(local_path.c_str())); + } }; void cmCTestSVN::LoadExternals() @@ -576,20 +543,16 @@ std::string cmCTestSVN::SVNInfo::BuildLocalPath(std::string const& path) const std::string local_path; // Add local path prefix if not empty - if (!this->LocalPath.empty()) - { + if (!this->LocalPath.empty()) { local_path += this->LocalPath; local_path += "/"; - } + } // Add path with base prefix removed - if(path.size() > this->Base.size() && - strncmp(path.c_str(), this->Base.c_str(), this->Base.size()) == 0) - { + if (path.size() > this->Base.size() && + strncmp(path.c_str(), this->Base.c_str(), this->Base.size()) == 0) { local_path += (path.c_str() + this->Base.size()); - } - else - { + } else { local_path += path; } |