Updated formatting of documentation plus a little reorganization.
[cmake.git] / Source / CTest / cmCTestVC.h
blobf5a919bc8226f098fc664d115166a7d281f1974b
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestVC.h,v $
5 Language: C++
6 Date: $Date: 2009-02-26 14:22:32 $
7 Version: $Revision: 1.8 $
9 Copyright (c) 2002 Kitware, Inc. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmCTestVC_h
18 #define cmCTestVC_h
20 #include "cmProcessTools.h"
22 class cmCTest;
24 /** \class cmCTestVC
25 * \brief Base class for version control system handlers
28 class cmCTestVC: public cmProcessTools
30 public:
31 /** Construct with a CTest instance and update log stream. */
32 cmCTestVC(cmCTest* ctest, std::ostream& log);
34 virtual ~cmCTestVC();
36 /** Command line tool to invoke. */
37 void SetCommandLineTool(std::string const& tool);
39 /** Top-level source directory. */
40 void SetSourceDirectory(std::string const& dir);
42 /** Get the date/time specification for the current nightly start time. */
43 std::string GetNightlyTime();
45 /** Prepare the work tree. */
46 bool InitialCheckout(const char* command);
48 /** Perform cleanup operations on the work tree. */
49 void Cleanup();
51 /** Update the working tree to the new revision. */
52 bool Update();
54 /** Get the command line used by the Update method. */
55 std::string const& GetUpdateCommandLine() const
56 { return this->UpdateCommandLine; }
58 /** Write Update.xml entries for the updates found. */
59 bool WriteXML(std::ostream& xml);
61 /** Enumerate non-trivial working tree states during update. */
62 enum PathStatus { PathUpdated, PathModified, PathConflicting };
64 /** Get the number of working tree paths in each state after update. */
65 int GetPathCount(PathStatus s) const { return this->PathCount[s]; }
67 protected:
68 // Internal API to be implemented by subclasses.
69 virtual void CleanupImpl();
70 virtual void NoteOldRevision();
71 virtual bool UpdateImpl();
72 virtual void NoteNewRevision();
73 virtual bool WriteXMLUpdates(std::ostream& xml);
75 /** Basic information about one revision of a tree or file. */
76 struct Revision
78 std::string Rev;
79 std::string Date;
80 std::string Author;
81 std::string Log;
84 struct File;
85 friend struct File;
87 /** Represent change to one file. */
88 struct File
90 PathStatus Status;
91 Revision const* Rev;
92 Revision const* PriorRev;
93 File(): Status(PathUpdated), Rev(0), PriorRev(0) {}
94 File(PathStatus status, Revision const* rev, Revision const* priorRev):
95 Status(status), Rev(rev), PriorRev(priorRev) {}
98 /** Convert a list of arguments to a human-readable command line. */
99 static std::string ComputeCommandLine(char const* const* cmd);
101 /** Run a command line and send output to given parsers. */
102 bool RunChild(char const* const* cmd, OutputParser* out,
103 OutputParser* err, const char* workDir = 0);
105 /** Run VC update command line and send output to given parsers. */
106 bool RunUpdateCommand(char const* const* cmd,
107 OutputParser* out, OutputParser* err = 0);
109 /** Write xml element for one file. */
110 void WriteXMLEntry(std::ostream& xml, std::string const& path,
111 std::string const& name, std::string const& full,
112 File const& f);
114 // Instance of cmCTest running the script.
115 cmCTest* CTest;
117 // A stream to which we write log information.
118 std::ostream& Log;
120 // Basic information about the working tree.
121 std::string CommandLineTool;
122 std::string SourceDirectory;
124 // Record update command info.
125 std::string UpdateCommandLine;
127 // Placeholder for unknown revisions.
128 Revision Unknown;
130 // Count paths reported with each PathStatus value.
131 int PathCount[3];
134 #endif