2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2009-04-22 17:18:19 +04:00
|
|
|
#include "cmCTestGlobalVC.h"
|
|
|
|
|
|
|
|
#include "cmCTest.h"
|
|
|
|
#include "cmSystemTools.h"
|
2015-05-24 01:33:24 +03:00
|
|
|
#include "cmXMLWriter.h"
|
2009-04-22 17:18:19 +04:00
|
|
|
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <ostream>
|
|
|
|
#include <utility>
|
2009-04-22 17:18:19 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log)
|
|
|
|
: cmCTestVC(ct, log)
|
2009-04-22 17:18:19 +04:00
|
|
|
{
|
|
|
|
this->PriorRev = this->Unknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCTestGlobalVC::~cmCTestGlobalVC()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmCTestGlobalVC::LocalPath(std::string const& path)
|
|
|
|
{
|
|
|
|
return path.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmCTestGlobalVC::DoRevision(Revision const& revision,
|
|
|
|
std::vector<Change> const& changes)
|
|
|
|
{
|
|
|
|
// Ignore changes in the old revision.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (revision.Rev == this->OldRevision) {
|
2009-04-22 17:18:19 +04:00
|
|
|
this->PriorRev = revision;
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-04-22 17:18:19 +04:00
|
|
|
|
|
|
|
// Indicate we found a revision.
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
|
|
|
|
|
|
|
|
// Store the revision.
|
|
|
|
this->Revisions.push_back(revision);
|
|
|
|
|
|
|
|
// Report this revision.
|
|
|
|
Revision const& rev = this->Revisions.back();
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2009-04-22 17:18:19 +04:00
|
|
|
this->Log << "Found revision " << rev.Rev << "\n"
|
|
|
|
<< " author = " << rev.Author << "\n"
|
|
|
|
<< " date = " << rev.Date << "\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2009-04-22 17:18:19 +04:00
|
|
|
|
|
|
|
// Update information about revisions of the changed files.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<Change>::const_iterator ci = changes.begin();
|
|
|
|
ci != changes.end(); ++ci) {
|
|
|
|
if (const char* local = this->LocalPath(ci->Path)) {
|
2009-04-22 17:18:19 +04:00
|
|
|
std::string dir = cmSystemTools::GetFilenamePath(local);
|
|
|
|
std::string name = cmSystemTools::GetFilenameName(local);
|
|
|
|
File& file = this->Dirs[dir][name];
|
2016-05-16 17:34:04 +03:00
|
|
|
file.PriorRev = file.Rev ? file.Rev : &this->PriorRev;
|
2009-04-22 17:18:19 +04:00
|
|
|
file.Rev = &rev;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Log << " " << ci->Action << " " << local << " "
|
|
|
|
<< "\n";
|
2009-04-22 17:18:19 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-04-22 17:18:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCTestGlobalVC::DoModification(PathStatus status,
|
|
|
|
std::string const& path)
|
|
|
|
{
|
|
|
|
std::string dir = cmSystemTools::GetFilenamePath(path);
|
|
|
|
std::string name = cmSystemTools::GetFilenameName(path);
|
|
|
|
File& file = this->Dirs[dir][name];
|
|
|
|
file.Status = status;
|
|
|
|
// For local modifications the current rev is unknown and the
|
|
|
|
// prior rev is the latest from svn.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!file.Rev && !file.PriorRev) {
|
2009-04-22 17:18:19 +04:00
|
|
|
file.PriorRev = &this->PriorRev;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-04-22 17:18:19 +04:00
|
|
|
}
|
|
|
|
|
2015-05-24 01:33:24 +03:00
|
|
|
void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
|
2009-04-22 17:18:19 +04:00
|
|
|
std::string const& path,
|
|
|
|
Directory const& dir)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* slash = path.empty() ? "" : "/";
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.StartElement("Directory");
|
|
|
|
xml.Element("Name", path);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
|
2009-04-22 17:18:19 +04:00
|
|
|
std::string full = path + slash + fi->first;
|
|
|
|
this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.EndElement(); // Directory
|
2009-04-22 17:18:19 +04:00
|
|
|
}
|
|
|
|
|
2015-05-24 01:33:24 +03:00
|
|
|
void cmCTestGlobalVC::WriteXMLGlobal(cmXMLWriter& xml)
|
2009-12-18 16:13:51 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->NewRevision.empty()) {
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.Element("Revision", this->NewRevision);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->OldRevision.empty() && this->OldRevision != this->NewRevision) {
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.Element("PriorRevision", this->OldRevision);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-12-18 16:13:51 +03:00
|
|
|
}
|
|
|
|
|
2015-05-24 01:33:24 +03:00
|
|
|
bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
|
2009-04-22 17:18:19 +04:00
|
|
|
{
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Gathering version information (one . per revision):\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
" "
|
|
|
|
<< std::flush);
|
2009-04-22 17:18:19 +04:00
|
|
|
this->LoadRevisions();
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
|
|
|
|
|
|
|
|
this->LoadModifications();
|
|
|
|
|
2009-12-18 16:13:51 +03:00
|
|
|
this->WriteXMLGlobal(xml);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::map<std::string, Directory>::const_iterator di =
|
|
|
|
this->Dirs.begin();
|
|
|
|
di != this->Dirs.end(); ++di) {
|
2009-04-22 17:18:19 +04:00
|
|
|
this->WriteXMLDirectory(xml, di->first, di->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-04-22 17:18:19 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|