cmCTestGlobalVC.cxx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmCTestGlobalVC.h"
  14. #include "cmCTest.h"
  15. #include "cmSystemTools.h"
  16. #include "cmXMLSafe.h"
  17. #include <cmsys/RegularExpression.hxx>
  18. //----------------------------------------------------------------------------
  19. cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log):
  20. cmCTestVC(ct, log)
  21. {
  22. this->PriorRev = this->Unknown;
  23. }
  24. //----------------------------------------------------------------------------
  25. cmCTestGlobalVC::~cmCTestGlobalVC()
  26. {
  27. }
  28. //----------------------------------------------------------------------------
  29. const char* cmCTestGlobalVC::LocalPath(std::string const& path)
  30. {
  31. return path.c_str();
  32. }
  33. //----------------------------------------------------------------------------
  34. void cmCTestGlobalVC::DoRevision(Revision const& revision,
  35. std::vector<Change> const& changes)
  36. {
  37. // Ignore changes in the old revision.
  38. if(revision.Rev == this->OldRevision)
  39. {
  40. this->PriorRev = revision;
  41. return;
  42. }
  43. // Indicate we found a revision.
  44. cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
  45. // Store the revision.
  46. this->Revisions.push_back(revision);
  47. // Report this revision.
  48. Revision const& rev = this->Revisions.back();
  49. this->Log << "Found revision " << rev.Rev << "\n"
  50. << " author = " << rev.Author << "\n"
  51. << " date = " << rev.Date << "\n";
  52. // Update information about revisions of the changed files.
  53. for(std::vector<Change>::const_iterator ci = changes.begin();
  54. ci != changes.end(); ++ci)
  55. {
  56. if(const char* local = this->LocalPath(ci->Path))
  57. {
  58. std::string dir = cmSystemTools::GetFilenamePath(local);
  59. std::string name = cmSystemTools::GetFilenameName(local);
  60. File& file = this->Dirs[dir][name];
  61. file.PriorRev = file.Rev? file.Rev : &this->PriorRev;
  62. file.Rev = &rev;
  63. this->Log << " " << ci->Action << " " << local << " " << "\n";
  64. }
  65. }
  66. }
  67. //----------------------------------------------------------------------------
  68. void cmCTestGlobalVC::DoModification(PathStatus status,
  69. std::string const& path)
  70. {
  71. std::string dir = cmSystemTools::GetFilenamePath(path);
  72. std::string name = cmSystemTools::GetFilenameName(path);
  73. File& file = this->Dirs[dir][name];
  74. file.Status = status;
  75. // For local modifications the current rev is unknown and the
  76. // prior rev is the latest from svn.
  77. if(!file.Rev && !file.PriorRev)
  78. {
  79. file.PriorRev = &this->PriorRev;
  80. }
  81. }
  82. //----------------------------------------------------------------------------
  83. void cmCTestGlobalVC::WriteXMLDirectory(std::ostream& xml,
  84. std::string const& path,
  85. Directory const& dir)
  86. {
  87. const char* slash = path.empty()? "":"/";
  88. xml << "\t<Directory>\n"
  89. << "\t\t<Name>" << cmXMLSafe(path) << "</Name>\n";
  90. for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi)
  91. {
  92. std::string full = path + slash + fi->first;
  93. this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
  94. }
  95. xml << "\t</Directory>\n";
  96. }
  97. //----------------------------------------------------------------------------
  98. bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml)
  99. {
  100. cmCTestLog(this->CTest, HANDLER_OUTPUT,
  101. " Gathering version information (one . per revision):\n"
  102. " " << std::flush);
  103. this->LoadRevisions();
  104. cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
  105. this->LoadModifications();
  106. for(std::map<cmStdString, Directory>::const_iterator
  107. di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
  108. {
  109. this->WriteXMLDirectory(xml, di->first, di->second);
  110. }
  111. return true;
  112. }