]> git.madduck.net Git - code/myrepos.git/blobdiff - mr

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

add log command
[code/myrepos.git] / mr
diff --git a/mr b/mr
index b1139e5b2a12f0e908d278fdf18ccac0112e2327..fd0ba15748c8f9e82442368a5d19e583ac84e5be 100755 (executable)
--- a/mr
+++ b/mr
@@ -16,6 +16,8 @@ B<mr> [options] commit [-m "message"]
 
 B<mr> [options] diff
 
+B<mr> [options] log
+
 B<mr> [options] action [params ...]
 
 =head1 DESCRIPTION
@@ -28,6 +30,11 @@ respository.
 Any mix of revision control systems can be used with B<mr>, and you can
 define arbitrary actions for commands like "update", "checkout", or "commit".
 
+B<mr> cds into and operates on all registered repsitories at or below your
+working directory. Or, if you are in a subdirectory of a repository that
+contains no other registered repositories, it will stay in that directory,
+and work on only that repository,
+
 The predefined commands should be fairly familiar to users of any revision
 control system:
 
@@ -59,6 +66,10 @@ The optional -m parameter allows specifying a commit message.
 
 Show a diff of uncommitted changes.
 
+=item log
+
+Show the commit log.
+
 =item list
 
 List the repositories that mr will act on.
@@ -70,11 +81,8 @@ Displays this help.
 =back
 
 Actions can be abbreviated to any unambiguous subsctring, so
-"mr st" is equivilant to "mr status".
-
-B<mr> operates on all registered repsitories at or below your working
-directory. Or, if you are in a subdirectory of a repository that contains
-no other registered repositories, it will act on only that repository.
+"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.
@@ -217,8 +225,13 @@ if (! exists $knownactions{$action}) {
                if (@matches == 1) {
                        $action=$matches[0];
                }
+               elsif (@matches == 0) {
+                       die "mr: unknown action \"$action\" (known actions: ".
+                               join(", ", sort keys %knownactions).")\n";
+               }
                else {
-                       die "mr: ambiguous action \"$action\" (matches @matches)\n";
+                       die "mr: ambiguous action \"$action\" (matches: ".
+                               join(", ", @matches).")\n";
                }
        }
 }
@@ -232,6 +245,7 @@ my @repos;
 my $nochdir=0;
 foreach my $topdir (sort keys %config) {
        foreach my $subdir (sort keys %{$config{$topdir}}) {
+               next if $subdir eq 'default';
                my $dir=$topdir.$subdir;
                next if $dir ne $directory && $dir !~ /^\Q$directory\E\//;
                push @repos, [$dir, $topdir, $subdir];
@@ -239,20 +253,20 @@ foreach my $topdir (sort keys %config) {
 }
 if (! @repos) {
        # fallback to find a leaf repo
-       foreach my $topdir (sort keys %config) {
-               foreach my $subdir (sort keys %{$config{$topdir}}) {
+       LEAF: foreach my $topdir (reverse sort keys %config) {
+               foreach my $subdir (reverse sort keys %{$config{$topdir}}) {
+                       next if $subdir eq 'default';
                        my $dir=$topdir.$subdir;
                        my $d=$directory;
                        $dir.="/" unless $dir=~/\/$/;
                        $d.="/" unless $d=~/\/$/;
                        if ($d=~/^\Q$dir\E/) {
                                push @repos, [$dir, $topdir, $subdir];
+                               last LEAF;
                        }
                }
        }
-       if (@repos > 1) {
-               die "mr: found multiple leaf repos (should never happen)";
-       }
+       $nochdir=1;
 }
 
 my (@failed, @successful, @skipped);
@@ -485,6 +499,14 @@ diff = \
        else \
                error "unknown repo type"; \
        fi
+log = \
+       if [ -d "$MR_REPO"/.svn ]; then \
+               svn log"$@"; \
+       elif [ -d "$MR_REPO"/.git ]; then \
+               git log "$@"; \
+       else \
+               error "unknown repo type"; \
+       fi
 list = true
 help = \
        if [ ! -e "$MR_PATH" ]; then \