|
@@ -32,6 +32,7 @@ CVSCopy() {
|
|
|
_model_dirname = ".";
|
|
_model_dirname = ".";
|
|
|
_key_filename = "Sources.pp";
|
|
_key_filename = "Sources.pp";
|
|
|
_cvs_binary = "cvs";
|
|
_cvs_binary = "cvs";
|
|
|
|
|
+ _user_aborted = false;
|
|
|
_model_dir = (CVSSourceDirectory *)NULL;
|
|
_model_dir = (CVSSourceDirectory *)NULL;
|
|
|
_map_dir = (CVSSourceDirectory *)NULL;
|
|
_map_dir = (CVSSourceDirectory *)NULL;
|
|
|
|
|
|
|
@@ -146,16 +147,52 @@ import(const Filename &source, void *extra_data,
|
|
|
nout << "Copying " << basename << " to " << dir->get_path() << "\n";
|
|
nout << "Copying " << basename << " to " << dir->get_path() << "\n";
|
|
|
|
|
|
|
|
if (!copy_file(source, dest, dir, extra_data, new_file)) {
|
|
if (!copy_file(source, dest, dir, extra_data, new_file)) {
|
|
|
- return (CVSSourceDirectory *)NULL;
|
|
|
|
|
- }
|
|
|
|
|
- if (new_file) {
|
|
|
|
|
- cvs_add(dest);
|
|
|
|
|
|
|
+ if (!continue_after_error()) {
|
|
|
|
|
+ return (CVSSourceDirectory *)NULL;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (new_file) {
|
|
|
|
|
+ cvs_add(dest);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return dir;
|
|
return dir;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: CVSCopy::continue_after_error
|
|
|
|
|
+// Access: Public
|
|
|
|
|
+// Description: Prompts the user (unless -f was specified) if he
|
|
|
|
|
+// wants to continue the copy operation after some error
|
|
|
|
|
+// has occurred. Returns true to continue, false
|
|
|
|
|
+// otherwise.
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+bool CVSCopy::
|
|
|
|
|
+continue_after_error() {
|
|
|
|
|
+ if (_force) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (_user_aborted) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ while (true) {
|
|
|
|
|
+ string result = prompt("Error occurred during copy! Continue (y/n)? ");
|
|
|
|
|
+ nassertr(!result.empty(), false);
|
|
|
|
|
+ if (result.size() == 1) {
|
|
|
|
|
+ if (tolower(result[0]) == 'y') {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else if (tolower(result[0]) == 'n') {
|
|
|
|
|
+ _user_aborted = true;
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ nout << "*** Invalid response: " << result << "\n\n";
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: CVSCopy::handle_args
|
|
// Function: CVSCopy::handle_args
|
|
@@ -467,3 +504,35 @@ scan_for_root(const string &dirname) {
|
|
|
|
|
|
|
|
return scan_for_root(dirname + "/..");
|
|
return scan_for_root(dirname + "/..");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: CVSCopy::prompt
|
|
|
|
|
+// Access: Private
|
|
|
|
|
+// Description: Issues a prompt to the user and waits for a typed
|
|
|
|
|
+// response. Returns the response (which will not be
|
|
|
|
|
+// empty).
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+string CVSCopy::
|
|
|
|
|
+prompt(const string &message) {
|
|
|
|
|
+ nout << flush;
|
|
|
|
|
+ while (true) {
|
|
|
|
|
+ cerr << message << flush;
|
|
|
|
|
+ string response;
|
|
|
|
|
+ getline(cin, response);
|
|
|
|
|
+
|
|
|
|
|
+ // Remove leading and trailing whitespace.
|
|
|
|
|
+ size_t p = 0;
|
|
|
|
|
+ while (p < response.length() && isspace(response[p])) {
|
|
|
|
|
+ p++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ size_t q = response.length();
|
|
|
|
|
+ while (q > p && isspace(response[q - 1])) {
|
|
|
|
|
+ q--;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (q > p) {
|
|
|
|
|
+ return response.substr(p, q - p);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|