Attached Files | p4.patch [^] (14,571 bytes) 1969-12-31 19:00 [Show Content] [Hide Content]==== //Abingdon/Tools/src/cmake/cmake-2.4.6/Modules/CTest.cmake#1 - D:\Abingdon\Tools\src\cmake\cmake-2.4.6\Modules\CTest.cmake ====
@@ -85,6 +85,7 @@
SET(CVS_UPDATE_OPTIONS "-d -A -P" CACHE STRING
"Options passed to the cvs update command.")
FIND_PROGRAM(SVNCOMMAND svn)
+ FIND_PROGRAM(P4COMMAND p4)
IF(NOT UPDATE_TYPE)
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CVS")
@@ -97,7 +98,7 @@
ENDIF(NOT UPDATE_TYPE)
IF(NOT UPDATE_TYPE)
- MESSAGE(STATUS "Cannot determine repository type. Please set UPDATE_TYPE to 'cvs' or 'svn'. CTest update will not work.")
+ MESSAGE(STATUS "Cannot determine repository type. Please set UPDATE_TYPE to 'cvs', 'svn' or 'p4'. CTest update will not work.")
ENDIF(NOT UPDATE_TYPE)
IF(UPDATE_TYPE MATCHES "[Cc][Vv][Ss]")
@@ -107,6 +108,11 @@
IF(UPDATE_TYPE MATCHES "[Ss][Vv][Nn]")
SET(UPDATE_COMMAND "${SVNCOMMAND}")
SET(UPDATE_OPTIONS "${SVN_UPDATE_OPTIONS}")
+ ELSE(UPDATE_TYPE MATCHES "[Ss][Vv][Nn]")
+ IF(UPDATE_TYPE MATCHES "[Pp]4")
+ SET(UPDATE_COMMAND "${P4COMMAND}")
+ SET(UPDATE_OPTIONS "${P4_UPDATE_OPTIONS}")
+ ENDIF(UPDATE_TYPE MATCHES "[Pp]4")
ENDIF(UPDATE_TYPE MATCHES "[Ss][Vv][Nn]")
ENDIF(UPDATE_TYPE MATCHES "[Cc][Vv][Ss]")
@@ -180,8 +186,10 @@
COVERAGE_COMMAND
CVSCOMMAND
SVNCOMMAND
+ P4COMMAND
CVS_UPDATE_OPTIONS
SVN_UPDATE_OPTIONS
+ P4_UPDATE_OPTIONS
MAKECOMMAND
MEMORYCHECK_COMMAND
MEMORYCHECK_SUPPRESSIONS_FILE
==== //Abingdon/Tools/src/cmake/cmake-2.4.6/Modules/DartConfiguration.tcl.in#1 - D:\Abingdon\Tools\src\cmake\cmake-2.4.6\Modules\DartConfiguration.tcl.in ====
@@ -39,6 +39,10 @@
SVNCommand: @SVNCOMMAND@
SVNUpdateOptions: @SVN_UPDATE_OPTIONS@
+# Perforce options
+P4Command: @P4COMMAND@
+P4UpdateOptions: @P4_UPDATE_OPTIONS@
+
# Generic update command
UpdateCommand: @UPDATE_COMMAND@
UpdateOptions: @UPDATE_OPTIONS@
==== //Abingdon/Tools/src/cmake/cmake-2.4.6/Source/CTest/cmCTestUpdateCommand.cxx#1 - D:\Abingdon\Tools\src\cmake\cmake-2.4.6\Source\CTest\cmCTestUpdateCommand.cxx ====
@@ -48,6 +48,10 @@
"SVNCommand", "CTEST_SVN_COMMAND");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS");
+ this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
+ "P4Command", "CTEST_P4_COMMAND");
+ this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
+ "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS");
const char* initialCheckoutCommand
= this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
==== //Abingdon/Tools/src/cmake/cmake-2.4.6/Source/CTest/cmCTestUpdateHandler.cxx#1 - D:\Abingdon\Tools\src\cmake\cmake-2.4.6\Source\CTest\cmCTestUpdateHandler.cxx ====
@@ -43,7 +43,8 @@
{
"Unknown",
"CVS",
- "SVN"
+ "SVN",
+ "P4"
};
static const char* cmCTestUpdateHandlerUpdateToString(int type)
@@ -208,6 +209,10 @@
{
return cmCTestUpdateHandler::e_SVN;
}
+ if ( stype.find("p4") != std::string::npos )
+ {
+ return cmCTestUpdateHandler::e_P4;
+ }
}
else
{
@@ -222,6 +227,10 @@
{
return cmCTestUpdateHandler::e_SVN;
}
+ if ( stype.find("p4") != std::string::npos )
+ {
+ return cmCTestUpdateHandler::e_P4;
+ }
}
std::string sourceDirectory = this->GetOption("SourceDirectory");
cmCTestLog(this->CTest, DEBUG, "Check directory: "
@@ -333,10 +342,18 @@
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;
+ updateCommand = this->CTest->GetCTestConfiguration("P4Command");
+ if ( updateCommand.empty() )
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot find CVSCommand, SVNCommand, P4Command, or UpdateCommand key in the "
+ "DartConfiguration.tcl" << std::endl);
+ return -1;
+ }
+ else
+ {
+ updateType = e_P4;
+ }
}
else
{
@@ -375,6 +392,9 @@
case cmCTestUpdateHandler::e_SVN:
updateOptions = this->CTest->GetCTestConfiguration("SVNUpdateOptions");
break;
+ case cmCTestUpdateHandler::e_P4:
+ updateOptions = this->CTest->GetCTestConfiguration("P4UpdateOptions");
+ break;
}
}
@@ -404,6 +424,19 @@
case cmCTestUpdateHandler::e_SVN:
extra_update_opts += "-r \"{" + today_update_date +" +0000}\"";
break;
+ case cmCTestUpdateHandler::e_P4:
+ {
+ char p4_current_time[1024];
+ sprintf(p4_current_time, "@%04d/%02d/%02d:%02d:%02d:%02d",
+ t->tm_year + 1900,
+ t->tm_mon + 1,
+ t->tm_mday,
+ t->tm_hour,
+ t->tm_min,
+ t->tm_sec);
+ extra_update_opts += p4_current_time;
+ }
+ break;
}
}
@@ -421,6 +454,9 @@
case cmCTestUpdateHandler::e_SVN:
command = updateCommand + " cleanup";
break;
+ case cmCTestUpdateHandler::e_P4:
+ // TODO: P4 - for now just leave empty
+ break;
}
//
@@ -463,6 +499,9 @@
case cmCTestUpdateHandler::e_SVN:
command = updateCommand + " info";
break;
+ case cmCTestUpdateHandler::e_P4:
+ command = updateCommand + " changes -m 1 ...#have";
+ break;
}
// CVS variables
@@ -471,6 +510,9 @@
int svn_latest_revision = 0;
int svn_use_status = 0;
+ int p4_current_revision = 0;
+ int p4_latest_revision = 0;
+
//
// Get initial repository information if that is possible. With subversion,
// this will check the current revision.
@@ -513,6 +555,21 @@
}
}
break;
+ case cmCTestUpdateHandler::e_P4:
+ {
+ cmsys::RegularExpression current_revision_regex(
+ "Change ([0-9]+)");
+ if ( current_revision_regex.find(goutput.c_str()) )
+ {
+ std::string currentRevisionString
+ = current_revision_regex.match(1);
+ p4_current_revision = atoi(currentRevisionString.c_str());
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Old revision of repository is: " << p4_current_revision
+ << std::endl);
+ }
+ }
+ break;
}
}
else
@@ -576,6 +633,31 @@
res = res && res1;
ofs << " Total output of update: " << goutput.c_str() << std::endl;
}
+ break;
+ case cmCTestUpdateHandler::e_P4:
+ {
+ std::string partialOutput;
+ command = updateCommand + " " + updateOptions + " sync ..." + extra_update_opts;
+ ofs << "* Update repository: " << std::endl;
+ ofs << " Command: " << command.c_str() << std::endl;
+ bool res1 = this->CTest->RunCommand(command.c_str(), &partialOutput,
+ &errors,
+ &retVal, sourceDirectory, 0 /*this->TimeOut*/);
+ ofs << " Output: " << partialOutput.c_str() << std::endl;
+ ofs << " Errors: " << errors.c_str() << std::endl;
+ goutput = partialOutput;
+ command = updateCommand + " changes -m 1 -t ...#have";
+ ofs << "* Status repository: " << std::endl;
+ ofs << " Command: " << command.c_str() << std::endl;
+ res = this->CTest->RunCommand(command.c_str(), &partialOutput,
+ &errors, &retVal, sourceDirectory, 0 /*this->TimeOut*/);
+ ofs << " Output: " << partialOutput.c_str() << std::endl;
+ ofs << " Errors: " << errors.c_str() << std::endl;
+ goutput += partialOutput;
+ res = res && res1;
+ ofs << " Total output of update: " << goutput.c_str() << std::endl;
+ }
+ break;
}
if ( ofs )
{
@@ -628,12 +710,25 @@
cmsys::RegularExpression svn_latest_revision_regex(
"(Updated to|At) revision ([0-9]+)\\.");
+ // Perforce style regular expressions
+ cmsys::RegularExpression p4_status_line_regex(
+ "Change ([0-9]+) on ([0-9]+/[0-9]+/[0-9]+ [0-9]+:[0-9]+:[0-9]+) by ([^@]+)");
+ cmsys::RegularExpression p4_comment_line_regex("^\t(.*)$");
+ cmsys::RegularExpression p4_user_line_regex("^([^ ]+) <([^>]+)> \\(([^\\)]+)\\)");
+
cmsys::RegularExpression file_removed_line(
"cvs update: `(.*)' is no longer in the repository");
cmsys::RegularExpression file_update_line("([A-Z]) *(.*)");
std::string current_path = "<no-path>";
bool first_file = true;
+ // Perforce style regular expressions
+ if ( updateType == cmCTestUpdateHandler::e_P4 )
+ {
+ file_removed_line.compile("^([^#]+)#([0-9]+) - deleted");
+ file_update_line.compile("^(([^#]+))#([0-9]+) - (added|updating)");
+ }
+
cmCTestUpdateHandler::AuthorsToUpdatesMap authors_files_map;
int numUpdated = 0;
int numModiefied = 0;
@@ -664,6 +759,32 @@
<< std::endl);
}
}
+ // In perforce, get the latest revision
+ if ( updateType == cmCTestUpdateHandler::e_P4 )
+ {
+ for ( cc= 0; cc < lines.size(); cc ++ )
+ {
+ const char* line = lines[cc].c_str();
+ if ( p4_status_line_regex.find(line) )
+ {
+ p4_latest_revision = atoi(
+ p4_status_line_regex.match(1).c_str());
+ }
+ }
+ if ( p4_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: " << p4_latest_revision
+ << std::endl);
+ }
+ }
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (each . represents one updated file):"
@@ -728,6 +849,20 @@
svn_use_status = 1;
}
break;
+ case cmCTestUpdateHandler::e_P4:
+ if ( p4_latest_revision > 0 &&
+ p4_latest_revision > p4_current_revision )
+ {
+ cmOStringStream logCommandStream;
+ logCommandStream << updateCommand << " changes -L -t -m 2 "
+ << "\"" << file << "@" << p4_latest_revision << "\"";
+ logcommand = logCommandStream.str();
+ }
+ else
+ {
+ logcommand = updateCommand + " changes -m 1 -t \"" + file + "\"";
+ }
+ break;
}
cmCTestLog(this->CTest, DEBUG, "Do log: " << logcommand << std::endl);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -890,6 +1025,76 @@
}
}
}
+ else if ( updateType == cmCTestUpdateHandler::e_P4 )
+ {
+ bool have_first = false;
+ bool have_second = false;
+ bool done = false;
+ std::vector<cmStdString> ulines;
+ cmSystemTools::Split(output.c_str(), ulines);
+ for ( kk = 0; kk < ulines.size(); kk ++ )
+ {
+ const char* clp = ulines[kk].c_str();
+ if ( !done && p4_status_line_regex.find(clp) )
+ {
+ std::string command = updateCommand + " " + updateOptions + " users " + p4_status_line_regex.match(3);
+ ofs << "* Get user information for file: " << file << std::endl;
+ ofs << " Command: " << command.c_str() << std::endl;
+ res = this->CTest->RunCommand(command.c_str(), &output, &errors,
+ &retVal, sourceDirectory, 0 /*this->TimeOut*/);
+ ofs << " Output: " << output.c_str() << std::endl;
+ ofs << " Errors: " << errors.c_str() << std::endl;
+
+ if ( !have_first )
+ {
+ srevision1 = p4_status_line_regex.match(1);
+ sdate1 = p4_status_line_regex.match(2);
+ if ( p4_user_line_regex.find(output) )
+ {
+ semail1 = p4_user_line_regex.match(2);
+ sauthor1 = p4_user_line_regex.match(3);
+ }
+ else
+ {
+ sauthor1 = p4_status_line_regex.match(3);
+ }
+ have_first = true;
+ }
+ else if ( !have_second )
+ {
+ srevision2 = p4_status_line_regex.match(1);
+ sdate2 = p4_status_line_regex.match(2);
+ if ( p4_user_line_regex.find(output) )
+ {
+ semail2 = p4_user_line_regex.match(2);
+ sauthor2 = p4_user_line_regex.match(3);
+ }
+ else
+ {
+ sauthor2 = p4_status_line_regex.match(3);
+ }
+ have_second = true;
+ }
+ else
+ {
+ done = true;
+ }
+ }
+ else if ( !done && p4_comment_line_regex.find(clp) )
+ {
+ if ( have_first && !have_second )
+ {
+ comment1 += p4_comment_line_regex.match(1);
+ comment1 += "\n";
+ }
+ else if ( have_second && !done )
+ {
+ comment2 += p4_comment_line_regex.match(1);
+ comment2 += "\n";
+ }
+ }
+ }
+ }
if ( mod == 'M' )
{
comment1 = "Locally modified file\n";
@@ -1098,5 +1303,6 @@
<< goutput << std::endl);
return -1;
}
+ cmCTestLog(this->CTest, DEBUG, "Returning count = " << count << std::endl);
return count;
}
==== //Abingdon/Tools/src/cmake/cmake-2.4.6/Source/CTest/cmCTestUpdateHandler.h#1 - D:\Abingdon\Tools\src\cmake\cmake-2.4.6\Source\CTest\cmCTestUpdateHandler.h ====
@@ -46,6 +46,7 @@
e_UNKNOWN = 0,
e_CVS,
e_SVN,
+ e_P4,
e_LAST
};
|