cmCTestSVN.cxx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 "cmCTestSVN.h"
  14. #include "cmCTest.h"
  15. #include <cmsys/RegularExpression.hxx>
  16. //----------------------------------------------------------------------------
  17. cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log)
  18. {
  19. }
  20. //----------------------------------------------------------------------------
  21. cmCTestSVN::~cmCTestSVN()
  22. {
  23. }
  24. //----------------------------------------------------------------------------
  25. void cmCTestSVN::CleanupImpl()
  26. {
  27. const char* svn = this->CommandLineTool.c_str();
  28. const char* svn_cleanup[] = {svn, "cleanup", 0};
  29. OutputLogger out(this->Log, "cleanup-out> ");
  30. OutputLogger err(this->Log, "cleanup-err> ");
  31. this->RunChild(svn_cleanup, &out, &err);
  32. }
  33. //----------------------------------------------------------------------------
  34. class cmCTestSVN::InfoParser: public cmCTestVC::LineParser
  35. {
  36. public:
  37. InfoParser(cmCTestSVN* svn, const char* prefix, std::string& rev):
  38. SVN(svn), Rev(rev)
  39. {
  40. this->SetLog(&svn->Log, prefix);
  41. this->RegexRev.compile("^Revision: ([0-9]+)");
  42. }
  43. private:
  44. cmCTestSVN* SVN;
  45. std::string& Rev;
  46. cmsys::RegularExpression RegexRev;
  47. virtual bool ProcessLine()
  48. {
  49. if(this->RegexRev.find(this->Line))
  50. {
  51. this->Rev = this->RegexRev.match(1);
  52. }
  53. return true;
  54. }
  55. };
  56. //----------------------------------------------------------------------------
  57. std::string cmCTestSVN::LoadInfo()
  58. {
  59. // Run "svn info" to get the repository info from the work tree.
  60. const char* svn = this->CommandLineTool.c_str();
  61. const char* svn_info[] = {svn, "info", 0};
  62. std::string rev;
  63. InfoParser out(this, "info-out> ", rev);
  64. OutputLogger err(this->Log, "info-err> ");
  65. this->RunChild(svn_info, &out, &err);
  66. return rev;
  67. }
  68. //----------------------------------------------------------------------------
  69. void cmCTestSVN::NoteOldRevision()
  70. {
  71. this->OldRevision = this->LoadInfo();
  72. this->Log << "Revision before update: " << this->OldRevision << "\n";
  73. cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
  74. << this->OldRevision << "\n");
  75. }
  76. //----------------------------------------------------------------------------
  77. void cmCTestSVN::NoteNewRevision()
  78. {
  79. this->NewRevision = this->LoadInfo();
  80. this->Log << "Revision after update: " << this->NewRevision << "\n";
  81. cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
  82. << this->NewRevision << "\n");
  83. }