2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc.
|
2009-02-24 18:39:55 +03: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.
|
2009-02-24 18:39:55 +03: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.
|
|
|
|
============================================================================*/
|
2009-02-24 18:39:55 +03:00
|
|
|
#include "cmCTestSVN.h"
|
|
|
|
|
2009-02-24 20:52:36 +03:00
|
|
|
#include "cmCTest.h"
|
2009-02-25 22:42:45 +03:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmXMLParser.h"
|
2015-05-24 01:33:24 +03:00
|
|
|
#include "cmXMLWriter.h"
|
2009-02-24 20:52:36 +03:00
|
|
|
|
|
|
|
#include <cmsys/RegularExpression.hxx>
|
|
|
|
|
2012-08-24 12:30:09 +04:00
|
|
|
struct cmCTestSVN::Revision: public cmCTestVC::Revision
|
|
|
|
{
|
|
|
|
cmCTestSVN::SVNInfo* SVNInfo;
|
|
|
|
};
|
|
|
|
|
2009-02-24 18:39:55 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2009-04-22 17:18:19 +04:00
|
|
|
cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log):
|
|
|
|
cmCTestGlobalVC(ct, log)
|
2009-02-24 18:39:55 +03:00
|
|
|
{
|
2009-02-25 22:42:45 +03:00
|
|
|
this->PriorRev = this->Unknown;
|
2009-02-24 18:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmCTestSVN::~cmCTestSVN()
|
|
|
|
{
|
|
|
|
}
|
2009-02-24 20:50:15 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmCTestSVN::CleanupImpl()
|
|
|
|
{
|
2012-09-23 21:55:48 +04:00
|
|
|
std::vector<const char*> svn_cleanup;
|
|
|
|
svn_cleanup.push_back("cleanup");
|
2009-02-24 20:50:15 +03:00
|
|
|
OutputLogger out(this->Log, "cleanup-out> ");
|
|
|
|
OutputLogger err(this->Log, "cleanup-err> ");
|
2012-09-23 21:55:48 +04:00
|
|
|
this->RunSVNCommand(svn_cleanup, &out, &err);
|
2009-02-24 20:50:15 +03:00
|
|
|
}
|
2009-02-24 20:52:36 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class cmCTestSVN::InfoParser: public cmCTestVC::LineParser
|
|
|
|
{
|
|
|
|
public:
|
2012-09-03 12:50:07 +04:00
|
|
|
InfoParser(cmCTestSVN* svn,
|
|
|
|
const char* prefix,
|
|
|
|
std::string& rev,
|
|
|
|
SVNInfo& svninfo):
|
|
|
|
Rev(rev), SVNRepo(svninfo)
|
2009-02-24 20:52:36 +03:00
|
|
|
{
|
|
|
|
this->SetLog(&svn->Log, prefix);
|
|
|
|
this->RegexRev.compile("^Revision: ([0-9]+)");
|
2009-02-24 23:43:25 +03:00
|
|
|
this->RegexURL.compile("^URL: +([^ ]+) *$");
|
|
|
|
this->RegexRoot.compile("^Repository Root: +([^ ]+) *$");
|
2009-02-24 20:52:36 +03:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
std::string& Rev;
|
2012-09-03 12:50:07 +04:00
|
|
|
cmCTestSVN::SVNInfo& SVNRepo;
|
2009-02-24 20:52:36 +03:00
|
|
|
cmsys::RegularExpression RegexRev;
|
2009-02-24 23:43:25 +03:00
|
|
|
cmsys::RegularExpression RegexURL;
|
|
|
|
cmsys::RegularExpression RegexRoot;
|
2009-02-24 20:52:36 +03:00
|
|
|
virtual bool ProcessLine()
|
|
|
|
{
|
|
|
|
if(this->RegexRev.find(this->Line))
|
|
|
|
{
|
|
|
|
this->Rev = this->RegexRev.match(1);
|
|
|
|
}
|
2009-02-24 23:43:25 +03:00
|
|
|
else if(this->RegexURL.find(this->Line))
|
|
|
|
{
|
2012-09-03 12:50:07 +04:00
|
|
|
this->SVNRepo.URL = this->RegexURL.match(1);
|
2009-02-24 23:43:25 +03:00
|
|
|
}
|
|
|
|
else if(this->RegexRoot.find(this->Line))
|
|
|
|
{
|
2012-09-03 12:50:07 +04:00
|
|
|
this->SVNRepo.Root = this->RegexRoot.match(1);
|
2009-02-24 23:43:25 +03:00
|
|
|
}
|
2009-02-24 20:52:36 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-02-24 23:43:25 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static bool cmCTestSVNPathStarts(std::string const& p1, std::string const& p2)
|
|
|
|
{
|
|
|
|
// Does path p1 start with path p2?
|
|
|
|
if(p1.size() == p2.size())
|
|
|
|
{
|
|
|
|
return p1 == p2;
|
|
|
|
}
|
|
|
|
else if(p1.size() > p2.size() && p1[p2.size()] == '/')
|
|
|
|
{
|
|
|
|
return strncmp(p1.c_str(), p2.c_str(), p2.size()) == 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-24 20:52:36 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2012-09-03 12:50:07 +04:00
|
|
|
std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo)
|
2009-02-24 20:52:36 +03:00
|
|
|
{
|
|
|
|
// Run "svn info" to get the repository info from the work tree.
|
2012-09-23 21:55:48 +04:00
|
|
|
std::vector<const char*> svn_info;
|
|
|
|
svn_info.push_back("info");
|
|
|
|
svn_info.push_back(svninfo.LocalPath.c_str());
|
2009-02-24 20:52:36 +03:00
|
|
|
std::string rev;
|
2012-09-03 12:50:07 +04:00
|
|
|
InfoParser out(this, "info-out> ", rev, svninfo);
|
2009-02-24 20:52:36 +03:00
|
|
|
OutputLogger err(this->Log, "info-err> ");
|
2012-09-23 21:55:48 +04:00
|
|
|
this->RunSVNCommand(svn_info, &out, &err);
|
2009-02-24 20:52:36 +03:00
|
|
|
return rev;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmCTestSVN::NoteOldRevision()
|
|
|
|
{
|
2012-08-24 12:48:57 +04:00
|
|
|
// Info for root repository
|
|
|
|
this->Repositories.push_back( SVNInfo("") );
|
|
|
|
this->RootInfo = &(this->Repositories.back());
|
2012-09-03 13:10:53 +04:00
|
|
|
// Info for the external repositories
|
|
|
|
this->LoadExternals();
|
2012-09-03 12:50:07 +04:00
|
|
|
|
2012-09-03 13:10:53 +04:00
|
|
|
// Get info for all the repositories
|
|
|
|
std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
|
|
|
|
std::list<SVNInfo>::iterator itend = this->Repositories.end();
|
|
|
|
for( ; itbeg != itend ; itbeg++)
|
|
|
|
{
|
|
|
|
SVNInfo& svninfo = *itbeg;
|
2012-09-03 12:50:07 +04:00
|
|
|
svninfo.OldRevision = this->LoadInfo(svninfo);
|
|
|
|
this->Log << "Revision for repository '" << svninfo.LocalPath
|
|
|
|
<< "' before update: " << svninfo.OldRevision << "\n";
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Old revision of external repository '"
|
|
|
|
<< svninfo.LocalPath << "' is: "
|
|
|
|
<< svninfo.OldRevision << "\n");
|
2012-09-03 13:10:53 +04:00
|
|
|
}
|
2012-09-03 12:50:07 +04:00
|
|
|
|
|
|
|
// Set the global old revision to the one of the root
|
|
|
|
this->OldRevision = this->RootInfo->OldRevision;
|
2009-02-25 22:42:45 +03:00
|
|
|
this->PriorRev.Rev = this->OldRevision;
|
2009-02-24 20:52:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmCTestSVN::NoteNewRevision()
|
|
|
|
{
|
2012-09-03 13:10:53 +04:00
|
|
|
// Get info for the external repositories
|
|
|
|
std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
|
|
|
|
std::list<SVNInfo>::iterator itend = this->Repositories.end();
|
|
|
|
for( ; itbeg != itend ; itbeg++)
|
|
|
|
{
|
|
|
|
SVNInfo& svninfo = *itbeg;
|
2012-09-03 12:50:07 +04:00
|
|
|
svninfo.NewRevision = this->LoadInfo(svninfo);
|
|
|
|
this->Log << "Revision for repository '" << svninfo.LocalPath
|
|
|
|
<< "' after update: " << svninfo.NewRevision << "\n";
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" New revision of external repository '"
|
|
|
|
<< svninfo.LocalPath << "' is: "
|
|
|
|
<< svninfo.NewRevision << "\n");
|
|
|
|
|
|
|
|
// svninfo.Root = ""; // uncomment to test GuessBase
|
|
|
|
this->Log << "Repository '" << svninfo.LocalPath
|
|
|
|
<< "' URL = " << svninfo.URL << "\n";
|
|
|
|
this->Log << "Repository '" << svninfo.LocalPath
|
|
|
|
<< "' Root = " << svninfo.Root << "\n";
|
|
|
|
|
|
|
|
// Compute the base path the working tree has checked out under
|
|
|
|
// the repository root.
|
|
|
|
if(!svninfo.Root.empty()
|
|
|
|
&& cmCTestSVNPathStarts(svninfo.URL, svninfo.Root))
|
|
|
|
{
|
|
|
|
svninfo.Base = cmCTest::DecodeURL(
|
|
|
|
svninfo.URL.substr(svninfo.Root.size()));
|
|
|
|
svninfo.Base += "/";
|
|
|
|
}
|
|
|
|
this->Log << "Repository '" << svninfo.LocalPath
|
|
|
|
<< "' Base = " << svninfo.Base << "\n";
|
|
|
|
|
2012-09-03 13:10:53 +04:00
|
|
|
}
|
|
|
|
|
2012-09-03 12:50:07 +04:00
|
|
|
// Set the global new revision to the one of the root
|
|
|
|
this->NewRevision = this->RootInfo->NewRevision;
|
2009-02-24 20:52:36 +03:00
|
|
|
}
|
2009-02-25 22:42:45 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2012-09-03 12:50:07 +04:00
|
|
|
void cmCTestSVN::GuessBase(SVNInfo& svninfo,
|
|
|
|
std::vector<Change> const& changes)
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
// Subversion did not give us a good repository root so we need to
|
|
|
|
// guess the base path from the URL and the paths in a revision with
|
|
|
|
// changes under it.
|
|
|
|
|
|
|
|
// Consider each possible URL suffix from longest to shortest.
|
2012-09-03 12:50:07 +04:00
|
|
|
for(std::string::size_type slash = svninfo.URL.find('/');
|
|
|
|
svninfo.Base.empty() && slash != std::string::npos;
|
|
|
|
slash = svninfo.URL.find('/', slash+1))
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
// If the URL suffix is a prefix of at least one path then it is the base.
|
2012-09-03 12:50:07 +04:00
|
|
|
std::string base = cmCTest::DecodeURL(svninfo.URL.substr(slash));
|
2009-02-25 22:42:45 +03:00
|
|
|
for(std::vector<Change>::const_iterator ci = changes.begin();
|
2012-09-03 12:50:07 +04:00
|
|
|
svninfo.Base.empty() && ci != changes.end(); ++ci)
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
if(cmCTestSVNPathStarts(ci->Path, base))
|
|
|
|
{
|
2012-09-03 12:50:07 +04:00
|
|
|
svninfo.Base = base;
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We always append a slash so that we know paths beginning in the
|
|
|
|
// base lie under its path. If no base was found then the working
|
|
|
|
// tree must be a checkout of the entire repo and this will match
|
|
|
|
// the leading slash in all paths.
|
2012-09-03 12:50:07 +04:00
|
|
|
svninfo.Base += "/";
|
2009-02-25 22:42:45 +03:00
|
|
|
|
2012-09-03 12:50:07 +04:00
|
|
|
this->Log << "Guessed Base = " << svninfo.Base << "\n";
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class cmCTestSVN::UpdateParser: public cmCTestVC::LineParser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UpdateParser(cmCTestSVN* svn, const char* prefix): SVN(svn)
|
|
|
|
{
|
|
|
|
this->SetLog(&svn->Log, prefix);
|
|
|
|
this->RegexUpdate.compile("^([ADUCGE ])([ADUCGE ])[B ] +(.+)$");
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
cmCTestSVN* SVN;
|
|
|
|
cmsys::RegularExpression RegexUpdate;
|
|
|
|
|
|
|
|
bool ProcessLine()
|
|
|
|
{
|
|
|
|
if(this->RegexUpdate.find(this->Line))
|
|
|
|
{
|
|
|
|
this->DoPath(this->RegexUpdate.match(1)[0],
|
|
|
|
this->RegexUpdate.match(2)[0],
|
|
|
|
this->RegexUpdate.match(3));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoPath(char path_status, char prop_status, std::string const& path)
|
|
|
|
{
|
|
|
|
char status = (path_status != ' ')? path_status : prop_status;
|
|
|
|
std::string dir = cmSystemTools::GetFilenamePath(path);
|
|
|
|
std::string name = cmSystemTools::GetFilenameName(path);
|
|
|
|
// See "svn help update".
|
|
|
|
switch(status)
|
|
|
|
{
|
|
|
|
case 'G':
|
|
|
|
this->SVN->Dirs[dir][name].Status = PathModified;
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
this->SVN->Dirs[dir][name].Status = PathConflicting;
|
|
|
|
break;
|
|
|
|
case 'A': case 'D': case 'U':
|
|
|
|
this->SVN->Dirs[dir][name].Status = PathUpdated;
|
|
|
|
break;
|
|
|
|
case 'E': // TODO?
|
|
|
|
case '?': case ' ': default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmCTestSVN::UpdateImpl()
|
|
|
|
{
|
|
|
|
// Get user-specified update options.
|
|
|
|
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
|
|
|
|
if(opts.empty())
|
|
|
|
{
|
|
|
|
opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions");
|
|
|
|
}
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
|
2009-02-25 22:42:45 +03:00
|
|
|
|
|
|
|
// Specify the start time for nightly testing.
|
|
|
|
if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
|
|
|
|
{
|
|
|
|
args.push_back("-r{" + this->GetNightlyTime() + " +0000}");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<char const*> svn_update;
|
|
|
|
svn_update.push_back("update");
|
2014-02-10 09:21:34 +04:00
|
|
|
for(std::vector<std::string>::const_iterator ai = args.begin();
|
2009-02-25 22:42:45 +03:00
|
|
|
ai != args.end(); ++ai)
|
|
|
|
{
|
|
|
|
svn_update.push_back(ai->c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateParser out(this, "up-out> ");
|
|
|
|
OutputLogger err(this->Log, "up-err> ");
|
2012-09-23 21:55:48 +04:00
|
|
|
return this->RunSVNCommand(svn_update, &out, &err);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
|
|
|
|
OutputParser* out, OutputParser* err)
|
|
|
|
{
|
|
|
|
if(parameters.empty()) return false;
|
|
|
|
|
|
|
|
std::vector<char const*> args;
|
|
|
|
args.push_back(this->CommandLineTool.c_str());
|
|
|
|
|
|
|
|
args.insert(args.end(), parameters.begin(), parameters.end());
|
|
|
|
|
|
|
|
args.push_back("--non-interactive");
|
|
|
|
|
|
|
|
std::string userOptions =
|
|
|
|
this->CTest->GetCTestConfiguration("SVNOptions");
|
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> parsedUserOptions =
|
2012-09-23 21:55:48 +04:00
|
|
|
cmSystemTools::ParseArguments(userOptions.c_str());
|
2014-02-10 09:21:34 +04:00
|
|
|
for(std::vector<std::string>::iterator i = parsedUserOptions.begin();
|
2012-09-23 21:55:48 +04:00
|
|
|
i != parsedUserOptions.end(); ++i)
|
|
|
|
{
|
|
|
|
args.push_back(i->c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
args.push_back(0);
|
|
|
|
|
|
|
|
if(strcmp(parameters[0], "update") == 0)
|
|
|
|
{
|
|
|
|
return RunUpdateCommand(&args[0], out, err);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return RunChild(&args[0], out, err);
|
|
|
|
}
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2009-02-25 23:45:14 +03:00
|
|
|
class cmCTestSVN::LogParser: public cmCTestVC::OutputLogger,
|
|
|
|
private cmXMLParser
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
public:
|
2012-09-03 12:50:07 +04:00
|
|
|
LogParser(cmCTestSVN* svn, const char* prefix, SVNInfo& svninfo):
|
|
|
|
OutputLogger(svn->Log, prefix), SVN(svn), SVNRepo(svninfo)
|
|
|
|
{ this->InitializeParser(); }
|
2009-02-25 22:42:45 +03:00
|
|
|
~LogParser() { this->CleanupParser(); }
|
|
|
|
private:
|
|
|
|
cmCTestSVN* SVN;
|
2012-09-03 12:50:07 +04:00
|
|
|
cmCTestSVN::SVNInfo& SVNRepo;
|
2009-02-25 22:42:45 +03:00
|
|
|
|
|
|
|
typedef cmCTestSVN::Revision Revision;
|
|
|
|
typedef cmCTestSVN::Change Change;
|
|
|
|
Revision Rev;
|
|
|
|
std::vector<Change> Changes;
|
|
|
|
Change CurChange;
|
|
|
|
std::vector<char> CData;
|
|
|
|
|
|
|
|
virtual bool ProcessChunk(const char* data, int length)
|
|
|
|
{
|
|
|
|
this->OutputLogger::ProcessChunk(data, length);
|
|
|
|
this->ParseChunk(data, length);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-22 04:05:55 +04:00
|
|
|
virtual void StartElement(const std::string& name, const char** atts)
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
this->CData.clear();
|
2014-02-22 04:05:55 +04:00
|
|
|
if(name == "logentry")
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
this->Rev = Revision();
|
2012-09-03 12:50:07 +04:00
|
|
|
this->Rev.SVNInfo = &SVNRepo;
|
2009-02-25 22:42:45 +03:00
|
|
|
if(const char* rev = this->FindAttribute(atts, "revision"))
|
|
|
|
{
|
|
|
|
this->Rev.Rev = rev;
|
|
|
|
}
|
|
|
|
this->Changes.clear();
|
|
|
|
}
|
2014-02-22 04:05:55 +04:00
|
|
|
else if(name == "path")
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
this->CurChange = Change();
|
|
|
|
if(const char* action = this->FindAttribute(atts, "action"))
|
|
|
|
{
|
|
|
|
this->CurChange.Action = action[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void CharacterDataHandler(const char* data, int length)
|
|
|
|
{
|
|
|
|
this->CData.insert(this->CData.end(), data, data+length);
|
|
|
|
}
|
|
|
|
|
2014-02-22 04:05:55 +04:00
|
|
|
virtual void EndElement(const std::string& name)
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
2014-02-22 04:05:55 +04:00
|
|
|
if(name == "logentry")
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
2012-08-24 12:30:09 +04:00
|
|
|
this->SVN->DoRevisionSVN(this->Rev, this->Changes);
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
2014-02-22 04:05:55 +04:00
|
|
|
else if(!this->CData.empty() && name == "path")
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
2012-09-03 12:50:07 +04:00
|
|
|
std::string orig_path(&this->CData[0], this->CData.size());
|
|
|
|
std::string new_path = SVNRepo.BuildLocalPath( orig_path );
|
|
|
|
this->CurChange.Path.assign(new_path);
|
2009-02-25 22:42:45 +03:00
|
|
|
this->Changes.push_back(this->CurChange);
|
|
|
|
}
|
2014-02-22 04:05:55 +04:00
|
|
|
else if(!this->CData.empty() && name == "author")
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
this->Rev.Author.assign(&this->CData[0], this->CData.size());
|
|
|
|
}
|
2014-02-22 04:05:55 +04:00
|
|
|
else if(!this->CData.empty() && name == "date")
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
this->Rev.Date.assign(&this->CData[0], this->CData.size());
|
|
|
|
}
|
2014-02-22 04:05:55 +04:00
|
|
|
else if(!this->CData.empty() && name == "msg")
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
this->Rev.Log.assign(&this->CData[0], this->CData.size());
|
|
|
|
}
|
|
|
|
this->CData.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ReportError(int, int, const char* msg)
|
|
|
|
{
|
|
|
|
this->SVN->Log << "Error parsing svn log xml: " << msg << "\n";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmCTestSVN::LoadRevisions()
|
2012-09-03 12:50:07 +04:00
|
|
|
{
|
2012-09-03 13:10:53 +04:00
|
|
|
// Get revisions for all the external repositories
|
|
|
|
std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
|
|
|
|
std::list<SVNInfo>::iterator itend = this->Repositories.end();
|
|
|
|
for( ; itbeg != itend ; itbeg++)
|
|
|
|
{
|
|
|
|
SVNInfo& svninfo = *itbeg;
|
2012-09-03 12:50:07 +04:00
|
|
|
LoadRevisions(svninfo);
|
2012-09-03 13:10:53 +04:00
|
|
|
}
|
2012-09-03 12:50:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmCTestSVN::LoadRevisions(SVNInfo &svninfo)
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
// We are interested in every revision included in the update.
|
|
|
|
std::string revs;
|
2012-09-03 12:50:07 +04:00
|
|
|
if(atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str()))
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
2012-09-03 12:50:07 +04:00
|
|
|
revs = "-r" + svninfo.OldRevision + ":" + svninfo.NewRevision;
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-03 12:50:07 +04:00
|
|
|
revs = "-r" + svninfo.NewRevision;
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run "svn log" to get all global revisions of interest.
|
2012-09-23 21:55:48 +04:00
|
|
|
std::vector<const char*> svn_log;
|
|
|
|
svn_log.push_back("log");
|
|
|
|
svn_log.push_back("--xml");
|
|
|
|
svn_log.push_back("-v");
|
|
|
|
svn_log.push_back(revs.c_str());
|
|
|
|
svn_log.push_back(svninfo.LocalPath.c_str());
|
2012-09-03 12:50:07 +04:00
|
|
|
LogParser out(this, "log-out> ", svninfo);
|
2009-02-25 22:42:45 +03:00
|
|
|
OutputLogger err(this->Log, "log-err> ");
|
2012-09-23 21:55:48 +04:00
|
|
|
this->RunSVNCommand(svn_log, &out, &err);
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2012-08-24 12:30:09 +04:00
|
|
|
void cmCTestSVN::DoRevisionSVN(Revision const& revision,
|
|
|
|
std::vector<Change> const& changes)
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
|
|
|
// Guess the base checkout path from the changes if necessary.
|
2012-09-03 12:50:07 +04:00
|
|
|
if(this->RootInfo->Base.empty() && !changes.empty())
|
2009-02-25 22:42:45 +03:00
|
|
|
{
|
2012-09-03 12:50:07 +04:00
|
|
|
this->GuessBase(*this->RootInfo, changes);
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
2012-09-03 13:10:53 +04:00
|
|
|
|
|
|
|
// Ignore changes in the old revision for external repositories
|
|
|
|
if(revision.Rev == revision.SVNInfo->OldRevision
|
|
|
|
&& revision.SVNInfo->LocalPath != "")
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-22 17:18:19 +04:00
|
|
|
this->cmCTestGlobalVC::DoRevision(revision, changes);
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class cmCTestSVN::StatusParser: public cmCTestVC::LineParser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StatusParser(cmCTestSVN* svn, const char* prefix): SVN(svn)
|
|
|
|
{
|
|
|
|
this->SetLog(&svn->Log, prefix);
|
|
|
|
this->RegexStatus.compile("^([ACDIMRX?!~ ])([CM ])[ L]... +(.+)$");
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
cmCTestSVN* SVN;
|
|
|
|
cmsys::RegularExpression RegexStatus;
|
|
|
|
bool ProcessLine()
|
|
|
|
{
|
|
|
|
if(this->RegexStatus.find(this->Line))
|
|
|
|
{
|
|
|
|
this->DoPath(this->RegexStatus.match(1)[0],
|
|
|
|
this->RegexStatus.match(2)[0],
|
|
|
|
this->RegexStatus.match(3));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoPath(char path_status, char prop_status, std::string const& path)
|
|
|
|
{
|
|
|
|
char status = (path_status != ' ')? path_status : prop_status;
|
|
|
|
// See "svn help status".
|
|
|
|
switch(status)
|
|
|
|
{
|
2009-08-12 16:06:57 +04:00
|
|
|
case 'M': case '!': case 'A': case 'D': case 'R':
|
2009-04-22 17:18:19 +04:00
|
|
|
this->SVN->DoModification(PathModified, path);
|
2009-02-25 22:42:45 +03:00
|
|
|
break;
|
|
|
|
case 'C': case '~':
|
2009-04-22 17:18:19 +04:00
|
|
|
this->SVN->DoModification(PathConflicting, path);
|
2009-02-25 22:42:45 +03:00
|
|
|
break;
|
2009-08-12 16:06:57 +04:00
|
|
|
case 'X': case 'I': case '?': case ' ': default:
|
2009-02-25 22:42:45 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmCTestSVN::LoadModifications()
|
|
|
|
{
|
|
|
|
// Run "svn status" which reports local modifications.
|
2012-09-23 21:55:48 +04:00
|
|
|
std::vector<const char*> svn_status;
|
|
|
|
svn_status.push_back("status");
|
2009-02-25 22:42:45 +03:00
|
|
|
StatusParser out(this, "status-out> ");
|
|
|
|
OutputLogger err(this->Log, "status-err> ");
|
2012-09-23 21:55:48 +04:00
|
|
|
this->RunSVNCommand(svn_status, &out, &err);
|
2009-02-25 22:42:45 +03:00
|
|
|
}
|
2009-12-18 16:19:41 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2015-05-24 01:33:24 +03:00
|
|
|
void cmCTestSVN::WriteXMLGlobal(cmXMLWriter& xml)
|
2009-12-18 16:19:41 +03:00
|
|
|
{
|
|
|
|
this->cmCTestGlobalVC::WriteXMLGlobal(xml);
|
|
|
|
|
2015-05-24 01:33:24 +03:00
|
|
|
xml.Element("SVNPath", this->RootInfo->Base);
|
2009-12-18 16:19:41 +03:00
|
|
|
}
|
2012-09-03 12:45:05 +04:00
|
|
|
|
2012-09-03 13:03:43 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class cmCTestSVN::ExternalParser: public cmCTestVC::LineParser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ExternalParser(cmCTestSVN* svn, const char* prefix): SVN(svn)
|
|
|
|
{
|
|
|
|
this->SetLog(&svn->Log, prefix);
|
|
|
|
this->RegexExternal.compile("^X..... +(.+)$");
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
cmCTestSVN* SVN;
|
|
|
|
cmsys::RegularExpression RegexExternal;
|
|
|
|
bool ProcessLine()
|
|
|
|
{
|
|
|
|
if(this->RegexExternal.find(this->Line))
|
|
|
|
{
|
|
|
|
this->DoPath(this->RegexExternal.match(1));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoPath(std::string const& path)
|
|
|
|
{
|
|
|
|
// Get local path relative to the source directory
|
|
|
|
std::string local_path;
|
|
|
|
if(path.size() > this->SVN->SourceDirectory.size() &&
|
|
|
|
strncmp(path.c_str(), this->SVN->SourceDirectory.c_str(),
|
|
|
|
this->SVN->SourceDirectory.size()) == 0)
|
|
|
|
{
|
|
|
|
local_path = path.c_str() + this->SVN->SourceDirectory.size() + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
local_path = path;
|
|
|
|
}
|
|
|
|
this->SVN->Repositories.push_back( SVNInfo(local_path.c_str()) );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmCTestSVN::LoadExternals()
|
|
|
|
{
|
|
|
|
// Run "svn status" to get the list of external repositories
|
2012-09-23 21:55:48 +04:00
|
|
|
std::vector<const char*> svn_status;
|
|
|
|
svn_status.push_back("status");
|
2012-09-03 13:03:43 +04:00
|
|
|
ExternalParser out(this, "external-out> ");
|
|
|
|
OutputLogger err(this->Log, "external-err> ");
|
2012-09-23 21:55:48 +04:00
|
|
|
this->RunSVNCommand(svn_status, &out, &err);
|
2012-09-03 13:03:43 +04:00
|
|
|
}
|
|
|
|
|
2012-09-03 12:45:05 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmCTestSVN::SVNInfo::BuildLocalPath(std::string const& path) const
|
|
|
|
{
|
|
|
|
std::string local_path;
|
|
|
|
|
|
|
|
// Add local path prefix if not empty
|
|
|
|
if (!this->LocalPath.empty())
|
|
|
|
{
|
|
|
|
local_path += this->LocalPath;
|
|
|
|
local_path += "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add path with base prefix removed
|
|
|
|
if(path.size() > this->Base.size() &&
|
|
|
|
strncmp(path.c_str(), this->Base.c_str(), this->Base.size()) == 0)
|
|
|
|
{
|
|
|
|
local_path += (path.c_str() + this->Base.size());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
local_path += path;
|
|
|
|
}
|
|
|
|
|
|
|
|
return local_path;
|
|
|
|
}
|