X-Git-Url: https://git.madduck.net/code/myrepos.git/blobdiff_plain/01ec3b770fb914f3f2210a9b6106e9ea82bf0e6b..c43f9d1f483b45907f24e6befc68016d3ed9ac93:/mr diff --git a/mr b/mr index 4c7be3d..55dbdee 100755 --- a/mr +++ b/mr @@ -224,7 +224,9 @@ is an alias, and its value is the action to use. All other sections add repositories. The section header specifies the directory where the repository is located. This is relative to the directory that contains the mrconfig file, but you can also choose to use absolute -paths. +paths. (Note that you can use environment variables in section names; they +will be passed through the shell for expansion. For example, +"[$HOSTNAME]", or "[${HOSTNAME}foo]") Within a section, each parameter defines a shell command to run to handle a given action. mr contains default handlers for "update", "status", @@ -423,6 +425,8 @@ sub action { #{{{ $config{$topdir}{$subdir}{lib}."\n" : ""; my $is_checkout=($action eq 'checkout'); + $ENV{MR_REPO}=$dir; + if ($is_checkout) { if (-d $dir) { print "mr $action: $dir already exists, skipping checkout\n" if $verbose; @@ -437,8 +441,6 @@ sub action { #{{{ } } - $ENV{MR_REPO}=$dir; - my $skiptest=findcommand("skip", $dir, $topdir, $subdir, $is_checkout); my $command=findcommand($action, $dir, $topdir, $subdir, $is_checkout); @@ -607,7 +609,7 @@ sub record { #{{{ elsif ($ret == FAILED) { if ($interactive) { chdir($dir) unless $no_chdir; - print STDERR "mr: starting interactive shell. Exit shell to continue.\n"; + print STDERR "mr: Starting interactive shell. Exit shell to continue.\n"; system((getpwuid($<))[8]); } push @failed, $dir; @@ -717,6 +719,18 @@ sub selectrepos { #{{{ return @repos; } #}}} +sub expandenv { #{{{ + my $val=shift; + + + if ($val=~/\$/) { + $val=`echo "$val"`; + chomp $val; + } + + return $val; +} #}}} + my %loaded; sub loadconfig { #{{{ my $f=shift; @@ -777,7 +791,7 @@ sub loadconfig { #{{{ chomp; next if /^\s*\#/ || /^\s*$/; if (/^\[([^\]]*)\]\s*$/) { - $section=$1; + $section=expandenv($1); } elsif (/^(\w+)\s*=\s*(.*)/) { my $parameter=$1; @@ -900,7 +914,7 @@ sub modifyconfig { #{{{ $addfields->(); } - $section=$1; + $section=expandenv($1); push @out, $_; } @@ -1207,7 +1221,7 @@ git_status = git status "$@" || true bzr_status = bzr status "$@" cvs_status = cvs status "$@" hg_status = hg status "$@" -darcs_status = darcs whatsnew -ls "$@" +darcs_status = darcs whatsnew -ls "$@" || true svn_commit = svn commit "$@" git_commit = git commit -a "$@" && git push --all