summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestHG.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/CTest/cmCTestHG.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-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/cmCTestHG.cxx')
-rw-r--r--Source/CTest/cmCTestHG.cxx228
1 files changed, 105 insertions, 123 deletions
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx
index 4dcd805..c6cfa44 100644
--- a/Source/CTest/cmCTestHG.cxx
+++ b/Source/CTest/cmCTestHG.cxx
@@ -17,8 +17,8 @@
#include <cmsys/RegularExpression.hxx>
-cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log):
- cmCTestGlobalVC(ct, log)
+cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log)
+ : cmCTestGlobalVC(ct, log)
{
this->PriorRev = this->Unknown;
}
@@ -27,74 +27,80 @@ cmCTestHG::~cmCTestHG()
{
}
-class cmCTestHG::IdentifyParser: public cmCTestVC::LineParser
+class cmCTestHG::IdentifyParser : public cmCTestVC::LineParser
{
public:
- IdentifyParser(cmCTestHG* hg, const char* prefix,
- std::string& rev): Rev(rev)
- {
+ IdentifyParser(cmCTestHG* hg, const char* prefix, std::string& rev)
+ : Rev(rev)
+ {
this->SetLog(&hg->Log, prefix);
this->RegexIdentify.compile("^([0-9a-f]+)");
- }
+ }
+
private:
std::string& Rev;
cmsys::RegularExpression RegexIdentify;
bool ProcessLine()
- {
- if(this->RegexIdentify.find(this->Line))
- {
+ {
+ if (this->RegexIdentify.find(this->Line)) {
this->Rev = this->RegexIdentify.match(1);
return false;
- }
- return true;
}
+ return true;
+ }
};
-class cmCTestHG::StatusParser: public cmCTestVC::LineParser
+class cmCTestHG::StatusParser : public cmCTestVC::LineParser
{
public:
- StatusParser(cmCTestHG* hg, const char* prefix): HG(hg)
- {
+ StatusParser(cmCTestHG* hg, const char* prefix)
+ : HG(hg)
+ {
this->SetLog(&hg->Log, prefix);
this->RegexStatus.compile("([MARC!?I]) (.*)");
- }
+ }
private:
cmCTestHG* HG;
cmsys::RegularExpression RegexStatus;
bool ProcessLine()
- {
- if(this->RegexStatus.find(this->Line))
- {
- this->DoPath(this->RegexStatus.match(1)[0],
- this->RegexStatus.match(2));
- }
- return true;
+ {
+ if (this->RegexStatus.find(this->Line)) {
+ this->DoPath(this->RegexStatus.match(1)[0], this->RegexStatus.match(2));
}
+ return true;
+ }
void DoPath(char status, std::string const& path)
- {
- if(path.empty()) return;
+ {
+ if (path.empty())
+ return;
// See "hg help status". Note that there is no 'conflict' status.
- switch(status)
- {
- case 'M': case 'A': case '!': case 'R':
+ switch (status) {
+ case 'M':
+ case 'A':
+ case '!':
+ case 'R':
this->HG->DoModification(PathModified, path);
break;
- case 'I': case '?': case 'C': case ' ': default:
+ case 'I':
+ case '?':
+ case 'C':
+ case ' ':
+ default:
break;
- }
}
+ }
};
std::string cmCTestHG::GetWorkingRevision()
{
// Run plumbing "hg identify" to get work tree revision.
const char* hg = this->CommandLineTool.c_str();
- const char* hg_identify[] = {hg, "identify","-i", 0};
+ const char* hg_identify[] = { hg, "identify", "-i", 0 };
std::string rev;
IdentifyParser out(this, "rev-out> ", rev);
OutputLogger err(this->Log, "rev-err> ");
@@ -106,7 +112,7 @@ void cmCTestHG::NoteOldRevision()
{
this->OldRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
- << this->OldRevision << "\n");
+ << this->OldRevision << "\n");
this->PriorRev.Rev = this->OldRevision;
}
@@ -114,18 +120,18 @@ void cmCTestHG::NoteNewRevision()
{
this->NewRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
- << this->NewRevision << "\n");
+ << this->NewRevision << "\n");
}
bool cmCTestHG::UpdateImpl()
{
// Use "hg pull" followed by "hg update" to update the working tree.
{
- const char* hg = this->CommandLineTool.c_str();
- const char* hg_pull[] = {hg, "pull","-v", 0};
- OutputLogger out(this->Log, "pull-out> ");
- OutputLogger err(this->Log, "pull-err> ");
- this->RunChild(&hg_pull[0], &out, &err);
+ const char* hg = this->CommandLineTool.c_str();
+ const char* hg_pull[] = { hg, "pull", "-v", 0 };
+ OutputLogger out(this->Log, "pull-out> ");
+ OutputLogger err(this->Log, "pull-err> ");
+ this->RunChild(&hg_pull[0], &out, &err);
}
// TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -137,16 +143,14 @@ bool cmCTestHG::UpdateImpl()
// Add user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
- if(opts.empty())
- {
+ if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("HGUpdateOptions");
- }
+ }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- 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) {
hg_update.push_back(ai->c_str());
- }
+ }
// Sentinel argument.
hg_update.push_back(0);
@@ -156,12 +160,16 @@ bool cmCTestHG::UpdateImpl()
return this->RunUpdateCommand(&hg_update[0], &out, &err);
}
-class cmCTestHG::LogParser: public cmCTestVC::OutputLogger,
- private cmXMLParser
+class cmCTestHG::LogParser : public cmCTestVC::OutputLogger,
+ private cmXMLParser
{
public:
- LogParser(cmCTestHG* hg, const char* prefix):
- OutputLogger(hg->Log, prefix), HG(hg) { this->InitializeParser(); }
+ LogParser(cmCTestHG* hg, const char* prefix)
+ : OutputLogger(hg->Log, prefix)
+ , HG(hg)
+ {
+ this->InitializeParser();
+ }
~LogParser() { this->CleanupParser(); }
private:
cmCTestHG* HG;
@@ -174,114 +182,88 @@ 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();
- if(const char* rev = this->FindAttribute(atts, "revision"))
- {
+ if (const char* rev = this->FindAttribute(atts, "revision")) {
this->Rev.Rev = rev;
- }
- this->Changes.clear();
}
+ this->Changes.clear();
}
+ }
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->HG->DoRevision(this->Rev, this->Changes);
- }
- 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 == "email")
- {
+ } else if (!this->CData.empty() && name == "email") {
this->Rev.EMail.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());
- }
- else if(!this->CData.empty() && name == "files")
- {
+ } else if (!this->CData.empty() && name == "files") {
std::vector<std::string> paths = this->SplitCData();
- for(unsigned int i = 0; i < paths.size(); ++i)
- {
+ for (unsigned int i = 0; i < paths.size(); ++i) {
// Updated by default, will be modified using file_adds and
// file_dels.
this->CurChange = Change('U');
this->CurChange.Path = paths[i];
this->Changes.push_back(this->CurChange);
- }
}
- else if(!this->CData.empty() && name == "file_adds")
- {
+ } else if (!this->CData.empty() && name == "file_adds") {
std::string added_paths(this->CData.begin(), this->CData.end());
- for(unsigned int i = 0; i < this->Changes.size(); ++i)
- {
- if(added_paths.find(this->Changes[i].Path) != std::string::npos)
- {
+ for (unsigned int i = 0; i < this->Changes.size(); ++i) {
+ if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
this->Changes[i].Action = 'A';
- }
}
}
- else if(!this->CData.empty() && name == "file_dels")
- {
+ } else if (!this->CData.empty() && name == "file_dels") {
std::string added_paths(this->CData.begin(), this->CData.end());
- for(unsigned int i = 0; i < this->Changes.size(); ++i)
- {
- if(added_paths.find(this->Changes[i].Path) != std::string::npos)
- {
+ for (unsigned int i = 0; i < this->Changes.size(); ++i) {
+ if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
this->Changes[i].Action = 'D';
- }
}
}
- this->CData.clear();
}
+ this->CData.clear();
+ }
std::vector<std::string> SplitCData()
- {
+ {
std::vector<std::string> output;
std::string currPath;
- for(unsigned int i=0; i < this->CData.size(); ++i)
- {
- if(this->CData[i] != ' ')
- {
+ for (unsigned int i = 0; i < this->CData.size(); ++i) {
+ if (this->CData[i] != ' ') {
currPath += this->CData[i];
- }
- else
- {
+ } else {
output.push_back(currPath);
currPath = "";
- }
}
+ }
output.push_back(currPath);
return output;
- }
+ }
virtual void ReportError(int, int, const char* msg)
- {
+ {
this->HG->Log << "Error parsing hg log xml: " << msg << "\n";
- }
+ }
};
void cmCTestHG::LoadRevisions()
@@ -294,19 +276,19 @@ void cmCTestHG::LoadRevisions()
// proper XML escapes.
std::string range = this->OldRevision + ":" + this->NewRevision;
const char* hg = this->CommandLineTool.c_str();
- const char* hgXMLTemplate =
- "<logentry\n"
- " revision=\"{node|short}\">\n"
- " <author>{author|person}</author>\n"
- " <email>{author|email}</email>\n"
- " <date>{date|isodate}</date>\n"
- " <msg>{desc}</msg>\n"
- " <files>{files}</files>\n"
- " <file_adds>{file_adds}</file_adds>\n"
- " <file_dels>{file_dels}</file_dels>\n"
- "</logentry>\n";
- const char* hg_log[] = {hg, "log","--removed", "-r", range.c_str(),
- "--template", hgXMLTemplate, 0};
+ const char* hgXMLTemplate = "<logentry\n"
+ " revision=\"{node|short}\">\n"
+ " <author>{author|person}</author>\n"
+ " <email>{author|email}</email>\n"
+ " <date>{date|isodate}</date>\n"
+ " <msg>{desc}</msg>\n"
+ " <files>{files}</files>\n"
+ " <file_adds>{file_adds}</file_adds>\n"
+ " <file_dels>{file_dels}</file_dels>\n"
+ "</logentry>\n";
+ const char* hg_log[] = {
+ hg, "log", "--removed", "-r", range.c_str(), "--template", hgXMLTemplate, 0
+ };
LogParser out(this, "log-out> ");
out.Process("<?xml version=\"1.0\"?>\n"
@@ -320,7 +302,7 @@ void cmCTestHG::LoadModifications()
{
// Use 'hg status' to get modified files.
const char* hg = this->CommandLineTool.c_str();
- const char* hg_status[] = {hg, "status", 0};
+ const char* hg_status[] = { hg, "status", 0 };
StatusParser out(this, "status-out> ");
OutputLogger err(this->Log, "status-err> ");
this->RunChild(hg_status, &out, &err);