]> 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:

better cvs handling approach
[code/myrepos.git] / mr
diff --git a/mr b/mr
index 7c4ff30b56dcc36f19339773e464d430ea3b830a..856de11f4121f112f9377d6f308096ef5c091248 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
@@ -64,7 +66,11 @@ The optional -m parameter allows specifying a commit message.
 
 Show a diff of uncommitted changes.
 
-=item list
+=item log
+
+Show the commit log.
+
+=item list (or ls)
 
 List the repositories that mr will act on.
 
@@ -94,7 +100,7 @@ the current working directory.
 
 =item -c mrconfig
 
-Use the specified mrconfig file, instead of looking for on in your home
+Use the specified mrconfig file, instead of looking for one in your home
 directory.
 
 =item -v
@@ -132,16 +138,16 @@ If the "chain" parameter is set and its command returns nonzero, then B<mr>
 will try to load a .mrconfig file from the root of the repository. (You
 should avoid chaining from repositories with untrusted committers.) The
 "lib" parameter can specify some shell code that will be run before each
-command, this can be a useful way to define shell functions other commands
-can use.
+command, this can be a useful way to define shell functions for other commands
+to use.
 
 The "default" section allows setting up default handlers for each action,
 and is overridden by the contents of other sections. mr contains default
 handlers for the "update", "status", and "commit" actions, so normally
 you only need to specify what to do for "checkout".
 
-The "alias" section allows adding aliases for commands. Each parameter
-is an alias, and its value is the command to run.
+The "alias" section allows adding aliases for actions. Each parameter
+is an alias, and its value is the action to use.
 
 For example:
 
@@ -219,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";
                }
        }
 }
@@ -303,13 +314,19 @@ sub action {
                push @skipped, $dir;
        }
        else {
-               print "mr $action: $dir\n";
+               if (! $nochdir) {
+                       print "mr $action: $dir\n";
+               }
+               else {
+                       print "mr $action: $dir (in subdir $directory)\n";
+               }
                my $command="set -e; ".$lib.
                        "my_action(){ $config{$topdir}{$subdir}{$action} ; }; my_action ".
                        join(" ", map { s/\//\/\//g; s/"/\"/g; '"'.$_.'"' } @ARGV);
+               print STDERR "mr $action: running $command\n" if $verbose;
                my $ret=system($command);
                if ($ret != 0) {
-                       print STDERR "mr $action: failed to run: $command\n" if $verbose;
+                       print STDERR "mr $action: failed ($ret)\n" if $verbose;
                        push @failed, $topdir.$subdir;
                        if ($ret >> 8 != 0) {
                                print STDERR "mr $action: command failed\n";
@@ -450,6 +467,7 @@ __DATA__
 [alias]
        co = checkout
        ci = commit
+       ls = list
 [default]
 lib = \
        error() { \
@@ -461,6 +479,8 @@ update = \
                svn update "$@"; \
        elif [ -d "$MR_REPO"/.git ]; then \
                git pull origin master "$@"; \
+       elif [ -d "$MR_REPO"/CVS ]; then \
+               cvs update "$@"; \
        else \
                error "unknown repo type"; \
        fi
@@ -469,6 +489,8 @@ status = \
                svn status "$@"; \
        elif [ -d "$MR_REPO"/.git ]; then \
                git status "$@" || true; \
+       elif [ -d "$MR_REPO"/CVS ]; then \
+               cvs status "$@"; \
        else \
                error "unknown repo type"; \
        fi
@@ -477,6 +499,8 @@ commit = \
                svn commit "$@"; \
        elif [ -d "$MR_REPO"/.git ]; then \
                git commit -a "$@" && git push --all; \
+       elif [ -d "$MR_REPO"/CVS ]; then \
+               cvs commit "$@"; \
        else \
                error "unknown repo type"; \
        fi
@@ -485,6 +509,18 @@ diff = \
                svn diff "$@"; \
        elif [ -d "$MR_REPO"/.git ]; then \
                git diff "$@"; \
+       elif [ -d "$MR_REPO"/CVS ]; then \
+               cvs diff "$@"; \
+       else \
+               error "unknown repo type"; \
+       fi
+log = \
+       if [ -d "$MR_REPO"/.svn ]; then \
+               svn log"$@"; \
+       elif [ -d "$MR_REPO"/.git ]; then \
+               git log "$@"; \
+       elif [ -d "$MR_REPO"/CVS ]; then \
+               cvs log "$@"; \
        else \
                error "unknown repo type"; \
        fi