From f71de7f7755b66c52e7e139479a2f8d3bec33323 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 13 Nov 2000 19:31:46 +0000 Subject: [PATCH] *** empty log message *** --- pandatool/src/softprogs/softCVS.cxx | 70 +++++++++++++++++++++++------ pandatool/src/softprogs/softCVS.h | 4 ++ 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/pandatool/src/softprogs/softCVS.cxx b/pandatool/src/softprogs/softCVS.cxx index b04a22f901..1295890898 100644 --- a/pandatool/src/softprogs/softCVS.cxx +++ b/pandatool/src/softprogs/softCVS.cxx @@ -99,6 +99,11 @@ run() { for (si = _scene_files.begin(); si != _scene_files.end(); ++si) { consider_scene_file(*si); } + + // Finally, add everything to CVS that needs to be added. We do + // this all at once at the end, instead of one at a time as we + // encounter each file, to speed things up a bit. + cvs_add_all(); } //////////////////////////////////////////////////////////////////// @@ -126,6 +131,17 @@ traverse(const string &dirname) { } closedir(root); + // Sort the directory entries just for the user's sanity. + sort(files.begin(), files.end()); + + // We need to know the set of files in this directory that are CVS + // elements. + set cvs_elements; + bool in_cvs = false; + if (!_no_cvs) { + in_cvs = scan_cvs(dirname, cvs_elements); + } + // Now go through and identify files with version numbers, and // collect together those files that are different versions of the // same file. @@ -133,7 +149,8 @@ traverse(const string &dirname) { vector_string::const_iterator fi; for (fi = files.begin(); fi != files.end(); ++fi) { const string &filename = (*fi); - if (!filename.empty() && filename[0] != '.') { + if (!filename.empty() && filename[0] != '.' && + !(filename == "CVS")) { SoftFilename v(filename); if (v.has_version()) { versions.push_back(v); @@ -142,21 +159,18 @@ traverse(const string &dirname) { Filename subdir = dirname + "/" + filename; if (subdir.is_directory()) { traverse(subdir); + } else { + // No, not a subdirectory; maybe a regular file that needs + // to get added to CVS? + if (in_cvs) { + consider_add_cvs(dirname, filename, cvs_elements); + } } } } } if (!versions.empty()) { - // We actually have some versioned filenames in this directory. - // We'll therefore need to know the set of files that are CVS - // elements. - set cvs_elements; - bool in_cvs = false; - if (!_no_cvs) { - in_cvs = scan_cvs(dirname, cvs_elements); - } - // Now sort the versioned filenames in order so we can scan for // higher versions. sort(versions.begin(), versions.end()); @@ -334,8 +348,8 @@ consider_add_cvs(const string &dirname, const string &filename, return; } } - - cvs_add(path); + + _cvs_paths.push_back(path); } //////////////////////////////////////////////////////////////////// @@ -442,8 +456,9 @@ scan_scene_file(istream &in, ostream &out) { //////////////////////////////////////////////////////////////////// // Function: SoftCVS::cvs_add // Access: Private -// Description: Invokes CVS to add the file to the repository. -// Returns true on success, false on failure. +// Description: Invokes CVS to add just the named file to the +// repository. Returns true on success, false on +// failure. //////////////////////////////////////////////////////////////////// bool SoftCVS:: cvs_add(const string &path) { @@ -458,6 +473,33 @@ cvs_add(const string &path) { return true; } +//////////////////////////////////////////////////////////////////// +// Function: SoftCVS::cvs_add_all +// Access: Private +// Description: Invokes CVS to add all of the files in _cvs_paths to +// the repository. Returns true on success, false on +// failure. +//////////////////////////////////////////////////////////////////// +bool SoftCVS:: +cvs_add_all() { + if (!_cvs_paths.empty()) { + string command = _cvs_binary + " add"; + vector_string::const_iterator pi; + for (pi = _cvs_paths.begin(); pi != _cvs_paths.end(); ++pi) { + command += ' '; + command += (*pi); + } + nout << command << "\n"; + int result = system(command.c_str()); + + if (result != 0) { + nout << "Failure invoking cvs.\n"; + return false; + } + } + return true; +} + //////////////////////////////////////////////////////////////////// // Function: SoftCVS::prompt_yesno // Access: Private diff --git a/pandatool/src/softprogs/softCVS.h b/pandatool/src/softprogs/softCVS.h index 20e1face33..2b019414f5 100644 --- a/pandatool/src/softprogs/softCVS.h +++ b/pandatool/src/softprogs/softCVS.h @@ -11,6 +11,7 @@ #include "softFilename.h" #include +#include #include #include @@ -40,12 +41,15 @@ private: bool scan_scene_file(istream &in, ostream &out); bool cvs_add(const string &path); + bool cvs_add_all(); bool prompt_yesno(const string &message); string prompt(const string &message); set _scene_files; set _versioned_files; + + vector_string _cvs_paths; protected: bool _interactive;