X-Git-Url: https://git.madduck.net/code/myrepos.git/blobdiff_plain/cab31c75dc608d3567c07c616c2cd84f7be2ce3e..af1ece782ef8ad328a97bed416a2793f9c56fc35:/mr?ds=sidebyside diff --git a/mr b/mr index 235c175..8eb0374 100755 --- a/mr +++ b/mr @@ -18,6 +18,8 @@ B [options] diff B [options] log +B [options] register repository + B [options] config section [parameter=[value] ...] B [options] action [params ...] @@ -76,14 +78,20 @@ Show the commit log. 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. - mr config src/foo checkout="svn co svn://example.com/foo/trunk" +For example, to add (or edit) a repository in src/foo: + + mr config src/foo checkout="svn co svn://example.com/foo/trunk foo" =item help @@ -95,10 +103,10 @@ Actions can be abbreviated to any unambiguous subsctring, so "mr st" is equivilant to "mr status", and "mr up" is equivilant to "mr update" -Additional parameters can be passed to other commands than "commit", they -will be passed on unchanged to the underlying revision control system. -This is mostly useful if the repositories mr will act on all use the same -revision control system. +Additional parameters can be passed to most commands, and are passed on +unchanged to the underlying revision control system. This is mostly useful +if the repositories mr will act on all use the same revision control +system. =head1 OPTIONS @@ -259,13 +267,20 @@ if (! exists $knownactions{$action}) { } 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 (/^([^=]+)=(.*)$/) { @@ -278,6 +293,13 @@ elsif ($action eq 'config') { 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; @@ -441,7 +463,6 @@ sub loadconfig { $dir=""; } else { - # $f might be a symlink my $absf=abs_path($f); if ($loaded{$absf}) { return; @@ -675,6 +696,30 @@ log = \ 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 "Registering 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 "Registering git url: $url" \ + mr config "$(pwd)" checkout="git clone $url $basedir" \ + else \ + error "unable to register this repo type" \ + fi list = true config = help = \