cmCTestVC.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc.
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCTestVC_h
  11. #define cmCTestVC_h
  12. #include "cmProcessTools.h"
  13. class cmCTest;
  14. class cmXMLWriter;
  15. /** \class cmCTestVC
  16. * \brief Base class for version control system handlers
  17. *
  18. */
  19. class cmCTestVC: public cmProcessTools
  20. {
  21. public:
  22. /** Construct with a CTest instance and update log stream. */
  23. cmCTestVC(cmCTest* ctest, std::ostream& log);
  24. virtual ~cmCTestVC();
  25. /** Command line tool to invoke. */
  26. void SetCommandLineTool(std::string const& tool);
  27. /** Top-level source directory. */
  28. void SetSourceDirectory(std::string const& dir);
  29. /** Get the date/time specification for the current nightly start time. */
  30. std::string GetNightlyTime();
  31. /** Prepare the work tree. */
  32. bool InitialCheckout(const char* command);
  33. /** Perform cleanup operations on the work tree. */
  34. void Cleanup();
  35. /** Update the working tree to the new revision. */
  36. bool Update();
  37. /** Get the command line used by the Update method. */
  38. std::string const& GetUpdateCommandLine() const
  39. { return this->UpdateCommandLine; }
  40. /** Write Update.xml entries for the updates found. */
  41. bool WriteXML(cmXMLWriter& xml);
  42. /** Enumerate non-trivial working tree states during update. */
  43. enum PathStatus { PathUpdated, PathModified, PathConflicting };
  44. /** Get the number of working tree paths in each state after update. */
  45. int GetPathCount(PathStatus s) const { return this->PathCount[s]; }
  46. protected:
  47. // Internal API to be implemented by subclasses.
  48. virtual void CleanupImpl();
  49. virtual void NoteOldRevision();
  50. virtual bool UpdateImpl();
  51. virtual void NoteNewRevision();
  52. virtual bool WriteXMLUpdates(cmXMLWriter& xml);
  53. #if defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x510
  54. // Sun CC 5.1 needs help to allow cmCTestSVN::Revision to see this
  55. public:
  56. #endif
  57. /** Basic information about one revision of a tree or file. */
  58. struct Revision
  59. {
  60. std::string Rev;
  61. std::string Date;
  62. std::string Author;
  63. std::string EMail;
  64. std::string Committer;
  65. std::string CommitterEMail;
  66. std::string CommitDate;
  67. std::string Log;
  68. };
  69. protected:
  70. struct File;
  71. friend struct File;
  72. /** Represent change to one file. */
  73. struct File
  74. {
  75. PathStatus Status;
  76. Revision const* Rev;
  77. Revision const* PriorRev;
  78. File(): Status(PathUpdated), Rev(0), PriorRev(0) {}
  79. File(PathStatus status, Revision const* rev, Revision const* priorRev):
  80. Status(status), Rev(rev), PriorRev(priorRev) {}
  81. };
  82. /** Convert a list of arguments to a human-readable command line. */
  83. static std::string ComputeCommandLine(char const* const* cmd);
  84. /** Run a command line and send output to given parsers. */
  85. bool RunChild(char const* const* cmd, OutputParser* out,
  86. OutputParser* err, const char* workDir = 0);
  87. /** Run VC update command line and send output to given parsers. */
  88. bool RunUpdateCommand(char const* const* cmd,
  89. OutputParser* out, OutputParser* err = 0);
  90. /** Write xml element for one file. */
  91. void WriteXMLEntry(cmXMLWriter& xml, std::string const& path,
  92. std::string const& name, std::string const& full,
  93. File const& f);
  94. // Instance of cmCTest running the script.
  95. cmCTest* CTest;
  96. // A stream to which we write log information.
  97. std::ostream& Log;
  98. // Basic information about the working tree.
  99. std::string CommandLineTool;
  100. std::string SourceDirectory;
  101. // Record update command info.
  102. std::string UpdateCommandLine;
  103. // Placeholder for unknown revisions.
  104. Revision Unknown;
  105. // Count paths reported with each PathStatus value.
  106. int PathCount[3];
  107. };
  108. #endif