2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2004-09-07 17:17:15 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2004-09-07 17:17:15 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2004-09-07 17:17:15 +04:00
|
|
|
|
|
|
|
#include "cmCTestUpdateHandler.h"
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCLocaleEnvironmentScope.h"
|
2004-09-07 17:17:15 +04:00
|
|
|
#include "cmCTest.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2004-09-07 17:17:15 +04:00
|
|
|
#include "cmGlobalGenerator.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmMakefile.h"
|
2004-10-22 23:44:54 +04:00
|
|
|
#include "cmVersion.h"
|
2005-02-16 21:28:47 +03:00
|
|
|
#include "cmXMLParser.h"
|
2015-05-24 01:33:24 +03:00
|
|
|
#include "cmXMLWriter.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmake.h"
|
2004-09-07 17:17:15 +04:00
|
|
|
|
2009-05-15 00:13:52 +04:00
|
|
|
#include "cmCTestBZR.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCTestCVS.h"
|
2009-04-22 17:19:06 +04:00
|
|
|
#include "cmCTestGIT.h"
|
2009-07-10 19:08:05 +04:00
|
|
|
#include "cmCTestHG.h"
|
2013-10-23 02:11:22 +04:00
|
|
|
#include "cmCTestP4.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCTestSVN.h"
|
|
|
|
#include "cmCTestVC.h"
|
2009-02-24 18:39:55 +03:00
|
|
|
|
|
|
|
#include <cmsys/auto_ptr.hxx>
|
|
|
|
|
2004-09-07 17:17:15 +04:00
|
|
|
//#include <cmsys/RegularExpression.hxx>
|
|
|
|
#include <cmsys/Process.h>
|
|
|
|
|
|
|
|
// used for sleep
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "windows.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <float.h>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
2004-09-07 17:17:15 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmCTestUpdateHandlerUpdateStrings[] = {
|
|
|
|
"Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4"
|
2005-06-17 21:04:56 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char* cmCTestUpdateHandlerUpdateToString(int type)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (type < cmCTestUpdateHandler::e_UNKNOWN ||
|
|
|
|
type >= cmCTestUpdateHandler::e_LAST) {
|
2005-06-17 21:04:56 +04:00
|
|
|
return cmCTestUpdateHandlerUpdateStrings[cmCTestUpdateHandler::e_UNKNOWN];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-17 21:04:56 +04:00
|
|
|
return cmCTestUpdateHandlerUpdateStrings[type];
|
|
|
|
}
|
|
|
|
|
2004-09-07 17:17:15 +04:00
|
|
|
cmCTestUpdateHandler::cmCTestUpdateHandler()
|
|
|
|
{
|
2005-06-17 21:04:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCTestUpdateHandler::Initialize()
|
|
|
|
{
|
2005-06-23 21:04:18 +04:00
|
|
|
this->Superclass::Initialize();
|
2009-02-24 17:09:43 +03:00
|
|
|
this->UpdateCommand = "";
|
|
|
|
this->UpdateType = e_CVS;
|
2004-09-07 17:17:15 +04:00
|
|
|
}
|
|
|
|
|
2005-02-16 21:28:47 +03:00
|
|
|
int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, "Determine update type from command: "
|
|
|
|
<< cmd << " and type: " << type << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
if (type && *type) {
|
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
|
|
|
"Type specified: " << type << std::endl, this->Quiet);
|
2005-02-16 21:28:47 +03:00
|
|
|
std::string stype = cmSystemTools::LowerCase(type);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (stype.find("cvs") != std::string::npos) {
|
2005-02-16 21:28:47 +03:00
|
|
|
return cmCTestUpdateHandler::e_CVS;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("svn") != std::string::npos) {
|
2005-02-16 21:28:47 +03:00
|
|
|
return cmCTestUpdateHandler::e_SVN;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("bzr") != std::string::npos) {
|
2009-05-15 00:13:52 +04:00
|
|
|
return cmCTestUpdateHandler::e_BZR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("git") != std::string::npos) {
|
2009-04-22 17:19:06 +04:00
|
|
|
return cmCTestUpdateHandler::e_GIT;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("hg") != std::string::npos) {
|
2009-07-10 19:08:05 +04:00
|
|
|
return cmCTestUpdateHandler::e_HG;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("p4") != std::string::npos) {
|
2013-10-23 02:11:22 +04:00
|
|
|
return cmCTestUpdateHandler::e_P4;
|
2005-02-16 21:28:47 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, DEBUG,
|
2015-02-17 19:45:46 +03:00
|
|
|
"Type not specified, check command: " << cmd << std::endl, this->Quiet);
|
2005-02-16 21:28:47 +03:00
|
|
|
std::string stype = cmSystemTools::LowerCase(cmd);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (stype.find("cvs") != std::string::npos) {
|
2005-02-16 21:28:47 +03:00
|
|
|
return cmCTestUpdateHandler::e_CVS;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("svn") != std::string::npos) {
|
2005-02-16 21:28:47 +03:00
|
|
|
return cmCTestUpdateHandler::e_SVN;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("bzr") != std::string::npos) {
|
2009-05-15 00:13:52 +04:00
|
|
|
return cmCTestUpdateHandler::e_BZR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("git") != std::string::npos) {
|
2009-04-22 17:19:06 +04:00
|
|
|
return cmCTestUpdateHandler::e_GIT;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("hg") != std::string::npos) {
|
2009-07-10 19:08:05 +04:00
|
|
|
return cmCTestUpdateHandler::e_HG;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (stype.find("p4") != std::string::npos) {
|
2013-10-23 02:11:22 +04:00
|
|
|
return cmCTestUpdateHandler::e_P4;
|
2005-02-16 21:28:47 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-17 21:04:56 +04:00
|
|
|
return cmCTestUpdateHandler::e_UNKNOWN;
|
2005-02-16 21:28:47 +03:00
|
|
|
}
|
2004-09-07 17:17:15 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// clearly it would be nice if this were broken up into a few smaller
|
|
|
|
// functions and commented...
|
2005-01-27 23:54:47 +03:00
|
|
|
int cmCTestUpdateHandler::ProcessHandler()
|
2004-09-07 17:17:15 +04:00
|
|
|
{
|
2009-01-06 22:58:30 +03:00
|
|
|
// Make sure VCS tool messages are in English so we can parse them.
|
2015-04-09 21:56:43 +03:00
|
|
|
cmCLocaleEnvironmentScope fixLocale;
|
2009-01-06 22:58:30 +03:00
|
|
|
static_cast<void>(fixLocale);
|
|
|
|
|
2005-02-16 21:28:47 +03:00
|
|
|
// Get source dir
|
2005-02-17 23:23:00 +03:00
|
|
|
const char* sourceDirectory = this->GetOption("SourceDirectory");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!sourceDirectory) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot find SourceDirectory key in the DartConfiguration.tcl"
|
|
|
|
<< std::endl);
|
2004-09-07 17:17:15 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-02-16 21:28:47 +03:00
|
|
|
|
2005-06-16 21:18:21 +04:00
|
|
|
cmGeneratedFileStream ofs;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CTest->GetShowOnly()) {
|
2005-06-23 21:04:18 +04:00
|
|
|
this->StartLogFile("Update", ofs);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-16 21:18:21 +04:00
|
|
|
|
2015-02-17 19:45:46 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Updating the repository: " << sourceDirectory
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
2005-02-16 21:28:47 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->SelectVCS()) {
|
2009-02-24 17:09:43 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-07 17:17:15 +04:00
|
|
|
|
2015-02-17 19:45:46 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Use "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmCTestUpdateHandlerUpdateToString(this->UpdateType)
|
|
|
|
<< " repository type" << std::endl;
|
|
|
|
, this->Quiet);
|
2005-06-17 21:04:56 +04:00
|
|
|
|
2009-02-24 18:39:55 +03:00
|
|
|
// Create an object to interact with the VCS tool.
|
|
|
|
cmsys::auto_ptr<cmCTestVC> vc;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->UpdateType) {
|
|
|
|
case e_CVS:
|
|
|
|
vc.reset(new cmCTestCVS(this->CTest, ofs));
|
|
|
|
break;
|
|
|
|
case e_SVN:
|
|
|
|
vc.reset(new cmCTestSVN(this->CTest, ofs));
|
|
|
|
break;
|
|
|
|
case e_BZR:
|
|
|
|
vc.reset(new cmCTestBZR(this->CTest, ofs));
|
|
|
|
break;
|
|
|
|
case e_GIT:
|
|
|
|
vc.reset(new cmCTestGIT(this->CTest, ofs));
|
|
|
|
break;
|
|
|
|
case e_HG:
|
|
|
|
vc.reset(new cmCTestHG(this->CTest, ofs));
|
|
|
|
break;
|
|
|
|
case e_P4:
|
|
|
|
vc.reset(new cmCTestP4(this->CTest, ofs));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vc.reset(new cmCTestVC(this->CTest, ofs));
|
|
|
|
break;
|
|
|
|
}
|
2009-02-24 18:39:55 +03:00
|
|
|
vc->SetCommandLineTool(this->UpdateCommand);
|
|
|
|
vc->SetSourceDirectory(sourceDirectory);
|
|
|
|
|
2009-02-24 20:50:15 +03:00
|
|
|
// Cleanup the working tree.
|
|
|
|
vc->Cleanup();
|
|
|
|
|
2005-04-24 21:57:11 +04:00
|
|
|
//
|
|
|
|
// Now update repository and remember what files were updated
|
2006-03-10 23:03:09 +03:00
|
|
|
//
|
|
|
|
cmGeneratedFileStream os;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->StartResultingXML(cmCTest::PartUpdate, "Update", os)) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open log file"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2007-08-04 00:42:47 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
std::string start_time = this->CTest->CurrentTime();
|
2008-02-01 00:38:45 +03:00
|
|
|
unsigned int start_time_time =
|
|
|
|
static_cast<unsigned int>(cmSystemTools::GetTime());
|
2004-09-07 17:17:15 +04:00
|
|
|
double elapsed_time_start = cmSystemTools::GetTime();
|
|
|
|
|
2009-02-25 22:42:45 +03:00
|
|
|
bool updated = vc->Update();
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string buildname =
|
|
|
|
cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
|
2005-02-16 21:28:47 +03:00
|
|
|
|
2015-05-24 01:33:24 +03:00
|
|
|
cmXMLWriter xml(os);
|
|
|
|
xml.StartDocument();
|
|
|
|
xml.StartElement("Update");
|
|
|
|
xml.Attribute("mode", "Client");
|
|
|
|
xml.Attribute("Generator",
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string("ctest-") + cmVersion::GetCMakeVersion());
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.Element("Site", this->CTest->GetCTestConfiguration("Site"));
|
|
|
|
xml.Element("BuildName", buildname);
|
|
|
|
xml.Element("BuildStamp", this->CTest->GetCurrentTag() + "-" +
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CTest->GetTestModelString());
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.Element("StartDateTime", start_time);
|
|
|
|
xml.Element("StartTime", start_time_time);
|
|
|
|
xml.Element("UpdateCommand", vc->GetUpdateCommandLine());
|
|
|
|
xml.Element("UpdateType",
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestUpdateHandlerUpdateToString(this->UpdateType));
|
2015-05-24 01:33:24 +03:00
|
|
|
|
|
|
|
vc->WriteXML(xml);
|
2005-02-16 21:28:47 +03:00
|
|
|
|
2009-02-25 22:42:45 +03:00
|
|
|
int localModifications = 0;
|
2009-03-20 21:19:56 +03:00
|
|
|
int numUpdated = vc->GetPathCount(cmCTestVC::PathUpdated);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (numUpdated) {
|
2015-02-17 19:45:46 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Found " << numUpdated << " updated files\n",
|
|
|
|
this->Quiet);
|
|
|
|
}
|
|
|
|
if (int numModified = vc->GetPathCount(cmCTestVC::PathModified)) {
|
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Found "
|
|
|
|
<< numModified << " locally modified files\n",
|
|
|
|
this->Quiet);
|
2009-02-25 22:42:45 +03:00
|
|
|
localModifications += numModified;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (int numConflicting = vc->GetPathCount(cmCTestVC::PathConflicting)) {
|
2015-02-17 19:45:46 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Found " << numConflicting << " conflicting files\n",
|
|
|
|
this->Quiet);
|
2009-02-25 22:42:45 +03:00
|
|
|
localModifications += numConflicting;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-07 17:17:15 +04:00
|
|
|
|
2015-02-17 19:45:46 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, "End" << std::endl, this->Quiet);
|
2006-03-10 23:03:09 +03:00
|
|
|
std::string end_time = this->CTest->CurrentTime();
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.Element("EndDateTime", end_time);
|
|
|
|
xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
|
2016-05-16 17:34:04 +03:00
|
|
|
xml.Element(
|
|
|
|
"ElapsedMinutes",
|
|
|
|
static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
|
|
|
|
10.0);
|
2015-05-24 01:33:24 +03:00
|
|
|
|
|
|
|
xml.StartElement("UpdateReturnStatus");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (localModifications) {
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.Content("Update error: "
|
2016-05-16 17:34:04 +03:00
|
|
|
"There are modified or conflicting files in the repository");
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
" There are modified or conflicting files in the repository"
|
|
|
|
<< std::endl);
|
|
|
|
}
|
|
|
|
if (!updated) {
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.Content("Update command failed:\n");
|
|
|
|
xml.Content(vc->GetUpdateCommandLine());
|
2015-06-11 16:00:01 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Update command failed: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< vc->GetUpdateCommandLine() << "\n");
|
|
|
|
}
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.EndElement(); // UpdateReturnStatus
|
|
|
|
xml.EndElement(); // Update
|
|
|
|
xml.EndDocument();
|
2016-05-16 17:34:04 +03:00
|
|
|
return updated ? numUpdated : -1;
|
2004-09-07 17:17:15 +04:00
|
|
|
}
|
2009-02-24 17:09:14 +03:00
|
|
|
|
2009-02-24 17:09:43 +03:00
|
|
|
int cmCTestUpdateHandler::DetectVCS(const char* dir)
|
|
|
|
{
|
|
|
|
std::string sourceDirectory = dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
|
|
|
"Check directory: " << sourceDirectory << std::endl,
|
|
|
|
this->Quiet);
|
2009-02-24 17:09:43 +03:00
|
|
|
sourceDirectory += "/.svn";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
|
2009-02-24 17:09:43 +03:00
|
|
|
return cmCTestUpdateHandler::e_SVN;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-24 17:09:43 +03:00
|
|
|
sourceDirectory = dir;
|
|
|
|
sourceDirectory += "/CVS";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
|
2009-02-24 17:09:43 +03:00
|
|
|
return cmCTestUpdateHandler::e_CVS;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-04-22 17:19:06 +04:00
|
|
|
sourceDirectory = dir;
|
2009-05-15 00:13:52 +04:00
|
|
|
sourceDirectory += "/.bzr";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
|
2009-05-15 00:13:52 +04:00
|
|
|
return cmCTestUpdateHandler::e_BZR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-05-15 00:13:52 +04:00
|
|
|
sourceDirectory = dir;
|
2009-04-22 17:19:06 +04:00
|
|
|
sourceDirectory += "/.git";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
|
2009-04-22 17:19:06 +04:00
|
|
|
return cmCTestUpdateHandler::e_GIT;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-07-10 19:08:05 +04:00
|
|
|
sourceDirectory = dir;
|
|
|
|
sourceDirectory += "/.hg";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
|
2009-07-10 19:08:05 +04:00
|
|
|
return cmCTestUpdateHandler::e_HG;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-10-23 02:11:22 +04:00
|
|
|
sourceDirectory = dir;
|
|
|
|
sourceDirectory += "/.p4";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
|
2013-10-23 02:11:22 +04:00
|
|
|
return cmCTestUpdateHandler::e_P4;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-10-23 02:11:22 +04:00
|
|
|
sourceDirectory = dir;
|
|
|
|
sourceDirectory += "/.p4config";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
|
2013-10-23 02:11:22 +04:00
|
|
|
return cmCTestUpdateHandler::e_P4;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-24 17:09:43 +03:00
|
|
|
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"));
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->UpdateType == e_UNKNOWN) {
|
2009-02-24 17:09:43 +03:00
|
|
|
// The source tree does not have a recognized VCS. Check the
|
|
|
|
// configuration value or command name.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->UpdateType = this->DetermineType(
|
|
|
|
this->UpdateCommand.c_str(),
|
2009-02-24 17:09:43 +03:00
|
|
|
this->CTest->GetCTestConfiguration("UpdateType").c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-24 17:09:43 +03:00
|
|
|
|
|
|
|
// If no update command was specified, lookup one for this VCS tool.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->UpdateCommand.empty()) {
|
2009-02-24 17:09:43 +03:00
|
|
|
const char* key = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->UpdateType) {
|
|
|
|
case e_CVS:
|
|
|
|
key = "CVSCommand";
|
|
|
|
break;
|
|
|
|
case e_SVN:
|
|
|
|
key = "SVNCommand";
|
|
|
|
break;
|
|
|
|
case e_BZR:
|
|
|
|
key = "BZRCommand";
|
|
|
|
break;
|
|
|
|
case e_GIT:
|
|
|
|
key = "GITCommand";
|
|
|
|
break;
|
|
|
|
case e_HG:
|
|
|
|
key = "HGCommand";
|
|
|
|
break;
|
|
|
|
case e_P4:
|
|
|
|
key = "P4Command";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (key) {
|
2009-02-24 17:09:43 +03:00
|
|
|
this->UpdateCommand = this->CTest->GetCTestConfiguration(key);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->UpdateCommand.empty()) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2009-02-24 17:09:43 +03:00
|
|
|
e << "Cannot find UpdateCommand ";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (key) {
|
2009-02-24 17:09:43 +03:00
|
|
|
e << "or " << key;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-24 17:09:43 +03:00
|
|
|
e << " configuration key.";
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, e.str() << std::endl);
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-24 17:09:43 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|