#
# add_file "tests/t_db_kill_rev_locally.at"
#
# patch "ChangeLog"
# from [c9fdccd9b5dae6701f72b07fd3f22fc542773f26]
# to [ba8adfcfdee37c10b80c327d8bf0fbf6473a73b5]
#
# patch "contrib/monotone-notify.pl"
# from [7b80bc10043bcd080e0a98742cd49a3c8aa7b8df]
# to [5fe63044551809be3609ccdd179c51b68109ffb1]
#
# patch "tests/t_db_kill_rev_locally.at"
# from []
# to [7833b3652bf45b72b9fb6490b86fe2b66d7105ee]
#
# patch "testsuite.at"
# from [5c3edfba27e5b828d6080f873f035114c54e7823]
# to [78e75421c02747bc50d1966394370014a1e16858]
#
--- ChangeLog
+++ ChangeLog
@@ -7,12 +7,23 @@
* change_set.cc (path_item, sanity_check_path_item): Mark things
inline.
+2005-04-17 Henrik Holmboe
+
+ * contrib/monotone-notify.pl: Add signal handlers. Correct some
+ typos.
+ (my_exit): New function that does a cleanup and exit.
+
2005-04-17 Olivier Andrieu
* transforms.cc: fix glob_to_regexp assertions
2005-04-17 Sebastian Spaeth
+
+ * tests/t_db_kill_rev_locally.at: new test;
+ make sure that db kill_rev_locally works as intended
+2005-04-17 Sebastian Spaeth
+
* commands.cc,database.cc: add 'db kill_rev_locally ' command
still missing: documentation and autotests. Otherwise seems ok.
--- contrib/monotone-notify.pl
+++ contrib/monotone-notify.pl
@@ -73,6 +73,11 @@
'quiet' => \$quiet,
'debug' => \$debug) or pod2usage(2);
+$SIG{HUP} = \&my_exit;
+$SIG{KILL} = \&my_exit;
+$SIG{TERM} = \&my_exit;
+$SIG{INT} = \&my_exit;
+
######################################################################
# Respond to user input
#
@@ -97,7 +102,7 @@
pod2usage(2);
}
if (!defined $difflogs_to && !defined $nodifflogs_to) {
- my_errlog("You need to specify a To address with --to");
+ my_errlog("You need to specify a To address with --diffslogs-to or --nodiffslogs-to");
pod2usage(2);
}
}
@@ -140,12 +145,15 @@
my $remove_workdir = 0;
if (!defined $workdir) {
- $workdir = "/var/tmp/monotone_motify.work.$$";
+ $workdir = "/var/tmp/monotone_notify.work.$$";
mkdir $workdir;
$remove_workdir = 1;
} elsif (! file_name_is_absolute($workdir)) {
$workdir = rel2abs($workdir);
}
+if (! -d $workdir && ! -w $workdir && ! -r $workdir) {
+ my_error("work directory $workdir not accessible, exiting");
+}
my_debug("using work directory $workdir");
my_debug("(to be removed after I'm done)") if $remove_workdir;
@@ -448,13 +456,8 @@
######################################################################
# Clean up.
#
-my_log("cleaning up.");
-unlink @files_to_clean_up;
-rmdir $workdir if $remove_workdir;
+my_exit();
-my_log("all done.");
-exit(0);
-
######################################################################
# Subroutines
#
@@ -594,6 +597,17 @@
return $return;
}
+# my_exit removes temporary files and gracefully closes network
+# connections.
+sub my_exit
+{
+ my_log("cleaning up.");
+ unlink @files_to_clean_up;
+ rmdir $workdir if $remove_workdir;
+ my_log("all done.");
+ exit(0);
+}
+
# my_backtick does the same thing as backtick commands, but will print a bit
# of debugging output when $debug is true. It will also die if the subprocess
# returned an error code.
@@ -738,7 +752,7 @@
two files F and F will be
left in the work directory.
-The default working directory is F,
+The default working directory is F,
and will be removed automatically unless F or
F are left in it.
--- tests/t_db_kill_rev_locally.at
+++ tests/t_db_kill_rev_locally.at
@@ -0,0 +1,24 @@
+AT_SETUP([db kill_rev_locally command])
+MONOTONE_SETUP
+
+# This tests the db kill_rev_locally command
+
+# Prepare a db with two revisions
+AT_CHECK(echo "test">tmp, [], ignore, ignore)
+AT_CHECK(MONOTONE add tmp, [], ignore, ignore)
+AT_CHECK(MONOTONE --branch="test" --message="logtext" commit, [], ignore, stderr)
+ANCESTOR=`cat stderr|awk '/committed revision/ {print $4}'`
+AT_CHECK(echo "test2">>tmp, [], ignore, ignore)
+AT_CHECK(MONOTONE --message="logtext" commit, [], ignore, stderr)
+CHILD=`cat stderr|awk '/committed revision/ {print $4}'`
+
+# trying to kill the ancestor. This *is supposed to fail*
+AT_CHECK(MONOTONE db kill_rev_locally $ANCESTOR, [1], ignore, ignore)
+AT_CHECK(MONOTONE db check, [], ignore, ignore)
+
+# killing children is ok, though :)
+AT_CHECK(MONOTONE db kill_rev_locally $CHILD, [], ignore, ignore)
+AT_CHECK(MONOTONE db check, [], ignore, ignore)
+
+AT_CLEANUP
+(END)
--- testsuite.at
+++ testsuite.at
@@ -564,3 +564,4 @@
m4_include(tests/t_override_author_date.at)
m4_include(tests/t_add_stomp_file.at)
m4_include(tests/t_database_check_minor.at)
+m4_include(tests/t_db_kill_rev_locally.at)