From cec9366aea873ebe2dca710d42f78d080c7d1ff0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 11 Oct 2007 16:10:08 -0400 Subject: [PATCH] default section needs to come first also, add skips --- mr | 27 ++++++++++++++++----------- mrconfig | 26 ++++++++++++++++++++------ 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/mr b/mr index 856de11..470927a 100755 --- a/mr +++ b/mr @@ -120,11 +120,22 @@ registers several additional repositories. The .mrconfig file uses a variant of the INI file format. Lines starting with "#" are comments. Lines ending with "\" are continued on to the next line. -Sections specify where each repository is located, relative to the + +The "default" section allows setting default values for the sections that +come after it. + +The "alias" section allows adding aliases for actions. Each parameter +is an alias, and its value is the action to use. + +All other sections specify where each repository is located, relative to the directory that contains the .mrconfig file. Within a section, each parameter defines a shell command to run to handle a -given action. Note that these shell commands are run in a "set -e" shell +given action. mr contains default handlers for the "update", "status", and +"commit" actions, so normally you only need to specify what to do for +"checkout". + +Note that these shell commands are run in a "set -e" shell environment, where any additional parameters you pass are available in "$@". The "checkout" command is run in the parent of the repository directory, since the repository isn't checked out yet. All other commands @@ -141,14 +152,6 @@ should avoid chaining from repositories with untrusted committers.) The command, this can be a useful way to define shell functions for other commands to use. -The "default" section allows setting up default handlers for each action, -and is overridden by the contents of other sections. mr contains default -handlers for the "update", "status", and "commit" actions, so normally -you only need to specify what to do for "checkout". - -The "alias" section allows adding aliases for actions. Each parameter -is an alias, and its value is the action to use. - For example: [src] @@ -301,7 +304,9 @@ sub action { } if (exists $config{$topdir}{$subdir}{skip}) { - my $ret=system($lib.$config{$topdir}{$subdir}{skip}); + my $test="set -e;".$lib.$config{$topdir}{$subdir}{skip}; + print "mr $action: running skip test $test\n" if $verbose; + my $ret=system($test); if ($ret >> 8 == 0) { print "mr $action: $dir skipped per config file\n" if $verbose; push @skipped, $dir; diff --git a/mrconfig b/mrconfig index e4ae9a0..5b51857 100644 --- a/mrconfig +++ b/mrconfig @@ -1,12 +1,28 @@ # An example config file for the mr(1) command. +[default] +# Teach mr how to run svn cleanup. +cleanup = if [ -d "$MR_REPO"/.svn ]; then svn cleanup ; fi +# Tests used in the skips below. +# - wantsrc checks whether I probably want a full source checkout (quite +# large) +# - mylaptop only succeeds if it's on my main development laptop, which +# gets lots of extra cruft +lib = \ + wantsrc() { \ + test "$(whoami)" = joey; \ + }; \ + mylaptop() { \ + test "$(hostname)" = kodama; \ + } + [src/mr] checkout = git clone ssh://kitenet.net/srv/git/kitenet.net/mr +skip = ! wantsrc [src/linux-2.6] checkout = git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git -# I only check this out on kodama, otherwise skip it. -skip = test $(hostname) != kodama +skip = ! mylaptop || ! wantsrc [src/dpkg] # A merge of the upstream dpkg git repo and my own personal branch. @@ -18,6 +34,7 @@ checkout = \ git checkout -b sourcev3 kite/sourcev3 update = git pull origin master && git pull kite sourcev3 commit = git push kite +skip = ! wantsrc [html/www.debian.org] # Still in CVS..urk! @@ -28,13 +45,10 @@ checkout = \ # and only rarely update = echo "skipping cvs update (too slow)" status = echo "skipping cvs status (too ugly)" +skip = ! wantsrc # My home directory, which I keep in svn. [] checkout = svn co svn+ssh://svn.kitenet.net/srv/svn/joey/trunk/home-$(hostname) joey # run svnfix after each update update = svn update && svnfix - -[default] -# Teach mr how to run svn cleanup. -cleanup = if [ -d "$MR_REPO"/.svn ]; then svn cleanup ; fi -- 2.39.5