updated git and svn scripts
[xrzperl.git] / svn-dump-change-author
blob1048ac0307f7f99653bce7c8e68c756a25bf9a87
1 #!/usr/bin/perl -w
3 use strict;
4 use warnings;
6 my $old_exp = shift;
7 my $new_exp = shift;
8 if(!$new_exp) {
9 print STDERR "Usage:$0 <old_author_exp> <new_author_exp> [svn_dump_file]\n";
10 exit 0;
13 while (<>) {
14 print;
15 next unless /^Revision-number:\s+\d+$/;
17 # Grab the content lengths. Examples:
18 # Prop-content-length: 139
19 # Content-length: 139
20 my $plen_line = <>;
21 my $clen_line = <>;
23 unless ( $plen_line =~ /^Prop-content-length:\s+\d+$/ ) {
24 # Nothing we want to change.
25 print $plen_line, $clen_line;
26 next;
29 my @lines;
30 while ( <> ) {
31 if ( /^PROPS-END$/ ) {
32 # finish.
33 print $plen_line, $clen_line, @lines, $_;
34 last;
37 push @lines, $_;
39 if ( /^svn:author$/ ) {
40 # Grab the author content length. Example:
41 # V 6
42 my $alen_line = <>;
44 # Grab the author name.
45 my $auth = <>;
46 my $old_length = length($auth);
47 print STDERR '<',"$auth\n";
48 if ( $auth =~ s/$old_exp/$new_exp/ ) {
49 my $new_length = length($auth);
50 # Adjust the content lengths.
51 for my $line ( $plen_line, $clen_line, $alen_line ) {
52 $line =~ s/(\d+)$/$1 + $new_length - $old_length/e;
54 print STDERR '>',"$auth\n";
56 print $plen_line, $clen_line, @lines, $alen_line, $auth;
57 last;