All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
7 mr - a Multiple Repository management tool
11 B<mr> [options] checkout
13 B<mr> [options] update
15 B<mr> [options] status
17 B<mr> [options] commit [-m "message"]
23 B<mr> [options] register [repository]
25 B<mr> [options] config section ["parameter=[value]" ...]
27 B<mr> [options] action [params ...]
31 B<mr> is a Multiple Repository management tool. It can checkout, update, or
32 perform other actions on a set of repositories as if they were one combined
33 respository. It supports any combination of subversion, git, cvs, mecurial,
34 bzr and darcs repositories, and support for other revision control systems can
37 B<mr> cds into and operates on all registered repositories at or below your
38 working directory. Or, if you are in a subdirectory of a repository that
39 contains no other registered repositories, it will stay in that directory,
40 and work on only that repository,
42 These predefined commands should be fairly familiar to users of any revision
47 =item checkout (or co)
49 Checks out any repositories that are not already checked out.
53 Updates each repository from its configured remote repository.
55 If a repository isn't checked out yet, it will first check it out.
59 Displays a status report for each repository, showing what
60 uncommitted changes are present in the repository.
64 Commits changes to each repository. (By default, changes are pushed to the
65 remote repository too, when using distributed systems like git.)
67 The optional -m parameter allows specifying a commit message.
71 Show a diff of uncommitted changes.
79 These commands are also available:
85 List the repositories that mr will act on.
89 Register an existing repository in a mrconfig file. By default, the
90 repository in the current directory is registered, or you can specify a
91 directory to register.
93 The mrconfig file that is modified is chosen by either the -c option, or by
94 looking for the closest known one at or below the current directory.
98 Adds, modifies, removes, or prints a value from a mrconfig file. The next
99 parameter is the name of the section the value is in. To add or modify
100 values, use one or more instances of "parameter=value". Use "parameter=" to
101 remove a parameter. Use just "parameter" to get the value of a parameter.
103 For example, to add (or edit) a repository in src/foo:
105 mr config src/foo checkout="svn co svn://example.com/foo/trunk foo"
107 To show the command that mr uses to update the repository in src/foo:
109 mr config src/foo update
111 To see the built-in library of shell functions contained in mr:
113 mr config DEFAULT lib
115 The ~/.mrconfig file is used by default. To use a different config file,
124 Actions can be abbreviated to any unambiguous subsctring, so
125 "mr st" is equivilant to "mr status", and "mr up" is equivilant to "mr
128 Additional parameters can be passed to most commands, and are passed on
129 unchanged to the underlying revision control system. This is mostly useful
130 if the repositories mr will act on all use the same revision control
139 Specifies the topmost directory that B<mr> should work in. The default is
140 the current working directory.
144 Use the specified mrconfig file. The default is B<~/.mrconfig>
152 Expand the statistics line displayed at the end to include information
153 about exactly which repositories failed and were skipped, if any.
157 Just operate on the repository for the current directory, do not
158 recurse into deeper repositories.
162 Run the specified number of jobs in parallel. This can greatly speed up
163 operations such as updates. It is not recommended for interactive
170 B<mr> is configured by .mrconfig files. It starts by reading the .mrconfig
171 file in your home directory, and this can in turn chain load .mrconfig files
174 Here is an example .mrconfig file:
177 checkout = svn co svn://svn.example.com/src/trunk src
181 checkout = git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git &&
183 git checkout -b mybranch origin/master
185 The .mrconfig file uses a variant of the INI file format. Lines starting with
186 "#" are comments. Values can be continued to the following line by
187 indenting the line with whitespace.
189 The "DEFAULT" section allows setting default values for the sections that
192 The "ALIAS" section allows adding aliases for actions. Each parameter
193 is an alias, and its value is the action to use.
195 All other sections add repositories. The section header specifies the
196 directory where the repository is located. This is relative to the directory
197 that contains the mrconfig file, but you can also choose to use absolute
200 Within a section, each parameter defines a shell command to run to handle a
201 given action. mr contains default handlers for "update", "status",
202 "commit", and other standard actions. Normally you only need to specify what
203 to do for "checkout".
205 Note that these shell commands are run in a "set -e" shell
206 environment, where any additional parameters you pass are available in
207 "$@". The "checkout" command is run in the parent of the repository
208 directory, since the repository isn't checked out yet. All other commands
209 are run inside the repository, though not necessarily at the top of it.
211 The "MR_REPO" environment variable is set to the path to the top of the
212 repository. The "MR_CONFIG" environment variable is set to the .mrconfig file
213 that defines the repo being acted on, or, if the repo is not yet in a config
214 file, the .mrconfig file that should be modified to register the repo.
216 A few parameters have special meanings:
222 If the "skip" parameter is set and its command returns true, then B<mr>
223 will skip acting on that repository. The command is passed the action
226 Here are two examples. The first skips the repo unless
227 mr is run by joey. The second uses the hours_since function
228 (included in mr's built-in library) to skip updating the repo unless it's
229 been at least 12 hours since the last update.
231 skip = test $(whoami) != joey
232 skip = [ "$1" = update ] && ! hours_since "$1" 12
236 The "order" parameter can be used to override the default ordering of
237 repositories. The default order value is 10. Use smaller values to make
238 repositories be processed earlier, and larger values to make repositories
241 Note that if a repository is located in a subdirectory of another
242 repository, ordering it to be processed earlier is not recommended.
246 If the "chain" parameter is set and its command returns true, then B<mr>
247 will try to load a .mrconfig file from the root of the repository. (You
248 should avoid chaining from repositories with untrusted committers.)
252 The "lib" parameter can specify some shell code that will be run before each
253 command, this can be a useful way to define shell functions for other commands
258 When looking for a command to run for a given action, mr first looks for
259 a parameter with the same name as the action. If that is not found, it
260 looks for a parameter named "rcs_action" (substituting in the name of the
261 revision control system and the action). The name of the revision control
262 system is itself determined by running each defined "rcs_test" action,
265 Internally, mr has settings for "git_update", "svn_update", etc. To change
266 the action that is performed for a given revision control system, you can
267 override these rcs specific actions. To add a new revision control system,
268 you can just add rcs specific actions for it.
272 Copyright 2007 Joey Hess <joey@kitenet.net>
274 Licensed under the GNU GPL version 2 or higher.
276 http://kitenet.net/~joey/code/mr/
285 use Cwd qw(getcwd abs_path);
295 print STDERR "mr: interrupted\n";
299 $ENV{MR_CONFIG}="$ENV{HOME}/.mrconfig";
300 my $config_overridden=0;
309 my $directory=getcwd();
311 Getopt::Long::Configure("no_permute");
312 my $result=GetOptions(
313 "d|directory=s" => sub { $directory=abs_path($_[1]) },
314 "c|config=s" => sub { $ENV{MR_CONFIG}=$_[1]; $config_overridden=1 },
315 "v|verbose" => \$verbose,
316 "s|stats" => \$stats,
317 "n|no-recurse" => \$no_recurse,
318 "j|jobs=i" => \$jobs,
320 if (! $result || @ARGV < 1) {
321 die("Usage: mr [-d directory] action [params ...]\n".
322 "(Use mr help for man page.)\n");
325 if (! defined $directory) {
326 die("mr: failed to determine working directory\n");
329 # Make sure MR_CONFIG is an absolute path, but don't use abs_path since
330 # the config file might be a symlink to elsewhere, and the directory it's
332 if ($ENV{MR_CONFIG} !~ /^\//) {
333 $ENV{MR_CONFIG}=getcwd()."/".$ENV{MR_CONFIG};
335 # Try to set MR_PATH to the path to the program.
337 use FindBin qw($Bin $Script);
338 $ENV{MR_PATH}=$Bin."/".$Script;
342 loadconfig($ENV{MR_CONFIG});
344 #print Dumper(\%config);
346 # alias expansion and command stemming
347 my $action=shift @ARGV;
348 if (exists $alias{$action}) {
349 $action=$alias{$action};
351 if (! exists $knownactions{$action}) {
352 my @matches = grep { /^\Q$action\E/ }
353 keys %knownactions, keys %alias;
357 elsif (@matches == 0) {
358 die "mr: unknown action \"$action\" (known actions: ".
359 join(", ", sort keys %knownactions).")\n";
362 die "mr: ambiguous action \"$action\" (matches: ".
363 join(", ", @matches).")\n";
367 # commands that do not operate on all repos
368 if ($action eq 'help') {
369 exec($config{''}{DEFAULT}{$action}) || die "exec: $!";
371 elsif ($action eq 'config') {
373 die "mr config: not enough parameters\n";
376 if ($section=~/^\//) {
377 # try to convert to a path relative to the config file
378 my ($dir)=$ENV{MR_CONFIG}=~/^(.*\/)[^\/]+$/;
380 $dir.="/" unless $dir=~/\/$/;
381 if ($section=~/^\Q$dir\E(.*)/) {
387 if (/^([^=]+)=(.*)$/) {
388 $changefields{$1}=$2;
392 foreach my $topdir (sort keys %config) {
393 if (exists $config{$topdir}{$section} &&
394 exists $config{$topdir}{$section}{$_}) {
395 print $config{$topdir}{$section}{$_}."\n";
397 last if $section eq 'DEFAULT';
401 die "mr $action: $section $_ not set\n";
405 modifyconfig($ENV{MR_CONFIG}, $section, %changefields) if %changefields;
408 elsif ($action eq 'register') {
409 if (! $config_overridden) {
410 # Find the closest known mrconfig file to the current
412 $directory.="/" unless $directory=~/\/$/;
413 foreach my $topdir (reverse sort keys %config) {
414 next unless length $topdir;
415 if ($directory=~/^\Q$topdir\E/) {
416 $ENV{MR_CONFIG}=$configfiles{$topdir};
421 my $command="set -e; ".$config{''}{DEFAULT}{lib}."\n".
422 "my_action(){ $config{''}{DEFAULT}{$action}\n }; my_action ".
423 join(" ", map { s/\//\/\//g; s/"/\"/g; '"'.$_.'"' } @ARGV);
424 print STDERR "mr $action: running >>$command<<\n" if $verbose;
425 exec($command) || die "exec: $!";
428 # an ordered list of repos
430 foreach my $topdir (sort keys %config) {
431 foreach my $subdir (sort keys %{$config{$topdir}}) {
435 order => $config{$topdir}{$subdir}{order},
440 $a->{order} <=> $b->{order}
442 $a->{topdir} cmp $b->{topdir}
444 $a->{subdir} cmp $b->{subdir}
447 # work out what repos to act on
450 foreach my $repo (@list) {
451 my $topdir=$repo->{topdir};
452 my $subdir=$repo->{subdir};
454 next if $subdir eq 'DEFAULT';
455 my $dir=($subdir =~/^\//) ? $subdir : $topdir.$subdir;
457 $dir.="/" unless $dir=~/\/$/;
458 $d.="/" unless $d=~/\/$/;
459 next if $no_recurse && $d ne $dir;
460 next if $dir ne $d && $dir !~ /^\Q$d\E/;
461 push @repos, [$dir, $topdir, $subdir];
464 # fallback to find a leaf repo
465 foreach my $repo (reverse @list) {
466 my $topdir=$repo->{topdir};
467 my $subdir=$repo->{subdir};
469 next if $subdir eq 'DEFAULT';
470 my $dir=($subdir =~/^\//) ? $subdir : $topdir.$subdir;
472 $dir.="/" unless $dir=~/\/$/;
473 $d.="/" unless $d=~/\/$/;
474 if ($d=~/^\Q$dir\E/) {
475 push @repos, [$dir, $topdir, $subdir];
482 # run the action on each repository and print stats
483 my (@ok, @failed, @skipped);
488 foreach my $repo (@repos) {
489 record($repo, action($action, @$repo));
492 if (! @ok && ! @failed && ! @skipped) {
493 die "mr $action: no repositories found to work on\n";
495 print "mr $action: finished (".join("; ",
496 showstat($#ok+1, "ok", "ok"),
497 showstat($#failed+1, "failed", "failed"),
498 showstat($#skipped+1, "skipped", "skipped"),
502 print "mr $action: (skipped: ".join(" ", @skipped).")\n";
505 print STDERR "mr $action: (failed: ".join(" ", @failed).")\n";
511 elsif (! @ok && @skipped) {
517 my ($action, $dir, $topdir, $subdir) = @_;
520 foreach my $rcs_test (grep { /_test/ } keys %{$config{$topdir}{$subdir}}) {
521 my ($rcs)=$rcs_test=~/(.*)_test/;
522 $test="my_$rcs_test(){ $config{$topdir}{$subdir}{$rcs_test}\n }\n".$test;
523 $test.="if my_$rcs_test; then echo $rcs; fi\n";
525 $test=$config{$topdir}{$subdir}{lib}."\n".$test
526 if exists $config{$topdir}{$subdir}{lib};
528 print "mr $action: running rcs test >>$test<<\n" if $verbose;
530 $ENV{MR_CONFIG}=$configfiles{$topdir};
541 sub findcommand { #{{{
542 my ($action, $dir, $topdir, $subdir) = @_;
544 my $rcs=rcs_test(@_);
547 exists $config{$topdir}{$subdir}{$rcs."_".$action}) {
548 return $config{$topdir}{$subdir}{$rcs."_".$action};
550 elsif (exists $config{$topdir}{$subdir}{$action}) {
551 return $config{$topdir}{$subdir}{$action};
559 my ($action, $dir, $topdir, $subdir) = @_;
561 $ENV{MR_CONFIG}=$configfiles{$topdir};
562 my $lib=exists $config{$topdir}{$subdir}{lib} ?
563 $config{$topdir}{$subdir}{lib}."\n" : "";
565 if ($action eq 'checkout') {
567 print "mr $action: $dir already exists, skipping checkout\n" if $verbose;
571 $dir=~s/^(.*)\/[^\/]+\/?$/$1/;
574 print "mr $action: creating parent directory $dir\n" if $verbose;
575 system("mkdir", "-p", $dir);
578 elsif ($action =~ /update/) {
580 return action("checkout", $dir, $topdir, $subdir);
586 my $skiptest=findcommand("skip", $dir, $topdir, $subdir);
587 my $command=findcommand($action, $dir, $topdir, $subdir);
589 if (defined $skiptest) {
590 my $test="set -e;".$lib.
591 "my_action(){ $skiptest\n }; my_action '$action'";
592 print "mr $action: running skip test >>$test<<\n" if $verbose;
593 my $ret=system($test);
595 if (($? & 127) == 2) {
596 print STDERR "mr $action: interrupted\n";
600 print STDERR "mr $action: skip test received signal ".($? & 127)."\n";
604 if ($ret >> 8 == 0) {
605 print "mr $action: $dir skipped per config file\n" if $verbose;
610 if (! $nochdir && ! chdir($dir)) {
611 print STDERR "mr $action: failed to chdir to $dir: $!\n";
614 elsif (! defined $command) {
615 my $rcs=rcs_test(@_);
616 if (! defined $rcs) {
617 print STDERR "mr $action: unknown repository type and no defined $action command for $topdir$subdir\n";
621 print STDERR "mr $action: no defined $action command for $rcs repository $topdir$subdir, skipping\n";
627 print "mr $action: $topdir$subdir\n";
631 $s=~s/^\Q$topdir$subdir\E\/?//;
632 print "mr $action: $topdir$subdir (in subdir $s)\n";
634 $command="set -e; ".$lib.
635 "my_action(){ $command\n }; my_action ".
636 join(" ", map { s/\//\/\//g; s/"/\"/g; '"'.$_.'"' } @ARGV);
637 print STDERR "mr $action: running >>$command<<\n" if $verbose;
638 my $ret=system($command);
640 if (($? & 127) == 2) {
641 print STDERR "mr $action: interrupted\n";
645 print STDERR "mr $action: received signal ".($? & 127)."\n";
648 print STDERR "mr $action: failed ($ret)\n" if $verbose;
649 if ($ret >> 8 != 0) {
650 print STDERR "mr $action: command failed\n";
653 print STDERR "mr $action: command died ($ret)\n";
658 if ($action eq 'checkout' && ! -d $dir) {
659 print STDERR "mr $action: $dir missing after checkout\n";;
668 # run actions on multiple repos, in parallel
675 while (@fhs or @repos) {
676 while ($running < $jobs && @repos) {
678 my $repo = shift @repos;
679 pipe(my $outfh, CHILD_STDOUT);
680 pipe(my $errfh, CHILD_STDERR);
682 unless ($pid = fork) {
683 die "mr $action: cannot fork: $!" unless defined $pid;
684 open(STDOUT, ">&CHILD_STDOUT") || die "mr $action cannot reopen stdout: $!";
685 open(STDERR, ">&CHILD_STDERR") || die "mr $action cannot reopen stderr: $!";
690 exit action($action, @$repo);
694 push @active, [$pid, $repo];
695 push @fhs, [$outfh, $errfh];
698 my ($rin, $rout) = ('','');
700 foreach my $fh (@fhs) {
701 next unless defined $fh;
702 vec($rin, fileno($fh->[0]), 1) = 1 if defined $fh->[0];
703 vec($rin, fileno($fh->[1]), 1) = 1 if defined $fh->[1];
705 $nfound = select($rout=$rin, undef, undef, 1);
706 foreach my $channel (0, 1) {
707 foreach my $i (0..$#fhs) {
708 next unless defined $fhs[$i];
709 my $fh = $fhs[$i][$channel];
710 next unless defined $fh;
711 if (vec($rout, fileno($fh), 1) == 1) {
713 if (sysread($fh, $r, 1024) == 0) {
715 $fhs[$i][$channel] = undef;
716 if (! defined $fhs[$i][0] &&
717 ! defined $fhs[$i][1]) {
718 waitpid($active[$i][0], 0);
719 print STDOUT $out[$i][0];
720 print STDERR $out[$i][1];
721 record($active[$i][1], $? >> 8);
723 splice(@active, $i, 1);
728 $out[$i][$channel] .= $r;
736 my $dir=shift()->[0];
743 elsif ($ret == FAILED) {
747 elsif ($ret == SKIPPED) {
750 elsif ($ret == ABORT) {
754 die "unknown exit status $ret";
763 return "$count ".($count > 1 ? $plural : $singular);
769 sub loadconfig { #{{{
776 if (ref $f eq 'GLOB') {
785 my $absf=abs_path($f);
786 if ($loaded{$absf}) {
791 ($dir)=$f=~/^(.*\/)[^\/]+$/;
792 if (! defined $dir) {
795 $dir=abs_path($dir)."/";
797 if (! exists $configfiles{$dir}) {
798 $configfiles{$dir}=$f;
801 # copy in defaults from first parent
803 while ($parent=~s/^(.*\/)[^\/]+\/?$/$1/) {
804 if ($parent eq '/') {
807 if (exists $config{$parent} &&
808 exists $config{$parent}{DEFAULT}) {
809 $config{$dir}{DEFAULT}={ %{$config{$parent}{DEFAULT}} };
814 print "mr: loading config $f\n" if $verbose;
815 open($in, "<", $f) || die "mr: open $f: $!\n";
826 next if /^\s*\#/ || /^\s*$/;
827 if (/^\[([^\]]*)\]\s*$/) {
830 elsif (/^(\w+)\s*=\s*(.*)/) {
835 while (@lines && $lines[0]=~/^\s(.+)/) {
842 if (! defined $section) {
843 die "$f line $.: parameter ($parameter) not in section\n";
845 if ($section ne 'ALIAS' &&
846 ! exists $config{$dir}{$section} &&
847 exists $config{$dir}{DEFAULT}) {
849 $config{$dir}{$section}={ %{$config{$dir}{DEFAULT}} };
851 if ($section eq 'ALIAS') {
852 $alias{$parameter}=$value;
854 elsif ($parameter eq 'lib') {
855 $config{$dir}{$section}{lib}.=$value."\n";
858 $config{$dir}{$section}{$parameter}=$value;
859 $knownactions{$parameter}=1;
860 if ($parameter eq 'chain' &&
861 length $dir && $section ne "DEFAULT" &&
862 -e $dir.$section."/.mrconfig") {
863 my $ret=system($value);
865 if (($? & 127) == 2) {
866 print STDERR "mr $action: chain test interrupted\n";
870 print STDERR "mr $action: chain test received signal ".($? & 127)."\n";
874 push @toload, $dir.$section."/.mrconfig";
880 die "$f line $line: parse error\n";
889 sub modifyconfig { #{{{
891 # the section to modify or add
892 my $targetsection=shift;
893 # fields to change in the section
894 # To remove a field, set its value to "".
901 open(my $in, "<", $f) || die "mr: open $f: $!\n";
906 my $formatfield=sub {
908 my @value=split(/\n/, shift);
910 return "$field = ".shift(@value)."\n".
911 join("", map { "\t$_\n" } @value);
915 while ($out[$#out] =~ /^\s*$/) {
916 unshift @blanks, pop @out;
918 foreach my $field (sort keys %changefields) {
919 if (length $changefields{$field}) {
920 push @out, "$field = $changefields{$field}\n";
921 delete $changefields{$field};
931 if (/^\s*\#/ || /^\s*$/) {
934 elsif (/^\[([^\]]*)\]\s*$/) {
935 if (defined $section &&
936 $section eq $targetsection) {
944 elsif (/^(\w+)\s*=\s(.*)/) {
949 while (@lines && $lines[0]=~/^\s(.+)/) {
955 if ($section eq $targetsection) {
956 if (exists $changefields{$parameter}) {
957 if (length $changefields{$parameter}) {
958 $value=$changefields{$parameter};
960 delete $changefields{$parameter};
964 push @out, $formatfield->($parameter, $value);
968 if (defined $section &&
969 $section eq $targetsection) {
972 elsif (%changefields) {
973 push @out, "\n[$targetsection]\n";
974 foreach my $field (sort keys %changefields) {
975 if (length $changefields{$field}) {
976 push @out, $formatfield->($field, $changefields{$field});
981 open(my $out, ">", $f) || die "mr: write $f: $!\n";
986 # Finally, some useful actions that mr knows about by default.
987 # These can be overridden in ~/.mrconfig.
1004 echo "mr (warning): $@" >&2
1010 if [ -z "$1" ] || [ -z "$2" ]; then
1011 error "mr: usage: hours_since action num"
1013 for dir in .git .svn .bzr CVS .hg _darcs; do
1014 if [ -e "$MR_REPO/$dir" ]; then
1015 flagfile="$MR_REPO/$dir/.mr_last$1"
1019 if [ -z "$flagfile" ]; then
1020 error "cannot determine flag filename"
1022 delta=$(perl -wle 'print -f shift() ? int((-M _) * 24) : 9999' "$flagfile")
1023 if [ "$delta" -lt "$2" ]; then
1032 if [ -d "$1"/.git ] && [ -d "$1"/.git/refs/heads ] &&
1033 [ -d "$1"/.git/objects ] && [ -f "$1"/.git/config ];
1036 elif [ -d "$1"/refs/heads ] && [ -d "$1"/refs/tags ] &&
1037 [ -d "$1"/objects ] && [ -f "$1"/config ]; then
1039 bare="$(GIT_CONFIG="$1"/config git-config --get core.bare)"
1042 false) echo fake-bare;;
1050 svn_test = test -d "$MR_REPO"/.svn
1051 git_test = test -d "$MR_REPO"/.git
1052 bzr_test = test -d "$MR_REPO"/.bzr
1053 cvs_test = test -d "$MR_REPO"/CVS
1054 hg_test = test -d "$MR_REPO"/.hg
1055 darcs_test = test -d "$MR_REPO"/_darcs
1057 svn_update = svn update "$@"
1059 # all this is because of a bug in git-fetch, which requires GIT_DIR set
1060 local git_dir_override; git_dir_override=.git
1061 case "$(get_git_repo_type "$MR_REPO")" in
1062 fake-bare) git_dir_override="$MR_REPO";;
1065 [ -z "$args" ] && args="-t origin master"
1066 eval GIT_DIR="$git_dir_override" git pull "$args"
1067 bzr_update = bzr merge "$@"
1068 cvs_update = cvs update "$@"
1069 hg_update = hg pull "$@" && hg update "$@"
1070 darcs_update = darcs pull -a "$@"
1072 svn_status = svn status "$@"
1073 git_status = git status "$@" || true
1074 bzr_status = bzr status "$@"
1075 cvs_status = cvs status "$@"
1076 hg_status = hg status "$@"
1077 darcs_status = darcs whatsnew -ls "$@"
1079 svn_commit = svn commit "$@"
1081 case "$(get_git_repo_type "$MR_REPO")" in
1082 bare) error "cannot commit to bare git repositories";;
1083 fake-bare) error "commit does not work for fake bare git repositories (yet).";;
1085 git commit -a "$@" && git push --all
1086 bzr_commit = bzr commit "$@" && bzr push
1087 cvs_commit = cvs commit "$@"
1088 hg_commit = hg commit -m "$@" && hg push
1089 darcs_commit = darcs commit -a -m "$@" && darcs push -a
1091 svn_diff = svn diff "$@"
1093 case "$(get_git_repo_type "$MR_REPO")" in
1094 bare) error "cannot diff in bare git repositories";;
1095 fake-bare) error "diff does not work for fake bare git repositories (yet).";;
1098 bzr_diff = bzr diff "$@"
1099 cvs_diff = cvs diff "$@"
1100 hg_diff = hg diff "$@"
1101 darcs_diff = darcs diff "$@"
1103 svn_log = svn log "$@"
1104 git_log = git log "$@"
1105 bzr_log = bzr log "$@"
1106 cvs_log = cvs log "$@"
1107 hg_log = hg log "$@"
1108 darcs_log = darcs changes "$@"
1111 if [ -n "$1" ]; then
1114 basedir="${PWD##*/}"
1115 url=$(LANG=C svn info . | grep -i ^URL: | cut -d ' ' -f 2)
1116 if [ -z "$url" ]; then
1117 error "cannot determine svn url"
1119 echo "Registering svn url: $url in $MR_CONFIG"
1120 mr -c "$MR_CONFIG" config "$PWD" checkout="svn co $url $basedir"
1122 if [ -n "$1" ]; then
1125 basedir="${PWD##*/}"
1126 local repo_type; repo_type="$(get_git_repo_type .)"
1128 case "$repo_type" in
1129 non-bare) config=.git/config;;
1130 bare|fake-bare) config=config;;
1132 url="$(LANG=C GIT_CONFIG="$config" git-config --get remote.origin.url)"
1133 if [ -z "$url" ]; then
1134 error "cannot determine git url"
1136 case "$repo_type" in
1138 # this seems like a bare repo as it has no
1141 work_tree="$(git-config --get core.worktree)" || :
1142 if [ ! -d "$work_tree" ]; then
1143 error "git worktree $work_tree does not exist"
1145 suffix=" (with worktree $work_tree)"
1146 mr -c "$MR_CONFIG" config "$PWD" \
1147 lib="GIT_WORK_TREE=$work_tree; export GIT_WORK_TREE"
1150 echo "Registering git url: $url in $MR_CONFIG${suffix:-}"
1151 mr -c "$MR_CONFIG" config "$PWD" checkout="git clone $url $basedir"
1153 if [ -n "$1" ]; then
1156 basedir="${PWD##*/}"
1157 url=$(cat .bzr/branch/parent)
1158 if [ -z "$url" ]; then
1159 error "cannot determine bzr url"
1161 echo "Registering bzr url: $url in $MR_CONFIG"
1162 mr -c "$MR_CONFIG" config "$PWD" checkout="bzr clone $url $basedir"
1164 if [ -n "$1" ]; then
1167 basedir="${PWD##*/}"
1168 repo=$(cat CVS/Repository)
1169 root=$(cat CVS/Root)
1170 if [ -z "$root" ]; then
1171 error "cannot determine cvs root"
1173 echo "Registering cvs repository $repo at root $root"
1174 mr -c "$MR_CONFIG" config "$PWD" \
1175 checkout="cvs -d '$root' co -d $basedir $repo"
1177 if [ -n "$1" ]; then
1180 basedir="${PWD##*/}"
1181 url=$(hg showconfig paths.default)
1182 echo "Registering mercurial repo url: $url in $MR_CONFIG"
1183 mr -c "$MR_CONFIG" config "$PWD" \
1184 checkout="hg clone $url $basedir"
1186 if [ -n "$1" ]; then
1189 basedir="${PWD##*/}"
1190 url=$(cat _darcs/prefs/defaultrepo)
1191 echo "Registering darcs repository $url in $MR_CONFIG"
1192 mr -c "$MR_CONFIG" config "$PWD" \
1193 checkout="darcs get $url $basedir"
1196 if [ ! -e "$MR_PATH" ]; then
1197 error "cannot find program path"
1199 (pod2man -c mr "$MR_PATH" | man -l -) || error "pod2man or man failed"
1203 ed = echo "A horse is a horse, of course, of course.."
1204 T = echo "I pity the fool."
1205 right = echo "Not found."
1208 # vim:sw=8:sts=0:ts=8:noet