1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestVC.h,v $
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 =========================================================================*/
20 #include "cmProcessTools.h"
25 * \brief Base class for version control system handlers
28 class cmCTestVC
: public cmProcessTools
31 /** Construct with a CTest instance and update log stream. */
32 cmCTestVC(cmCTest
* ctest
, std::ostream
& log
);
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. */
51 /** Update the working tree to the new revision. */
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
]; }
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. */
87 /** Represent change to one file. */
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
,
114 // Instance of cmCTest running the script.
117 // A stream to which we write log information.
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.
130 // Count paths reported with each PathStatus value.