B<mr> [options] log
+B<mr> [options] register repository
+
B<mr> [options] config section [parameter=[value] ...]
B<mr> [options] action [params ...]
List the repositories that mr will act on.
+=item register
+
+The next parameter is the directory of an existing repository. The
+repository will be registered in the mrconfig file.
+
=item config
Modifies the mrconfig file. The next parameter is the name of the section
to add or modify, and it is followed by one or more instances of
-"parameter=value". Use "parameter=" to remove a parameter. For example,
-to register a new svn repository in src/foo:
+"parameter=value". Use "parameter=" to remove a parameter.
+
+For example, to register a new svn repository in src/foo:
mr config src/foo checkout="svn co svn://example.com/foo/trunk"
}
if ($action eq 'help') {
- exec($config{''}{DEFAULT}{help});
+ exec($config{''}{DEFAULT}{$action}) || die "exec: $!";
}
elsif ($action eq 'config') {
if (@ARGV < 2) {
die "mr config: not enough parameters\n";
}
my $section=shift;
+ if ($section=~/^\//) {
+ # try to convert to a path relative to $config's dir
+ my ($dir)=$config=~/^(.*\/)[^\/]+$/;
+ if ($section=~/^\Q$dir\E(.*)/) {
+ $section=$1;
+ }
+ }
my %fields;
foreach (@ARGV) {
if (/^([^=]+)=(.*)$/) {
modifyconfig($config, $section, %fields);
exit 0;
}
+elsif ($action eq 'register') {
+ my $command="set -e; ".$config{''}{DEFAULT}{lib}."\n".
+ "my_action(){ $config{''}{DEFAULT}{$action}\n }; my_action ".
+ join(" ", map { s/\//\/\//g; s/"/\"/g; '"'.$_.'"' } @ARGV);
+ print STDERR "mr $action: running >>$command<<\n" if $verbose;
+ exec($command) || die "exec: $!";
+}
# work out what repos to act on
my @repos;
$dir="";
}
else {
- # $f might be a symlink
my $absf=abs_path($f);
if ($loaded{$absf}) {
return;
else \
error "unknown repo type" \
fi
+register = \
+ if [ -z "$1" ]; then \
+ error "repository directory not specified" \
+ fi \
+ cd "$1" \
+ basedir="$(basename $(pwd))" \
+ if [ -d .svn ]; then \
+ url=$(svn info . | \
+ grep -i ^URL: | cut -d ' ' -f 2) \
+ if [ -z "$url" ]; then \
+ error "cannot determine svn url" \
+ fi \
+ echo "Found svn url: $url" \
+ mr config "$(pwd)" checkout="svn co $url $basedir" \
+ elif [ -d .git ]; then \
+ url=$(git-config --get remote.origin.url) \
+ if [ -z "$url" ]; then \
+ error "cannot determine git url" \
+ fi \
+ echo "Found git url: $url" \
+ mr config "$(pwd)" checkout="git clone $url $basedir" \
+ else \
+ error "unable to register this repo type" \
+ fi
list = true
config =
help = \