summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestP4.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-06-08 12:50:10 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2023-08-29 14:51:30 (GMT)
commitec124582acf966db9e6ddb226b53021fe6be591a (patch)
treebd0b3056158f944b5469aa364cd7720e83acd766 /Source/CTest/cmCTestP4.cxx
parent5420639a8d696055577de638e0952d6936706f18 (diff)
downloadCMake-ec124582acf966db9e6ddb226b53021fe6be591a.zip
CMake-ec124582acf966db9e6ddb226b53021fe6be591a.tar.gz
CMake-ec124582acf966db9e6ddb226b53021fe6be591a.tar.bz2
cmProcessTools::RunProcess(): Replace cmsysProcess with cmUVProcessChain
And convert the VCS code to std::vector<std::string>.
Diffstat (limited to 'Source/CTest/cmCTestP4.cxx')
-rw-r--r--Source/CTest/cmCTestP4.cxx66
1 files changed, 26 insertions, 40 deletions
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index 0e002b9..5d71b84 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -149,17 +149,16 @@ cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
auto it = this->Users.find(username);
if (it == this->Users.end()) {
- std::vector<char const*> p4_users;
+ std::vector<std::string> p4_users;
this->SetP4Options(p4_users);
p4_users.push_back("users");
p4_users.push_back("-m");
p4_users.push_back("1");
- p4_users.push_back(username.c_str());
- p4_users.push_back(nullptr);
+ p4_users.push_back(username);
UserParser out(this, "users-out> ");
OutputLogger err(this->Log, "users-err> ");
- this->RunChild(p4_users.data(), &out, &err);
+ this->RunChild(p4_users, &out, &err);
// The user should now be added to the map. Search again.
it = this->Users.find(username);
@@ -303,10 +302,10 @@ private:
}
};
-void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions)
+void cmCTestP4::SetP4Options(std::vector<std::string>& CommandOptions)
{
if (this->P4Options.empty()) {
- const char* p4 = this->CommandLineTool.c_str();
+ std::string p4 = this->CommandLineTool;
this->P4Options.emplace_back(p4);
// The CTEST_P4_CLIENT variable sets the P4 client used when issuing
@@ -328,15 +327,12 @@ void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions)
cm::append(this->P4Options, cmSystemTools::ParseArguments(opts));
}
- CommandOptions.clear();
- for (std::string const& o : this->P4Options) {
- CommandOptions.push_back(o.c_str());
- }
+ CommandOptions = this->P4Options;
}
std::string cmCTestP4::GetWorkingRevision()
{
- std::vector<char const*> p4_identify;
+ std::vector<std::string> p4_identify;
this->SetP4Options(p4_identify);
p4_identify.push_back("changes");
@@ -345,14 +341,13 @@ std::string cmCTestP4::GetWorkingRevision()
p4_identify.push_back("-t");
std::string source = this->SourceDirectory + "/...#have";
- p4_identify.push_back(source.c_str());
- p4_identify.push_back(nullptr);
+ p4_identify.push_back(source);
std::string rev;
IdentifyParser out(this, "p4_changes-out> ", rev);
OutputLogger err(this->Log, "p4_changes-err> ");
- bool result = this->RunChild(p4_identify.data(), &out, &err);
+ bool result = this->RunChild(p4_identify, &out, &err);
// If there was a problem contacting the server return "<unknown>"
if (!result) {
@@ -388,7 +383,7 @@ bool cmCTestP4::NoteNewRevision()
bool cmCTestP4::LoadRevisions()
{
- std::vector<char const*> p4_changes;
+ std::vector<std::string> p4_changes;
this->SetP4Options(p4_changes);
// Use 'p4 changes ...@old,new' to get a list of changelists
@@ -409,38 +404,36 @@ bool cmCTestP4::LoadRevisions()
.append(this->NewRevision);
p4_changes.push_back("changes");
- p4_changes.push_back(range.c_str());
- p4_changes.push_back(nullptr);
+ p4_changes.push_back(range);
ChangesParser out(this, "p4_changes-out> ");
OutputLogger err(this->Log, "p4_changes-err> ");
this->ChangeLists.clear();
- this->RunChild(p4_changes.data(), &out, &err);
+ this->RunChild(p4_changes, &out, &err);
if (this->ChangeLists.empty()) {
return true;
}
// p4 describe -s ...@1111111,2222222
- std::vector<char const*> p4_describe;
+ std::vector<std::string> p4_describe;
for (std::string const& i : cmReverseRange(this->ChangeLists)) {
this->SetP4Options(p4_describe);
p4_describe.push_back("describe");
p4_describe.push_back("-s");
- p4_describe.push_back(i.c_str());
- p4_describe.push_back(nullptr);
+ p4_describe.push_back(i);
DescribeParser outDescribe(this, "p4_describe-out> ");
OutputLogger errDescribe(this->Log, "p4_describe-err> ");
- this->RunChild(p4_describe.data(), &outDescribe, &errDescribe);
+ this->RunChild(p4_describe, &outDescribe, &errDescribe);
}
return true;
}
bool cmCTestP4::LoadModifications()
{
- std::vector<char const*> p4_diff;
+ std::vector<std::string> p4_diff;
this->SetP4Options(p4_diff);
p4_diff.push_back("diff");
@@ -448,12 +441,11 @@ bool cmCTestP4::LoadModifications()
// Ideally we would use -Od but not all clients support it
p4_diff.push_back("-dn");
std::string source = this->SourceDirectory + "/...";
- p4_diff.push_back(source.c_str());
- p4_diff.push_back(nullptr);
+ p4_diff.push_back(source);
DiffParser out(this, "p4_diff-out> ");
OutputLogger err(this->Log, "p4_diff-err> ");
- this->RunChild(p4_diff.data(), &out, &err);
+ this->RunChild(p4_diff, &out, &err);
return true;
}
@@ -461,17 +453,14 @@ bool cmCTestP4::UpdateCustom(const std::string& custom)
{
cmList p4_custom_command{ custom, cmList::EmptyElements::Yes };
- std::vector<char const*> p4_custom;
- p4_custom.reserve(p4_custom_command.size() + 1);
- for (std::string const& i : p4_custom_command) {
- p4_custom.push_back(i.c_str());
- }
- p4_custom.push_back(nullptr);
+ std::vector<std::string> p4_custom;
+ p4_custom.reserve(p4_custom_command.size());
+ cm::append(p4_custom, p4_custom_command);
OutputLogger custom_out(this->Log, "p4_customsync-out> ");
OutputLogger custom_err(this->Log, "p4_customsync-err> ");
- return this->RunUpdateCommand(p4_custom.data(), &custom_out, &custom_err);
+ return this->RunUpdateCommand(p4_custom, &custom_out, &custom_err);
}
bool cmCTestP4::UpdateImpl()
@@ -488,7 +477,7 @@ bool cmCTestP4::UpdateImpl()
return false;
}
- std::vector<char const*> p4_sync;
+ std::vector<std::string> p4_sync;
this->SetP4Options(p4_sync);
p4_sync.push_back("sync");
@@ -499,9 +488,7 @@ bool cmCTestP4::UpdateImpl()
opts = this->CTest->GetCTestConfiguration("P4UpdateOptions");
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
- for (std::string const& arg : args) {
- p4_sync.push_back(arg.c_str());
- }
+ cm::append(p4_sync, args);
std::string source = this->SourceDirectory + "/...";
@@ -515,11 +502,10 @@ bool cmCTestP4::UpdateImpl()
source.append("@\"").append(date).append("\"");
}
- p4_sync.push_back(source.c_str());
- p4_sync.push_back(nullptr);
+ p4_sync.push_back(source);
OutputLogger out(this->Log, "p4_sync-out> ");
OutputLogger err(this->Log, "p4_sync-err> ");
- return this->RunUpdateCommand(p4_sync.data(), &out, &err);
+ return this->RunUpdateCommand(p4_sync, &out, &err);
}