ソースを参照

ENH: Factor out svn work tree cleanup

This removes work tree cleanup from cmCTestUpdateHandler and adds an
interface for it in cmCTestVC with an implementation in cmCTestSVN.
Brad King 17 年 前
コミット
fdd0d2a32b

+ 10 - 0
Source/CTest/cmCTestSVN.cxx

@@ -25,3 +25,13 @@ cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log)
 cmCTestSVN::~cmCTestSVN()
 {
 }
+
+//----------------------------------------------------------------------------
+void cmCTestSVN::CleanupImpl()
+{
+  const char* svn = this->CommandLineTool.c_str();
+  const char* svn_cleanup[] = {svn, "cleanup", 0};
+  OutputLogger out(this->Log, "cleanup-out> ");
+  OutputLogger err(this->Log, "cleanup-err> ");
+  this->RunChild(svn_cleanup, &out, &err);
+}

+ 4 - 0
Source/CTest/cmCTestSVN.h

@@ -30,6 +30,10 @@ public:
   cmCTestSVN(cmCTest* ctest, std::ostream& log);
 
   virtual ~cmCTestSVN();
+
+private:
+  // Implement cmCTestVC internal API.
+  virtual void CleanupImpl();
 };
 
 #endif

+ 3 - 42
Source/CTest/cmCTestUpdateHandler.cxx

@@ -389,52 +389,13 @@ int cmCTestUpdateHandler::ProcessHandler()
       }
     }
 
+  // Cleanup the working tree.
+  vc->Cleanup();
+
   bool res = true;
 
   // First, check what the current state of repository is
   std::string command = "";
-  switch( this->UpdateType )
-    {
-  case cmCTestUpdateHandler::e_CVS:
-    // TODO: CVS - for now just leave empty
-    break;
-  case cmCTestUpdateHandler::e_SVN:
-    command = "\"" + this->UpdateCommand + "\" cleanup";
-    break;
-    }
-
-  //
-  // Get initial repository information if that is possible. With subversion,
-  // this will check the current revision.
-  //
-  if ( !command.empty() )
-    {
-    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "* Cleanup repository: " << command.c_str() << std::endl);
-    if ( !this->CTest->GetShowOnly() )
-      {
-      ofs << "* Cleanup repository" << std::endl;
-      ofs << "  Command: " << command.c_str() << std::endl;
-      res = this->CTest->RunCommand(command.c_str(), &goutput, &errors,
-        &retVal, sourceDirectory, 0 /*this->TimeOut*/);
-
-      ofs << "  Output: " << goutput.c_str() << std::endl;
-      ofs << "  Errors: " << errors.c_str() << std::endl;
-      if ( ofs )
-        {
-        ofs << "--- Cleanup ---" << std::endl;
-        ofs << goutput << std::endl;
-        }
-      }
-    else
-      {
-      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "Cleanup with command: " << command << std::endl);
-      }
-    }
-
-  // First, check what the current state of repository is
-  command = "";
   switch( this->UpdateType )
     {
   case cmCTestUpdateHandler::e_CVS:

+ 14 - 0
Source/CTest/cmCTestVC.cxx

@@ -70,3 +70,17 @@ std::string cmCTestVC::ComputeCommandLine(char const* const* cmd)
     }
   return line.str();
 }
+
+//----------------------------------------------------------------------------
+void cmCTestVC::Cleanup()
+{
+  this->Log << "--- Begin Cleanup ---\n";
+  this->CleanupImpl();
+  this->Log << "--- End Cleanup ---\n";
+}
+
+//----------------------------------------------------------------------------
+void cmCTestVC::CleanupImpl()
+{
+  // We do no cleanup by default.
+}

+ 5 - 0
Source/CTest/cmCTestVC.h

@@ -39,7 +39,12 @@ public:
   /** Top-level source directory.  */
   void SetSourceDirectory(std::string const& dir);
 
+  /** Perform cleanup operations on the work tree.  */
+  void Cleanup();
+
 protected:
+  // Internal API to be implemented by subclasses.
+  virtual void CleanupImpl();
 
   /** Convert a list of arguments to a human-readable command line.  */
   static std::string ComputeCommandLine(char const* const* cmd);