From: Joey Hess Date: Tue, 27 Sep 2011 21:21:48 +0000 (-0400) Subject: Brought back the "deleted" parameter, which provides an easy way to mark repositories... X-Git-Url: https://git.madduck.net/code/myrepos.git/commitdiff_plain/6ac6acc4892bfcbe166f09b64eaecc420c430106 Brought back the "deleted" parameter, which provides an easy way to mark repositories that should be removed. This will be especially useful in untrusted mrconfig files. --- diff --git a/debian/changelog b/debian/changelog index 9fa0d95..68a67c2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ mr (1.05) UNRELEASED; urgency=low * git-fake-bare: handle fake bare repositories with core.bare not set (Thanks, Julien Rebetez) * README now gives a quick into to using mr. + * Brought back the "deleted" parameter, which provides an easy way to + mark repositories that should be removed. -- Joey Hess Fri, 05 Aug 2011 13:29:21 -0400 diff --git a/mr b/mr index 4235151..bd6c2d7 100755 --- a/mr +++ b/mr @@ -377,6 +377,14 @@ part of the including file. Unlike all other parameters, this parameter does not need to be placed within a section. +=item deleted + +If the "deleted" parameter is set and its command returns true, then +B will treat the repository as deleted. It won't ever actually delete +the repository, but it will warn if it sees the repository's directory. +This is useful when one mrconfig file is shared amoung multiple machines, +to keep track of and remember to delete old repositories. + =item lib The "lib" parameter can specify some shell code that will be run before each @@ -567,6 +575,37 @@ sub action { my $is_update=($action =~ /update/); $ENV{MR_REPO}=$dir; + + foreach my $testname ("skip", "deleted") { + my $testcommand=findcommand($testname, $dir, $topdir, $subdir, $is_checkout); + + if (defined $testcommand) { + my $test="set -e;".$lib. + "my_action(){ $testcommand\n }; my_action '$action'"; + print "mr $action: running $testname test >>$test<<\n" if $verbose; + my $ret=system($test); + if ($ret != 0) { + if (($? & 127) == 2) { + print STDERR "mr $action: interrupted\n"; + return ABORT; + } + elsif ($? & 127) { + print STDERR "mr $action: $testname test received signal ".($? & 127)."\n"; + return ABORT; + } + } + if ($ret >> 8 == 0) { + if ($testname eq "deleted") { + if (-d $dir) { + print STDERR "mr error: $dir should be deleted yet still exists\n"; + return FAILED; + } + } + print "mr $action: skip $dir skipped\n" if $verbose; + return SKIPPED; + } + } + } if ($is_checkout) { if (! $force_checkout) { @@ -584,30 +623,8 @@ sub action { } } - my $skiptest=findcommand("skip", $dir, $topdir, $subdir, $is_checkout); my $command=findcommand($action, $dir, $topdir, $subdir, $is_checkout); - if (defined $skiptest) { - my $test="set -e;".$lib. - "my_action(){ $skiptest\n }; my_action '$action'"; - print "mr $action: running skip test >>$test<<\n" if $verbose; - my $ret=system($test); - if ($ret != 0) { - if (($? & 127) == 2) { - print STDERR "mr $action: interrupted\n"; - return ABORT; - } - elsif ($? & 127) { - print STDERR "mr $action: skip test received signal ".($? & 127)."\n"; - return ABORT; - } - } - if ($ret >> 8 == 0) { - print "mr $action: $dir skipped per config file\n" if $verbose; - return SKIPPED; - } - } - if ($is_checkout && ! -d $dir) { print "mr $action: creating parent directory $dir\n" if $verbose; system("mkdir", "-p", $dir); diff --git a/mrconfig b/mrconfig index c366271..a1abcd1 100644 --- a/mrconfig +++ b/mrconfig @@ -10,10 +10,3 @@ skip = ([ "$1" = update ] && ! hours_since "$1" 12) [debian-cd] checkout = svn co svn://svn.debian.org/debian-cd/trunk debian-cd - -# Example of how to remember to delete a repo, when one mrconfig file is -# used on multiple systems. If you're feeling brave, use rm -rf $MR_REPO -# instead. This approach can also be used for renames. -[foo] -update = error "$MR_REPO is no longer used and should be deleted" -skip = ! test -d "$MR_REPO"