From fdd0d2a32bffc3742b5d40c066a61794135bd6f4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Feb 2009 12:50:15 -0500 Subject: ENH: Factor out svn work tree cleanup This removes work tree cleanup from cmCTestUpdateHandler and adds an interface for it in cmCTestVC with an implementation in cmCTestSVN. --- Source/CTest/cmCTestSVN.cxx | 10 ++++++++ Source/CTest/cmCTestSVN.h | 4 ++++ Source/CTest/cmCTestUpdateHandler.cxx | 45 +++-------------------------------- Source/CTest/cmCTestVC.cxx | 14 +++++++++++ Source/CTest/cmCTestVC.h | 5 ++++ 5 files changed, 36 insertions(+), 42 deletions(-) diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index f7111c9..9396404 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -25,3 +25,13 @@ cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log) cmCTestSVN::~cmCTestSVN() { } + +//---------------------------------------------------------------------------- +void cmCTestSVN::CleanupImpl() +{ + const char* svn = this->CommandLineTool.c_str(); + const char* svn_cleanup[] = {svn, "cleanup", 0}; + OutputLogger out(this->Log, "cleanup-out> "); + OutputLogger err(this->Log, "cleanup-err> "); + this->RunChild(svn_cleanup, &out, &err); +} diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h index b003094..c6723af 100644 --- a/Source/CTest/cmCTestSVN.h +++ b/Source/CTest/cmCTestSVN.h @@ -30,6 +30,10 @@ public: cmCTestSVN(cmCTest* ctest, std::ostream& log); virtual ~cmCTestSVN(); + +private: + // Implement cmCTestVC internal API. + virtual void CleanupImpl(); }; #endif diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index cce8f2f..e2cc0f7 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -389,6 +389,9 @@ int cmCTestUpdateHandler::ProcessHandler() } } + // Cleanup the working tree. + vc->Cleanup(); + bool res = true; // First, check what the current state of repository is @@ -399,48 +402,6 @@ int cmCTestUpdateHandler::ProcessHandler() // TODO: CVS - for now just leave empty break; case cmCTestUpdateHandler::e_SVN: - command = "\"" + this->UpdateCommand + "\" cleanup"; - break; - } - - // - // Get initial repository information if that is possible. With subversion, - // this will check the current revision. - // - if ( !command.empty() ) - { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "* Cleanup repository: " << command.c_str() << std::endl); - if ( !this->CTest->GetShowOnly() ) - { - ofs << "* Cleanup repository" << std::endl; - ofs << " Command: " << command.c_str() << std::endl; - res = this->CTest->RunCommand(command.c_str(), &goutput, &errors, - &retVal, sourceDirectory, 0 /*this->TimeOut*/); - - ofs << " Output: " << goutput.c_str() << std::endl; - ofs << " Errors: " << errors.c_str() << std::endl; - if ( ofs ) - { - ofs << "--- Cleanup ---" << std::endl; - ofs << goutput << std::endl; - } - } - else - { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Cleanup with command: " << command << std::endl); - } - } - - // First, check what the current state of repository is - command = ""; - switch( this->UpdateType ) - { - case cmCTestUpdateHandler::e_CVS: - // TODO: CVS - for now just leave empty - break; - case cmCTestUpdateHandler::e_SVN: command = "\"" + this->UpdateCommand + "\" info"; break; } diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index 9d9a191..d03b23b 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -70,3 +70,17 @@ std::string cmCTestVC::ComputeCommandLine(char const* const* cmd) } return line.str(); } + +//---------------------------------------------------------------------------- +void cmCTestVC::Cleanup() +{ + this->Log << "--- Begin Cleanup ---\n"; + this->CleanupImpl(); + this->Log << "--- End Cleanup ---\n"; +} + +//---------------------------------------------------------------------------- +void cmCTestVC::CleanupImpl() +{ + // We do no cleanup by default. +} diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h index 1bc4277..4564e70 100644 --- a/Source/CTest/cmCTestVC.h +++ b/Source/CTest/cmCTestVC.h @@ -39,7 +39,12 @@ public: /** Top-level source directory. */ void SetSourceDirectory(std::string const& dir); + /** Perform cleanup operations on the work tree. */ + void Cleanup(); + protected: + // Internal API to be implemented by subclasses. + virtual void CleanupImpl(); /** Convert a list of arguments to a human-readable command line. */ static std::string ComputeCommandLine(char const* const* cmd); -- cgit v0.12