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

reword
[code/myrepos.git] / mr
diff --git a/mr b/mr
index ff5b60d867c620bf0d00abae2f0eb8d36e86f756..f14ba4dddebfd38fb55f9a823e7cea2e7050b2b2 100755 (executable)
--- a/mr
+++ b/mr
@@ -415,9 +415,13 @@ to keep track of and remember to delete old repositories.
 
 =item lib
 
 
 =item lib
 
-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 for other commands
-to use.
+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 for other commands to use. 
+
+Unlike most other parameters, this can be specified multiple times, in
+which case the chunks of shell code are accumulatively concatenated
+together.
 
 =item fixups
 
 
 =item fixups
 
@@ -426,14 +430,7 @@ is checked out, or updated. This provides an easy way to do things
 like permissions fixups, or other tweaks to the repository content,
 whenever the repository is changed.
 
 like permissions fixups, or other tweaks to the repository content,
 whenever the repository is changed.
 
-=item pre_ and post_
-
-If a "pre_action" parameter is set, its command is run before mr performs the
-specified action. Similarly, "post_action" parameters are run after mr
-successfully performs the specified action. For example, "pre_commit" is
-run before committing; "post_update" is run after updating.
-
-=back
+=item VCS_action
 
 When looking for a command to run for a given action, mr first looks for
 a parameter with the same name as the action. If that is not found, it
 
 When looking for a command to run for a given action, mr first looks for
 a parameter with the same name as the action. If that is not found, it
@@ -447,6 +444,21 @@ the action that is performed for a given version control system, you can
 override these VCS specific actions. To add a new version control system,
 you can just add VCS specific actions for it.
 
 override these VCS specific actions. To add a new version control system,
 you can just add VCS specific actions for it.
 
+=item pre_ and post_
+
+If a "pre_action" parameter is set, its command is run before mr performs the
+specified action. Similarly, "post_action" parameters are run after mr
+successfully performs the specified action. For example, "pre_commit" is
+run before committing; "post_update" is run after updating.
+
+=item _append
+
+Any parameter can be suffixed with C<_append>, to add an additional value
+to the existing value of the parameter. In this way, actions 
+can be constructed accumulatively.
+
+=back
+
 =head1 UNTRUSTED MRCONFIG FILES
 
 Since mrconfig files can contain arbitrary shell commands, they can do
 =head1 UNTRUSTED MRCONFIG FILES
 
 Since mrconfig files can contain arbitrary shell commands, they can do
@@ -1107,20 +1119,6 @@ sub is_trusted_checkout {
        return 0;
 }
 
        return 0;
 }
 
-sub trusterror {
-       my ($err, $file, $line, $url)=@_;
-       
-       if (defined $url) {
-               die "$err in untrusted $url line $line\n".
-                       "(To trust this url, --trust-all can be used; but please use caution;\n".
-                       "this can allow arbitrary code execution!)\n";
-       }
-       else {
-               die "$err in untrusted $file line $line\n".
-                       "(To trust this file, list it in ~/.mrtrust.)\n";
-       }
-}
-
 my %loaded;
 sub loadconfig {
        my $f=shift;
 my %loaded;
 sub loadconfig {
        my $f=shift;
@@ -1185,30 +1183,43 @@ sub loadconfig {
 
        # Keep track of the current line in the config file;
        # when a file is included track the current line from the include.
 
        # Keep track of the current line in the config file;
        # when a file is included track the current line from the include.
-       my $line=0;
+       my $lineno=0;
        my $included=undef;
        my $included=undef;
-       my $includeline=0;
+
+       my $line;
        my $nextline = sub {
                if ($included) {
        my $nextline = sub {
                if ($included) {
-                       $includeline++;
                        $included--;
                }
                else {
                        $included=undef;
                        $included--;
                }
                else {
                        $included=undef;
-                       $includeline=0;
-                       $line++;
+                       $lineno++;
                }
                }
-               my $l=shift @lines;
-               chomp $l;
-               return $l
+               $line=shift @lines;
+               chomp $line;
+               return $line;
        };
        my $lineerror = sub {
                my $msg=shift;
                if (defined $included) {
        };
        my $lineerror = sub {
                my $msg=shift;
                if (defined $included) {
-                       die "mr: $f line $line include line $includeline: $msg\n";
+                       die "mr: $msg at $f line $lineno, included line: $line\n";
+               }
+               else {
+                       die "mr: $msg at $f line $lineno\n";
+               }
+       };
+       my $trusterror = sub {
+               my $msg=shift;
+               my ($err, $file, $lineno, $url)=@_;
+       
+               if (defined $bootstrap_url) {
+                       die "mr: $err in untrusted $bootstrap_url line $lineno\n".
+                               "(To trust this url, --trust-all can be used; but please use caution;\n".
+                               "this can allow arbitrary code execution!)\n";
                }
                else {
                }
                else {
-                       die "mr: $f line $line: $msg\n";
+                       die "mr: $err in untrusted $file line $lineno\n".
+                               "(To trust this file, list it in ~/.mrtrust.)\n";
                }
        };
 
                }
        };
 
@@ -1216,7 +1227,7 @@ sub loadconfig {
                $_=$nextline->();
 
                if (! $trusted && /[[:cntrl:]]/) {
                $_=$nextline->();
 
                if (! $trusted && /[[:cntrl:]]/) {
-                       trusterror("mr: illegal control character", $f, $line, $bootstrap_url);
+                       $trusterror->("illegal control character");
                }
 
                next if /^\s*\#/ || /^\s*$/;
                }
 
                next if /^\s*\#/ || /^\s*$/;
@@ -1227,7 +1238,7 @@ sub loadconfig {
                                if (! is_trusted_repo($section) ||
                                    $section eq 'ALIAS' ||
                                    $section eq 'DEFAULT') {
                                if (! is_trusted_repo($section) ||
                                    $section eq 'ALIAS' ||
                                    $section eq 'DEFAULT') {
-                                       trusterror("mr: illegal section \"[$section]\"", $f, $line, $bootstrap_url)
+                                       $trusterror->("illegal section \"[$section]\"");
                                }
                        }
                        $section=expandenv($section) if $trusted;
                                }
                        }
                        $section=expandenv($section) if $trusted;
@@ -1254,7 +1265,7 @@ sub loadconfig {
                                # settings in specific known-safe formats.
                                if ($parameter eq 'checkout') {
                                        if (! is_trusted_checkout($value)) {
                                # 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);
+                                               $trusterror->("illegal checkout command \"$value\"");
                                        }
                                }
                                elsif ($parameter eq 'order') {
                                        }
                                }
                                elsif ($parameter eq 'order') {
@@ -1266,7 +1277,7 @@ sub loadconfig {
                                        # safe.
                                }
                                else {
                                        # safe.
                                }
                                else {
-                                       trusterror("mr: illegal setting \"$parameter=$value\"", $f, $line, $bootstrap_url);
+                                       $trusterror->("illegal setting \"$parameter=$value\"");
                                }
                        }
 
                                }
                        }
 
@@ -1287,8 +1298,8 @@ sub loadconfig {
                        if ($section eq 'ALIAS') {
                                $alias{$parameter}=$value;
                        }
                        if ($section eq 'ALIAS') {
                                $alias{$parameter}=$value;
                        }
-                       elsif ($parameter eq 'lib') {
-                               $config{$dir}{$section}{lib}.=$value."\n";
+                       elsif ($parameter eq 'lib' or $parameter =~ s/_append$//) {
+                               $config{$dir}{$section}{$parameter}.="\n".$value."\n";
                        }
                        else {
                                $config{$dir}{$section}{$parameter}=$value;
                        }
                        else {
                                $config{$dir}{$section}{$parameter}=$value;
@@ -1970,3 +1981,7 @@ T = echo "I pity the fool."
 right = echo "Not found."
 
 # vim:sw=8:sts=0:ts=8:noet
 right = echo "Not found."
 
 # vim:sw=8:sts=0:ts=8:noet
+# Local variables:
+# indent-tabs-mode: t
+# cperl-indent-level: 8
+# End: