[Cmake-commits] [cmake-commits] king committed cmCTestGlobalVC.cxx NONE 1.1 cmCTestGlobalVC.h NONE 1.1 cmCTestSVN.cxx 1.6 1.7 cmCTestSVN.h 1.5 1.6
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Apr 22 09:18:21 EDT 2009
Update of /cvsroot/CMake/CMake/Source/CTest
In directory public:/mounts/ram/cvs-serv16977/Source/CTest
Modified Files:
cmCTestSVN.cxx cmCTestSVN.h
Added Files:
cmCTestGlobalVC.cxx cmCTestGlobalVC.h
Log Message:
ENH: Factor global-VC parts out of cmCTestSVN
This factors parts of the svn update implementation that are useful for
any globally-versioning vcs tool into cmCTestGlobalVC. It will allow
the code to be shared among the support classes for most vcs tools.
--- NEW FILE: cmCTestGlobalVC.h ---
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile: cmCTestGlobalVC.h,v $
Language: C++
Date: $Date: 2009-04-22 13:18:19 $
Version: $Revision: 1.1 $
Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmCTestGlobalVC_h
#define cmCTestGlobalVC_h
#include "cmCTestVC.h"
/** \class cmCTestGlobalVC
* \brief Base class for handling globally-versioned trees
*
*/
class cmCTestGlobalVC: public cmCTestVC
{
public:
/** Construct with a CTest instance and update log stream. */
cmCTestGlobalVC(cmCTest* ctest, std::ostream& log);
virtual ~cmCTestGlobalVC();
protected:
// Implement cmCTestVC internal API.
virtual bool WriteXMLUpdates(std::ostream& xml);
/** Represent a vcs-reported action for one path in a revision. */
struct Change
{
char Action;
std::string Path;
Change(char a = '?'): Action(a) {}
};
// Update status for files in each directory.
class Directory: public std::map<cmStdString, File> {};
std::map<cmStdString, Directory> Dirs;
// Old and new repository revisions.
std::string OldRevision;
std::string NewRevision;
// Information known about old revision.
Revision PriorRev;
// Information about revisions from a svn log.
std::list<Revision> Revisions;
virtual const char* LocalPath(std::string const& path);
virtual void DoRevision(Revision const& revision,
std::vector<Change> const& changes);
virtual void DoModification(PathStatus status, std::string const& path);
virtual void LoadModifications() = 0;
virtual void LoadRevisions() = 0;
void WriteXMLDirectory(std::ostream& xml, std::string const& path,
Directory const& dir);
};
#endif
Index: cmCTestSVN.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestSVN.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C 2 -d -r1.5 -r1.6
*** cmCTestSVN.h 25 Feb 2009 19:42:45 -0000 1.5
--- cmCTestSVN.h 22 Apr 2009 13:18:19 -0000 1.6
***************
*** 18,22 ****
#define cmCTestSVN_h
! #include "cmCTestVC.h"
/** \class cmCTestSVN
--- 18,22 ----
#define cmCTestSVN_h
! #include "cmCTestGlobalVC.h"
/** \class cmCTestSVN
***************
*** 24,28 ****
*
*/
! class cmCTestSVN: public cmCTestVC
{
public:
--- 24,28 ----
*
*/
! class cmCTestSVN: public cmCTestGlobalVC
{
public:
***************
*** 38,58 ****
virtual void NoteNewRevision();
virtual bool UpdateImpl();
- virtual bool WriteXMLUpdates(std::ostream& xml);
-
- /** Represent a subversion-reported action for one path in a revision. */
- struct Change
- {
- char Action;
- std::string Path;
- Change(): Action('?') {}
- };
-
- // Update status for files in each directory.
- class Directory: public std::map<cmStdString, File> {};
- std::map<cmStdString, Directory> Dirs;
-
- // Old and new repository revisions.
- std::string OldRevision;
- std::string NewRevision;
// URL of repository directory checked out in the working tree.
--- 38,41 ----
***************
*** 65,74 ****
std::string Base;
- // Information known about old revision.
- Revision PriorRev;
-
- // Information about revisions from a svn log.
- std::list<Revision> Revisions;
-
std::string LoadInfo();
void LoadModifications();
--- 48,51 ----
***************
*** 80,85 ****
void DoRevision(Revision const& revision,
std::vector<Change> const& changes);
- void WriteXMLDirectory(std::ostream& xml, std::string const& path,
- Directory const& dir);
// Parsing helper classes.
--- 57,60 ----
Index: cmCTestSVN.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestSVN.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -C 2 -d -r1.6 -r1.7
*** cmCTestSVN.cxx 25 Feb 2009 20:45:14 -0000 1.6
--- cmCTestSVN.cxx 22 Apr 2009 13:18:19 -0000 1.7
***************
*** 25,29 ****
//----------------------------------------------------------------------------
! cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log)
{
this->PriorRev = this->Unknown;
--- 25,30 ----
//----------------------------------------------------------------------------
! cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log):
! cmCTestGlobalVC(ct, log)
{
this->PriorRev = this->Unknown;
***************
*** 361,368 ****
void cmCTestSVN::LoadRevisions()
{
- cmCTestLog(this->CTest, HANDLER_OUTPUT,
- " Gathering version information (one . per revision):\n"
- " " << std::flush);
-
// We are interested in every revision included in the update.
std::string revs;
--- 362,365 ----
***************
*** 384,388 ****
this->RunChild(svn_log, &out, &err);
}
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
}
--- 381,384 ----
***************
*** 396,433 ****
this->GuessBase(changes);
}
!
! // Indicate we found a revision.
! cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
!
! // Ignore changes in the old revision.
! if(revision.Rev == this->OldRevision)
! {
! this->PriorRev = revision;
! return;
! }
!
! // Store the revision.
! this->Revisions.push_back(revision);
!
! // Report this revision.
! Revision const& rev = this->Revisions.back();
! this->Log << "Found revision " << rev.Rev << "\n"
! << " author = " << rev.Author << "\n"
! << " date = " << rev.Date << "\n";
!
! // Update information about revisions of the changed files.
! for(std::vector<Change>::const_iterator ci = changes.begin();
! ci != changes.end(); ++ci)
! {
! if(const char* local = this->LocalPath(ci->Path))
! {
! std::string dir = cmSystemTools::GetFilenamePath(local);
! std::string name = cmSystemTools::GetFilenameName(local);
! File& file = this->Dirs[dir][name];
! file.PriorRev = file.Rev? file.Rev : &this->PriorRev;
! file.Rev = &rev;
! this->Log << " " << ci->Action << " " << local << " " << "\n";
! }
! }
}
--- 392,396 ----
this->GuessBase(changes);
}
! this->cmCTestGlobalVC::DoRevision(revision, changes);
}
***************
*** 462,469 ****
{
case 'M': case '!': case 'A': case 'D': case 'R': case 'X':
! this->DoPath(PathModified, path);
break;
case 'C': case '~':
! this->DoPath(PathConflicting, path);
break;
case 'I': case '?': case ' ': default:
--- 425,432 ----
{
case 'M': case '!': case 'A': case 'D': case 'R': case 'X':
! this->SVN->DoModification(PathModified, path);
break;
case 'C': case '~':
! this->SVN->DoModification(PathConflicting, path);
break;
case 'I': case '?': case ' ': default:
***************
*** 471,488 ****
}
}
-
- void DoPath(PathStatus status, std::string const& path)
- {
- std::string dir = cmSystemTools::GetFilenamePath(path);
- std::string name = cmSystemTools::GetFilenameName(path);
- File& file = this->SVN->Dirs[dir][name];
- file.Status = status;
- // For local modifications the current rev is unknown and the
- // prior rev is the latest from svn.
- if(!file.Rev && !file.PriorRev)
- {
- file.PriorRev = &this->SVN->PriorRev;
- }
- }
};
--- 434,437 ----
***************
*** 497,529 ****
this->RunChild(svn_status, &out, &err);
}
-
- //----------------------------------------------------------------------------
- void cmCTestSVN::WriteXMLDirectory(std::ostream& xml,
- std::string const& path,
- Directory const& dir)
- {
- const char* slash = path.empty()? "":"/";
- xml << "\t<Directory>\n"
- << "\t\t<Name>" << cmXMLSafe(path) << "</Name>\n";
- for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi)
- {
- std::string full = path + slash + fi->first;
- this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
- }
- xml << "\t</Directory>\n";
- }
-
- //----------------------------------------------------------------------------
- bool cmCTestSVN::WriteXMLUpdates(std::ostream& xml)
- {
- this->LoadRevisions();
- this->LoadModifications();
-
- for(std::map<cmStdString, Directory>::const_iterator
- di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
- {
- this->WriteXMLDirectory(xml, di->first, di->second);
- }
-
- return true;
- }
--- 446,447 ----
--- NEW FILE: cmCTestGlobalVC.cxx ---
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile: cmCTestGlobalVC.cxx,v $
Language: C++
Date: $Date: 2009-04-22 13:18:19 $
Version: $Revision: 1.1 $
Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmCTestGlobalVC.h"
#include "cmCTest.h"
#include "cmSystemTools.h"
#include "cmXMLSafe.h"
#include <cmsys/RegularExpression.hxx>
//----------------------------------------------------------------------------
cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log):
cmCTestVC(ct, log)
{
this->PriorRev = this->Unknown;
}
//----------------------------------------------------------------------------
cmCTestGlobalVC::~cmCTestGlobalVC()
{
}
//----------------------------------------------------------------------------
const char* cmCTestGlobalVC::LocalPath(std::string const& path)
{
return path.c_str();
}
//----------------------------------------------------------------------------
void cmCTestGlobalVC::DoRevision(Revision const& revision,
std::vector<Change> const& changes)
{
// Ignore changes in the old revision.
if(revision.Rev == this->OldRevision)
{
this->PriorRev = revision;
return;
}
// Indicate we found a revision.
cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
// Store the revision.
this->Revisions.push_back(revision);
// Report this revision.
Revision const& rev = this->Revisions.back();
this->Log << "Found revision " << rev.Rev << "\n"
<< " author = " << rev.Author << "\n"
<< " date = " << rev.Date << "\n";
// Update information about revisions of the changed files.
for(std::vector<Change>::const_iterator ci = changes.begin();
ci != changes.end(); ++ci)
{
if(const char* local = this->LocalPath(ci->Path))
{
std::string dir = cmSystemTools::GetFilenamePath(local);
std::string name = cmSystemTools::GetFilenameName(local);
File& file = this->Dirs[dir][name];
file.PriorRev = file.Rev? file.Rev : &this->PriorRev;
file.Rev = &rev;
this->Log << " " << ci->Action << " " << local << " " << "\n";
}
}
}
//----------------------------------------------------------------------------
void cmCTestGlobalVC::DoModification(PathStatus status,
std::string const& path)
{
std::string dir = cmSystemTools::GetFilenamePath(path);
std::string name = cmSystemTools::GetFilenameName(path);
File& file = this->Dirs[dir][name];
file.Status = status;
// For local modifications the current rev is unknown and the
// prior rev is the latest from svn.
if(!file.Rev && !file.PriorRev)
{
file.PriorRev = &this->PriorRev;
}
}
//----------------------------------------------------------------------------
void cmCTestGlobalVC::WriteXMLDirectory(std::ostream& xml,
std::string const& path,
Directory const& dir)
{
const char* slash = path.empty()? "":"/";
xml << "\t<Directory>\n"
<< "\t\t<Name>" << cmXMLSafe(path) << "</Name>\n";
for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi)
{
std::string full = path + slash + fi->first;
this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
}
xml << "\t</Directory>\n";
}
//----------------------------------------------------------------------------
bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per revision):\n"
" " << std::flush);
this->LoadRevisions();
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
this->LoadModifications();
for(std::map<cmStdString, Directory>::const_iterator
di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
{
this->WriteXMLDirectory(xml, di->first, di->second);
}
return true;
}
More information about the Cmake-commits
mailing list