[Cmake-commits] [cmake-commits] king committed cmCTestSVN.cxx 1.2 1.3 cmCTestSVN.h 1.2 1.3 cmCTestUpdateHandler.cxx 1.60 1.61 cmCTestVC.cxx 1.4 1.5 cmCTestVC.h 1.4 1.5
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Feb 24 12:52:38 EST 2009
Update of /cvsroot/CMake/CMake/Source/CTest
In directory public:/mounts/ram/cvs-serv26380/Source/CTest
Modified Files:
cmCTestSVN.cxx cmCTestSVN.h cmCTestUpdateHandler.cxx
cmCTestVC.cxx cmCTestVC.h
Log Message:
ENH: Factor out VCS work tree revision checks
This moves checks of the work tree revision before and after update from
cmCTestUpdateHandler::ProcessHandler into the cmCTestVC hierarchy.
Index: cmCTestUpdateHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateHandler.cxx,v
retrieving revision 1.60
retrieving revision 1.61
diff -C 2 -d -r1.60 -r1.61
*** cmCTestUpdateHandler.cxx 24 Feb 2009 17:50:48 -0000 1.60
--- cmCTestUpdateHandler.cxx 24 Feb 2009 17:52:36 -0000 1.61
***************
*** 384,399 ****
bool res = true;
- // First, check what the current state of repository is
- std::string 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;
- }
-
// CVS variables
// SVN variables
--- 384,387 ----
***************
*** 402,454 ****
int svn_use_status = 0;
! //
! // 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,
! "* Get repository information: " << command.c_str() << std::endl);
! if ( !this->CTest->GetShowOnly() )
! {
! ofs << "* Get repository information" << 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 << "--- Update information ---" << std::endl;
! ofs << goutput << std::endl;
! }
! switch ( this->UpdateType )
! {
! case cmCTestUpdateHandler::e_CVS:
! // TODO: CVS - for now just leave empty
! break;
! case cmCTestUpdateHandler::e_SVN:
! {
! cmsys::RegularExpression current_revision_regex(
! "Revision: ([0-9]+)");
! if ( current_revision_regex.find(goutput.c_str()) )
! {
! std::string currentRevisionString
! = current_revision_regex.match(1);
! svn_current_revision = atoi(currentRevisionString.c_str());
! cmCTestLog(this->CTest, HANDLER_OUTPUT,
! " Old revision of repository is: " << svn_current_revision
! << std::endl);
! }
! }
! break;
! }
! }
! else
! {
! cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
! "Get information with command: " << command << std::endl);
! }
}
--- 390,399 ----
int svn_use_status = 0;
! // Get initial repository information if that is possible.
! vc->MarkOldRevision();
! if(this->UpdateType == e_SVN)
{
! svn_current_revision =
! static_cast<cmCTestSVN*>(vc.get())->GetOldRevision();
}
***************
*** 469,472 ****
--- 414,418 ----
double elapsed_time_start = cmSystemTools::GetTime();
+ std::string command;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "* Update repository: "
<< command.c_str() << std::endl);
***************
*** 571,599 ****
int numModified = 0;
int numConflicting = 0;
! // In subversion, get the latest revision
if ( this->UpdateType == cmCTestUpdateHandler::e_SVN )
{
! for ( cc= 0; cc < lines.size(); cc ++ )
! {
! const char* line = lines[cc].c_str();
! if ( svn_latest_revision_regex.find(line) )
! {
! svn_latest_revision = atoi(
! svn_latest_revision_regex.match(2).c_str());
! }
! }
! if ( svn_latest_revision <= 0 )
! {
! cmCTestLog(this->CTest, ERROR_MESSAGE,
! "Problem determining the current "
! "revision of the repository from output:" << std::endl
! << goutput.c_str() << std::endl);
! }
! else
! {
! cmCTestLog(this->CTest, HANDLER_OUTPUT,
! " Current revision of repository is: " << svn_latest_revision
! << std::endl);
! }
}
--- 517,527 ----
int numModified = 0;
int numConflicting = 0;
!
! // Get final repository information if that is possible.
! vc->MarkNewRevision();
if ( this->UpdateType == cmCTestUpdateHandler::e_SVN )
{
! svn_latest_revision =
! static_cast<cmCTestSVN*>(vc.get())->GetNewRevision();
}
Index: cmCTestVC.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestVC.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C 2 -d -r1.4 -r1.5
*** cmCTestVC.h 24 Feb 2009 17:50:48 -0000 1.4
--- cmCTestVC.h 24 Feb 2009 17:52:36 -0000 1.5
***************
*** 46,52 ****
--- 46,56 ----
void Cleanup();
+ void MarkOldRevision() { this->NoteOldRevision(); }
+ void MarkNewRevision() { this->NoteNewRevision(); }
protected:
// Internal API to be implemented by subclasses.
virtual void CleanupImpl();
+ virtual void NoteOldRevision();
+ virtual void NoteNewRevision();
/** Convert a list of arguments to a human-readable command line. */
Index: cmCTestSVN.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestSVN.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** cmCTestSVN.h 24 Feb 2009 17:50:15 -0000 1.2
--- cmCTestSVN.h 24 Feb 2009 17:52:36 -0000 1.3
***************
*** 32,38 ****
--- 32,52 ----
virtual ~cmCTestSVN();
+ int GetOldRevision() { return atoi(this->OldRevision.c_str()); }
+ int GetNewRevision() { return atoi(this->NewRevision.c_str()); }
private:
// Implement cmCTestVC internal API.
virtual void CleanupImpl();
+ virtual void NoteOldRevision();
+ virtual void NoteNewRevision();
+
+ // Old and new repository revisions.
+ std::string OldRevision;
+ std::string NewRevision;
+
+ std::string LoadInfo();
+
+ // Parsing helper classes.
+ class InfoParser;
+ friend class InfoParser;
};
Index: cmCTestSVN.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestSVN.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** cmCTestSVN.cxx 24 Feb 2009 17:50:15 -0000 1.2
--- cmCTestSVN.cxx 24 Feb 2009 17:52:36 -0000 1.3
***************
*** 17,20 ****
--- 17,24 ----
#include "cmCTestSVN.h"
+ #include "cmCTest.h"
+
+ #include <cmsys/RegularExpression.hxx>
+
//----------------------------------------------------------------------------
cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log)
***************
*** 36,37 ****
--- 40,96 ----
this->RunChild(svn_cleanup, &out, &err);
}
+
+ //----------------------------------------------------------------------------
+ class cmCTestSVN::InfoParser: public cmCTestVC::LineParser
+ {
+ public:
+ InfoParser(cmCTestSVN* svn, const char* prefix, std::string& rev):
+ SVN(svn), Rev(rev)
+ {
+ this->SetLog(&svn->Log, prefix);
+ this->RegexRev.compile("^Revision: ([0-9]+)");
+ }
+ private:
+ cmCTestSVN* SVN;
+ std::string& Rev;
+ cmsys::RegularExpression RegexRev;
+ virtual bool ProcessLine()
+ {
+ if(this->RegexRev.find(this->Line))
+ {
+ this->Rev = this->RegexRev.match(1);
+ }
+ return true;
+ }
+ };
+
+ //----------------------------------------------------------------------------
+ std::string cmCTestSVN::LoadInfo()
+ {
+ // Run "svn info" to get the repository info from the work tree.
+ const char* svn = this->CommandLineTool.c_str();
+ const char* svn_info[] = {svn, "info", 0};
+ std::string rev;
+ InfoParser out(this, "info-out> ", rev);
+ OutputLogger err(this->Log, "info-err> ");
+ this->RunChild(svn_info, &out, &err);
+ return rev;
+ }
+
+ //----------------------------------------------------------------------------
+ void cmCTestSVN::NoteOldRevision()
+ {
+ this->OldRevision = this->LoadInfo();
+ this->Log << "Revision before update: " << this->OldRevision << "\n";
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
+ << this->OldRevision << "\n");
+ }
+
+ //----------------------------------------------------------------------------
+ void cmCTestSVN::NoteNewRevision()
+ {
+ this->NewRevision = this->LoadInfo();
+ this->Log << "Revision after update: " << this->NewRevision << "\n";
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
+ << this->NewRevision << "\n");
+ }
Index: cmCTestVC.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestVC.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -C 2 -d -r1.4 -r1.5
*** cmCTestVC.cxx 24 Feb 2009 17:50:48 -0000 1.4
--- cmCTestVC.cxx 24 Feb 2009 17:52:36 -0000 1.5
***************
*** 103,104 ****
--- 103,116 ----
// We do no cleanup by default.
}
+
+ //----------------------------------------------------------------------------
+ void cmCTestVC::NoteOldRevision()
+ {
+ // We do nothing by default.
+ }
+
+ //----------------------------------------------------------------------------
+ void cmCTestVC::NoteNewRevision()
+ {
+ // We do nothing by default.
+ }
More information about the Cmake-commits
mailing list