Here is an example .mrconfig file:
[src]
- checkout = svn co svn://svn.example.com/src/trunk src
+ checkout = svn checkout svn://svn.example.com/src/trunk src
chain = true
[src/linux-2.6]
Within a section, each parameter defines a shell command to run to handle a
given action. mr contains default handlers for "update", "status",
-"commit", and other standard actions. Normally you only need to specify what
-to do for "checkout".
+"commit", and other standard actions.
+
+Normally you only need to specify what to do for "checkout". Here you
+specify the command to run in order to create a checkout of the repository.
+The command will be run in the parent directory, and must create the
+repository's directory. So use "git clone", "svn checkout", "bzr branch"
+or "bzr checkout" (for a bound branch), etc.
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
-are run inside the repository, though not necessarily at the top of it.
+"$@". All commands other than "checkout" are run inside the repository,
+though not necessarily at the top of it.
The "MR_REPO" environment variable is set to the path to the top of the
repository. (For the "register" action, "MR_REPO" is instead set to the
print STDERR "mr $hook: received signal ".($? & 127)."\n";
return ABORT;
}
+ else {
+ return FAILED;
+ }
}
return OK;
is_trusted_repo($words[$c])
);
}
- elsif (defined $words[$c] && $twords[$c] eq $words[$c]) {
+ elsif (defined $words[$c] && $words[$c]=~/^($twords[$c])$/) {
$match=1;
}
else {
}
if (! $trusted) {
- # Untrusted files can only contain checkout
- # parameters.
- if ($parameter ne 'checkout') {
- trusterror("mr: illegal setting \"$parameter=$value\"", $f, $line, $bootstrap_url);
+ # Untrusted files can only contain a few
+ # settings in specific known-safe formats.
+ if ($parameter eq 'checkout') {
+ if (! is_trusted_checkout($value)) {
+ trusterror("mr: illegal checkout command \"$value\"", $f, $line, $bootstrap_url);
+ }
+ }
+ elsif ($parameter eq 'order') {
+ # not interpreted as a command, so
+ # safe.
+ }
+ elsif ($value eq 'true' || $value eq 'false') {
+ # skip=true , deleted=true etc are
+ # safe.
}
- if (! is_trusted_checkout($value)) {
- trusterror("mr: illegal checkout command \"$value\"", $f, $line, $bootstrap_url);
+ else {
+ trusterror("mr: illegal setting \"$parameter=$value\"", $f, $line, $bootstrap_url);
}
}
$knownactions{$parameter}=1;
}
if ($parameter eq 'chain' &&
- length $dir && $section ne "DEFAULT" &&
- -e $dir.$section."/.mrconfig") {
- my $ret=system($value);
- if ($ret != 0) {
- if (($? & 127) == 2) {
- print STDERR "mr: chain test interrupted\n";
- exit 2;
+ length $dir && $section ne "DEFAULT") {
+ my $chaindir="$section";
+ if ($chaindir !~ m!/!) {
+ $chaindir=$dir.$chaindir;
+ }
+ if (-e "$chaindir/.mrconfig") {
+ my $ret=system($value);
+ if ($ret != 0) {
+ if (($? & 127) == 2) {
+ print STDERR "mr: chain test interrupted\n";
+ exit 2;
+ }
+ elsif ($? & 127) {
+ print STDERR "mr: chain test received signal ".($? & 127)."\n";
+ }
}
- elsif ($? & 127) {
- print STDERR "mr: chain test received signal ".($? & 127)."\n";
+ else {
+ push @toload, ["$chaindir/.mrconfig", $chaindir];
}
}
- else {
- push @toload, $dir.$section."/.mrconfig";
- }
}
}
}
}
}
- foreach (@toload) {
- loadconfig($_);
+ foreach my $c (@toload) {
+ loadconfig(@$c);
}
}
return 0
fi
}
+ is_bzr_checkout() {
+ LANG=C bzr info | egrep -q '^Checkout'
+ }
svn_test = test -d "$MR_REPO"/.svn
git_test = test -d "$MR_REPO"/.git
svn_update = svn update "$@"
git_update = git pull "$@"
-bzr_update = bzr merge --pull "$@"
+bzr_update =
+ if is_bzr_checkout; then
+ bzr update "$@"
+ else
+ bzr merge --pull "$@"
+ fi
cvs_update = cvs update "$@"
hg_update = hg pull "$@" && hg update "$@"
darcs_update = darcs pull -a "$@"
svn_commit = svn commit "$@"
git_commit = git commit -a "$@" && git push --all
-bzr_commit = bzr commit "$@" && bzr push
+bzr_commit =
+ if is_bzr_checkout; then
+ bzr commit "$@"
+ else
+ bzr commit "$@" && bzr push
+ fi
cvs_commit = cvs commit "$@"
hg_commit = hg commit -m "$@" && hg push
darcs_commit = darcs record -a -m "$@" && darcs push -a
fossil_commit = fossil commit "$@"
git_record = git commit -a "$@"
-bzr_record = bzr commit "$@"
+bzr_record =
+ if is_bzr_checkout; then
+ bzr commit --local "$@"
+ else
+ bzr commit "$@"
+ fi
hg_record = hg commit -m "$@"
darcs_record = darcs record -a -m "$@"
fossil_record = fossil commit "$@"
error "cannot determine bzr url"
fi
echo "Registering bzr url: $url in $MR_CONFIG"
- mr -c "$MR_CONFIG" config "`pwd`" checkout="bzr clone '$url' '$MR_REPO'"
+ mr -c "$MR_CONFIG" config "`pwd`" checkout="bzr branch '$url' '$MR_REPO'"
cvs_register =
repo=`cat CVS/Repository`
root=`cat CVS/Root`
svn_trusted_checkout = svn co $url $repo
svn_alt_trusted_checkout = svn checkout $url $repo
git_trusted_checkout = git clone $url $repo
-bzr_trusted_checkout = bzr clone $url $repo
+bzr_trusted_checkout = bzr checkout|clone|branch|get $url $repo
# cvs: too hard
hg_trusted_checkout = hg clone $url $repo
darcs_trusted_checkout = darcs get $url $repo