[Cmake-commits] [cmake-commits] king committed cmCTestUpdateHandler.cxx 1.56 1.57 cmCTestUpdateHandler.h 1.10 1.11
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Feb 24 09:09:45 EST 2009
Update of /cvsroot/CMake/CMake/Source/CTest
In directory public:/mounts/ram/cvs-serv27139/Source/CTest
Modified Files:
cmCTestUpdateHandler.cxx cmCTestUpdateHandler.h
Log Message:
ENH: Factor out VCS tool detection
In cmCTestUpdateHandler, this factors out version control tool detection
from the monolithic cmCTestUpdateHandler::ProcessHandler to separate
methods. This also places priority on detection of the tool managing
the source tree since using any other tool will cause errors.
Index: cmCTestUpdateHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateHandler.cxx,v
retrieving revision 1.56
retrieving revision 1.57
diff -C 2 -d -r1.56 -r1.57
*** cmCTestUpdateHandler.cxx 24 Feb 2009 14:09:14 -0000 1.56
--- cmCTestUpdateHandler.cxx 24 Feb 2009 14:09:43 -0000 1.57
***************
*** 231,234 ****
--- 231,236 ----
{
this->Superclass::Initialize();
+ this->UpdateCommand = "";
+ this->UpdateType = e_CVS;
}
***************
*** 265,282 ****
}
}
- std::string sourceDirectory = this->GetOption("SourceDirectory");
- cmCTestLog(this->CTest, DEBUG, "Check directory: "
- << sourceDirectory.c_str() << std::endl);
- sourceDirectory += "/.svn";
- if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
- {
- return cmCTestUpdateHandler::e_SVN;
- }
- sourceDirectory = this->GetOption("SourceDirectory");
- sourceDirectory += "/CVS";
- if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
- {
- return cmCTestUpdateHandler::e_CVS;
- }
return cmCTestUpdateHandler::e_UNKNOWN;
}
--- 267,270 ----
***************
*** 288,292 ****
{
int count = 0;
- int updateType = e_CVS;
std::string::size_type cc, kk;
std::string goutput;
--- 276,279 ----
***************
*** 327,364 ****
<< sourceDirectory << std::endl);
! // Get update command
! std::string updateCommand
! = this->CTest->GetCTestConfiguration("UpdateCommand");
! if ( updateCommand.empty() )
! {
! updateCommand = this->CTest->GetCTestConfiguration("CVSCommand");
! if ( updateCommand.empty() )
! {
! updateCommand = this->CTest->GetCTestConfiguration("SVNCommand");
! if ( updateCommand.empty() )
! {
! cmCTestLog(this->CTest, ERROR_MESSAGE,
! "Cannot find CVSCommand, SVNCommand, or UpdateCommand key in the "
! "DartConfiguration.tcl" << std::endl);
! return -1;
! }
! else
! {
! updateType = e_SVN;
! }
! }
! else
! {
! updateType = e_CVS;
! }
! }
! else
{
! updateType = this->DetermineType(updateCommand.c_str(),
! this->CTest->GetCTestConfiguration("UpdateType").c_str());
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Use "
! << cmCTestUpdateHandlerUpdateToString(updateType) << " repository type"
<< std::endl;);
--- 314,325 ----
<< sourceDirectory << std::endl);
! if(!this->SelectVCS())
{
! return -1;
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Use "
! << cmCTestUpdateHandlerUpdateToString(this->UpdateType)
! << " repository type"
<< std::endl;);
***************
*** 368,372 ****
if ( updateOptions.empty() )
{
! switch (updateType)
{
case cmCTestUpdateHandler::e_CVS:
--- 329,333 ----
if ( updateOptions.empty() )
{
! switch (this->UpdateType)
{
case cmCTestUpdateHandler::e_CVS:
***************
*** 401,405 ****
// TODO: SVN
! switch ( updateType )
{
case cmCTestUpdateHandler::e_CVS:
--- 362,366 ----
// TODO: SVN
! switch ( this->UpdateType )
{
case cmCTestUpdateHandler::e_CVS:
***************
*** 416,420 ****
// First, check what the current state of repository is
std::string command = "";
! switch( updateType )
{
case cmCTestUpdateHandler::e_CVS:
--- 377,381 ----
// First, check what the current state of repository is
std::string command = "";
! switch( this->UpdateType )
{
case cmCTestUpdateHandler::e_CVS:
***************
*** 422,426 ****
break;
case cmCTestUpdateHandler::e_SVN:
! command = "\"" + updateCommand + "\" cleanup";
break;
}
--- 383,387 ----
break;
case cmCTestUpdateHandler::e_SVN:
! command = "\"" + this->UpdateCommand + "\" cleanup";
break;
}
***************
*** 458,462 ****
// First, check what the current state of repository is
command = "";
! switch( updateType )
{
case cmCTestUpdateHandler::e_CVS:
--- 419,423 ----
// First, check what the current state of repository is
command = "";
! switch( this->UpdateType )
{
case cmCTestUpdateHandler::e_CVS:
***************
*** 464,468 ****
break;
case cmCTestUpdateHandler::e_SVN:
! command = "\"" + updateCommand + "\" info";
break;
}
--- 425,429 ----
break;
case cmCTestUpdateHandler::e_SVN:
! command = "\"" + this->UpdateCommand + "\" info";
break;
}
***************
*** 496,500 ****
ofs << goutput << std::endl;
}
! switch ( updateType )
{
case cmCTestUpdateHandler::e_CVS:
--- 457,461 ----
ofs << goutput << std::endl;
}
! switch ( this->UpdateType )
{
case cmCTestUpdateHandler::e_CVS:
***************
*** 546,553 ****
{
command = "";
! switch( updateType )
{
case cmCTestUpdateHandler::e_CVS:
! command = "\"" + updateCommand + "\" -z3 update " + updateOptions +
" " + extra_update_opts;
ofs << "* Update repository: " << std::endl;
--- 507,514 ----
{
command = "";
! switch( this->UpdateType )
{
case cmCTestUpdateHandler::e_CVS:
! command = "\""+this->UpdateCommand+"\" -z3 update " + updateOptions +
" " + extra_update_opts;
ofs << "* Update repository: " << std::endl;
***************
*** 561,565 ****
{
std::string partialOutput;
! command = "\"" + updateCommand + "\" update " + updateOptions +
" " + extra_update_opts;
ofs << "* Update repository: " << std::endl;
--- 522,526 ----
{
std::string partialOutput;
! command = "\"" + this->UpdateCommand + "\" update " + updateOptions +
" " + extra_update_opts;
ofs << "* Update repository: " << std::endl;
***************
*** 571,575 ****
ofs << " Errors: " << errors.c_str() << std::endl;
goutput = partialOutput;
! command = "\"" + updateCommand + "\" status";
ofs << "* Status repository: " << std::endl;
ofs << " Command: " << command.c_str() << std::endl;
--- 532,536 ----
ofs << " Errors: " << errors.c_str() << std::endl;
goutput = partialOutput;
! command = "\"" + this->UpdateCommand + "\" status";
ofs << "* Status repository: " << std::endl;
ofs << " Command: " << command.c_str() << std::endl;
***************
*** 604,608 ****
<< "</UpdateCommand>\n"
<< "\t<UpdateType>" << cmXMLSafe(
! cmCTestUpdateHandlerUpdateToString(updateType))
<< "</UpdateType>\n";
--- 565,569 ----
<< "</UpdateCommand>\n"
<< "\t<UpdateType>" << cmXMLSafe(
! cmCTestUpdateHandlerUpdateToString(this->UpdateType))
<< "</UpdateType>\n";
***************
*** 644,648 ****
int numConflicting = 0;
// In subversion, get the latest revision
! if ( updateType == cmCTestUpdateHandler::e_SVN )
{
for ( cc= 0; cc < lines.size(); cc ++ )
--- 605,609 ----
int numConflicting = 0;
// In subversion, get the latest revision
! if ( this->UpdateType == cmCTestUpdateHandler::e_SVN )
{
for ( cc= 0; cc < lines.size(); cc ++ )
***************
*** 716,723 ****
{
std::string logcommand;
! switch ( updateType )
{
case cmCTestUpdateHandler::e_CVS:
! logcommand = "\""+updateCommand+"\" -z3 log -N \"" + file + "\"";
break;
case cmCTestUpdateHandler::e_SVN:
--- 677,685 ----
{
std::string logcommand;
! switch ( this->UpdateType )
{
case cmCTestUpdateHandler::e_CVS:
! logcommand = "\"" + this->UpdateCommand + "\" -z3 log -N \""
! + file + "\"";
break;
case cmCTestUpdateHandler::e_SVN:
***************
*** 726,730 ****
{
cmOStringStream logCommandStream;
! logCommandStream << "\"" << updateCommand << "\" log -r "
<< svn_current_revision << ":" << svn_latest_revision
<< " --xml \"" << file << "\"";
--- 688,692 ----
{
cmOStringStream logCommandStream;
! logCommandStream << "\"" << this->UpdateCommand << "\" log -r "
<< svn_current_revision << ":" << svn_latest_revision
<< " --xml \"" << file << "\"";
***************
*** 733,737 ****
else
{
! logcommand = "\"" + updateCommand +
"\" status --verbose \"" + file + "\"";
svn_use_status = 1;
--- 695,699 ----
else
{
! logcommand = "\"" + this->UpdateCommand +
"\" status --verbose \"" + file + "\"";
svn_use_status = 1;
***************
*** 768,772 ****
std::string comment1 = "";
std::string srevision2 = "Unknown";
! if ( updateType == cmCTestUpdateHandler::e_CVS )
{
bool have_first = false;
--- 730,734 ----
std::string comment1 = "";
std::string srevision2 = "Unknown";
! if ( this->UpdateType == cmCTestUpdateHandler::e_CVS )
{
bool have_first = false;
***************
*** 821,825 ****
}
}
! else if ( updateType == cmCTestUpdateHandler::e_SVN )
{
if ( svn_use_status )
--- 783,787 ----
}
}
! else if ( this->UpdateType == cmCTestUpdateHandler::e_SVN )
{
if ( svn_use_status )
***************
*** 1113,1114 ****
--- 1075,1143 ----
return true;
}
+
+ //----------------------------------------------------------------------
+ int cmCTestUpdateHandler::DetectVCS(const char* dir)
+ {
+ std::string sourceDirectory = dir;
+ cmCTestLog(this->CTest, DEBUG, "Check directory: "
+ << sourceDirectory.c_str() << std::endl);
+ sourceDirectory += "/.svn";
+ if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
+ {
+ return cmCTestUpdateHandler::e_SVN;
+ }
+ sourceDirectory = dir;
+ sourceDirectory += "/CVS";
+ if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
+ {
+ return cmCTestUpdateHandler::e_CVS;
+ }
+ return cmCTestUpdateHandler::e_UNKNOWN;
+ }
+
+ //----------------------------------------------------------------------
+ bool cmCTestUpdateHandler::SelectVCS()
+ {
+ // Get update command
+ this->UpdateCommand = this->CTest->GetCTestConfiguration("UpdateCommand");
+
+ // Detect the VCS managing the source tree.
+ this->UpdateType = this->DetectVCS(this->GetOption("SourceDirectory"));
+ if (this->UpdateType == e_UNKNOWN)
+ {
+ // The source tree does not have a recognized VCS. Check the
+ // configuration value or command name.
+ this->UpdateType = this->DetermineType(this->UpdateCommand.c_str(),
+ this->CTest->GetCTestConfiguration("UpdateType").c_str());
+ }
+
+ // If no update command was specified, lookup one for this VCS tool.
+ if (this->UpdateCommand.empty())
+ {
+ const char* key = 0;
+ switch (this->UpdateType)
+ {
+ case e_CVS: key = "CVSCommand"; break;
+ case e_SVN: key = "SVNCommand"; break;
+ default: break;
+ }
+ if (key)
+ {
+ this->UpdateCommand = this->CTest->GetCTestConfiguration(key);
+ }
+ if (this->UpdateCommand.empty())
+ {
+ cmOStringStream e;
+ e << "Cannot find UpdateCommand ";
+ if (key)
+ {
+ e << "or " << key;
+ }
+ e << " configuration key.";
+ cmCTestLog(this->CTest, ERROR_MESSAGE, e.str() << std::endl);
+ return false;
+ }
+ }
+
+ return true;
+ }
Index: cmCTestUpdateHandler.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateHandler.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C 2 -d -r1.10 -r1.11
*** cmCTestUpdateHandler.h 24 Feb 2009 14:09:14 -0000 1.10
--- cmCTestUpdateHandler.h 24 Feb 2009 14:09:43 -0000 1.11
***************
*** 64,68 ****
--- 64,74 ----
int DetermineType(const char* cmd, const char* type);
+ // The VCS command to update the working tree.
+ std::string UpdateCommand;
+ int UpdateType;
+
bool InitialCheckout(std::ostream& ofs);
+ int DetectVCS(const char* dir);
+ bool SelectVCS();
};
More information about the Cmake-commits
mailing list