Adding some scripts I wrote to help to the CVS/SVN to Git migration.
authorGerald (Jerry) Carter <jerry@samba.org>
Mon, 15 Oct 2007 12:28:54 +0000 (07:28 -0500)
committerGerald (Jerry) Carter <jerry@samba.org>
Mon, 15 Oct 2007 12:28:54 +0000 (07:28 -0500)
fix-commiter.pl    -> Cleanup the committer listed in the *dat files
      created by cvs2svn got git-fast-import
fix-svn-log.pl    -> Trim preceeding whitespace from the body of "svn
      log --incremental -r$REV"
strip_revisions.sh -> Strip CVSIN from the svn log output and generate
      a list of revision IDs.
svn-janitor.sh    -> Wrapper around fix-svn-log.pl to interate through all
      revisions in an SVN repo.
parse_git_revs.pl  -> Generate a set of hashs to be cherry-picked from
      a list of SVN revision numbers included in the commit
      msg from git-svnimport (1.5.3.4).

scripts/fix-commiter.pl [new file with mode: 0755]
scripts/fix-svn-log.pl [new file with mode: 0755]
scripts/parse_git_revs.pl [new file with mode: 0755]
scripts/strip_revisions.sh [new file with mode: 0755]
scripts/svn-janitor.sh [new file with mode: 0755]

diff --git a/scripts/fix-commiter.pl b/scripts/fix-commiter.pl
new file mode 100755 (executable)
index 0000000..edaf828
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+
+my %authors;
+
+open(AUTHORS, "< $ARGV[0]") || die @!;
+while (<AUTHORS>) {
+    chomp($_);
+    $_ =~ s/\s+=\s+/=/;
+    ($name, $userinfo) = split(/=/, $_);
+    $authors{$name} = $userinfo;
+}
+close(AUTHORS);
+
+open(INDATA, "< $ARGV[1]") || die @!;
+while (<INDATA>) {
+    chomp($_);
+    if ($_ =~ /^committer /) {
+       @lineinfo = split(/ /, $_);
+       if (!defined($authors{$lineinfo[1]})) {
+           die "No entry for \"$lineinfo[1]\" in $ARGV[0]!\n";
+       }
+       ($realname, $emailaddr) = split(/</, $authors{$lineinfo[1]});
+       $realname =~ s/\s+$//g;
+       $emailaddr =~ s/^\s+//;
+       print "committer $realname <$emailaddr  $lineinfo[3] $lineinfo[4]\n";
+    } else {
+       print "$_\n";
+    }
+}
+close(INDATA);
diff --git a/scripts/fix-svn-log.pl b/scripts/fix-svn-log.pl
new file mode 100755 (executable)
index 0000000..8f42ff9
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/perl -w
+
+my ($i, $body, $modified);
+
+for ($i=0; $i<3; $i++) {
+    <STDIN>;
+}
+
+while (<STDIN>) {
+    last if (!($_ =~ /^\s+$/));
+    $modified = 1;
+}
+
+$body = "$_";
+while (<STDIN>) {
+    $body = "$body$_";
+}
+
+print "$body" if (defined($modified));
diff --git a/scripts/parse_git_revs.pl b/scripts/parse_git_revs.pl
new file mode 100755 (executable)
index 0000000..2551267
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/perl -w
+
+my ($rev, $revlist, $badrevlist);
+
+open(REVS, "< $ARGV[0]") || die @!;
+while (<REVS>) {
+    chomp($_);
+    $revlist{$_} = 1;
+}
+close(REVS);
+
+open(BADREVS, "< $ARGV[1]") || die @!;
+while (<BADREVS>) {
+    chomp($_);
+    $badrevlist{$_} = "BADREV_";
+}
+close(BADREVS);
+
+
+while (<STDIN>) {
+    chomp($_);
+    $_ =~ s/^\s+//;
+
+    if ($_ =~ /^commit [a-f0-9]/) {
+       $_ =~ s/^commit //;
+       $hash = $_;
+       undef $rev;
+    } elsif ($_ =~ /^r[0-9]+:/) {
+       $_ =~ s/:.*//;
+       $_ =~ s/^r//;
+       $rev = $_;
+
+       if (defined($revlist{$rev}) > 0) {
+           print "$badrevlist{$rev}" if (defined($badrevlist{$rev}));
+           print "$hash\n";
+       }
+    }
+}
+
diff --git a/scripts/strip_revisions.sh b/scripts/strip_revisions.sh
new file mode 100755 (executable)
index 0000000..dd7a2fd
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cat $1 | grep ^r[1-9] | grep -v CVSIN | awk '{print $1}' | sed 's/^r//' > $1.revisions
+
diff --git a/scripts/svn-janitor.sh b/scripts/svn-janitor.sh
new file mode 100755 (executable)
index 0000000..466c880
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+for rev in `seq 1 25600`; do
+       svn log -r$rev --incremental file:///data/src/mirror/svn/samba | ./fix-svn-log.pl > $rev
+       if [ ! -s $rev ]; then
+               /bin/rm $rev
+       else
+               echo "r$rev"
+               svnadmin setlog --bypass-hooks /data/src/mirror/svn/samba -r$rev $rev
+       fi
+done