summaryrefslogtreecommitdiff
path: root/Source/CTest/cmCTestVC.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-02-25 14:42:45 -0500
committerBrad King <brad.king@kitware.com>2009-02-25 14:42:45 -0500
commit80282b749fb138ea8bd188dd5b7623c7545ea927 (patch)
treea654e1b28bf2b2bec97de9ee7dad695d322598f1 /Source/CTest/cmCTestVC.cxx
parentcb788e8f6dfeeb5a934679f671adc87116837834 (diff)
downloadcmake-80282b749fb138ea8bd188dd5b7623c7545ea927.tar.gz
ENH: Rewrite CTest Update implementation
This adds a new VCS update implementation to the cmCTestVC hierarchy and removes it from cmCTestUpdateHandler. The new implementation has the following advantages: - Factorized implementation instead of monolithic function - Logs vcs tool output as it is parsed (less memory, inline messages) - Uses one global svn log instead of one log per file - Reports changes on cvs branches (instead of latest trunk change) - Generates simpler Update.xml (only one Directory element per dir) Shared components of the new implementation appear in cmCTestVC and may be re-used by subclasses for other VCS tools in the future.
Diffstat (limited to 'Source/CTest/cmCTestVC.cxx')
-rw-r--r--Source/CTest/cmCTestVC.cxx82
1 files changed, 82 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index ccc6fcb4fe..642a59a8f4 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -17,12 +17,19 @@
#include "cmCTestVC.h"
#include "cmCTest.h"
+#include "cmXMLSafe.h"
#include <cmsys/Process.h>
//----------------------------------------------------------------------------
cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log): CTest(ct), Log(log)
{
+ this->PathCount[PathUpdated] = 0;
+ this->PathCount[PathModified] = 0;
+ this->PathCount[PathConflicting] = 0;
+ this->Unknown.Date = "Unknown";
+ this->Unknown.Author = "Unknown";
+ this->Unknown.Rev = "Unknown";
}
//----------------------------------------------------------------------------
@@ -72,6 +79,22 @@ std::string cmCTestVC::ComputeCommandLine(char const* const* cmd)
}
//----------------------------------------------------------------------------
+bool cmCTestVC::RunUpdateCommand(char const* const* cmd,
+ OutputParser* out, OutputParser* err)
+{
+ // Report the command line.
+ this->UpdateCommandLine = this->ComputeCommandLine(cmd);
+ if(this->CTest->GetShowOnly())
+ {
+ this->Log << this->UpdateCommandLine << "\n";
+ return true;
+ }
+
+ // Run the command.
+ return this->RunChild(cmd, out, err);
+}
+
+//----------------------------------------------------------------------------
std::string cmCTestVC::GetNightlyTime()
{
// Get the nightly start time corresponding to the current dau.
@@ -104,6 +127,17 @@ void cmCTestVC::CleanupImpl()
}
//----------------------------------------------------------------------------
+bool cmCTestVC::Update()
+{
+ this->NoteOldRevision();
+ this->Log << "--- Begin Update ---\n";
+ bool result = this->UpdateImpl();
+ this->Log << "--- End Update ---\n";
+ this->NoteNewRevision();
+ return result;
+}
+
+//----------------------------------------------------------------------------
void cmCTestVC::NoteOldRevision()
{
// We do nothing by default.
@@ -114,3 +148,51 @@ void cmCTestVC::NoteNewRevision()
{
// We do nothing by default.
}
+
+//----------------------------------------------------------------------------
+bool cmCTestVC::UpdateImpl()
+{
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "* Unknown VCS tool, not updating!" << std::endl);
+ return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmCTestVC::WriteXML(std::ostream& xml)
+{
+ this->Log << "--- Begin Revisions ---\n";
+ bool result = this->WriteXMLUpdates(xml);
+ this->Log << "--- End Revisions ---\n";
+ return result;
+}
+
+//----------------------------------------------------------------------------
+bool cmCTestVC::WriteXMLUpdates(std::ostream&)
+{
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "* CTest cannot extract updates for this VCS tool.\n");
+ return true;
+}
+
+//----------------------------------------------------------------------------
+void cmCTestVC::WriteXMLEntry(std::ostream& xml,
+ std::string const& path,
+ std::string const& name,
+ std::string const& full,
+ File const& f)
+{
+ static const char* desc[3] = { "Updated", "Modified", "Conflicting"};
+ Revision const& rev = f.Rev? *f.Rev : this->Unknown;
+ std::string prior = f.PriorRev? f.PriorRev->Rev : std::string("Unknown");
+ xml << "\t\t<" << desc[f.Status] << ">\n"
+ << "\t\t\t<File>" << cmXMLSafe(name) << "</File>\n"
+ << "\t\t\t<Directory>" << cmXMLSafe(path) << "</Directory>\n"
+ << "\t\t\t<FullName>" << cmXMLSafe(full) << "</FullName>\n"
+ << "\t\t\t<CheckinDate>" << cmXMLSafe(rev.Date) << "</CheckinDate>\n"
+ << "\t\t\t<Author>" << cmXMLSafe(rev.Author) << "</Author>\n"
+ << "\t\t\t<Log>" << cmXMLSafe(rev.Log) << "</Log>\n"
+ << "\t\t\t<Revision>" << cmXMLSafe(rev.Rev) << "</Revision>\n"
+ << "\t\t\t<PriorRevision>" << cmXMLSafe(prior) << "</PriorRevision>\n"
+ << "\t\t</" << desc[f.Status] << ">\n";
+ ++this->PathCount[f.Status];
+}