From d8cb44c340a78c32b330372703aa274d1c0f28fa Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sat, 31 Jan 2009 20:31:58 -0500 Subject: [PATCH] import geofft's script for importing the doc wiki password excised in favor of reading /mit/sipb-www/.my.cnf --- import-trac | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 import-trac diff --git a/import-trac b/import-trac new file mode 100755 index 0000000..1d1656f --- /dev/null +++ b/import-trac @@ -0,0 +1,38 @@ +#!/usr/bin/perl +use DBI; +use IPC::Open2; + +$password = qx(perl -F= -lane 'print \$F[1] if (\$F[0] eq "password")' \\ + /mit/sipb-www/.my.cnf); +chomp $password; +$dbh = DBI->connect('DBI:mysql:sipb-www+doc;host=sql.mit.edu', + 'sipb-www', $password) or die; +$rows = $dbh->selectall_arrayref('SELECT * FROM wiki', {Slice=>{}}); +foreach $row (@$rows) { + next if $row->{author} eq 'trac'; + print "Processing revision $row->{version} of $row->{name} by $row->{author}..."; + + $pid = open2(OUT, IN, qw(git hash-object -w --stdin)); + print IN $row->{text}; + close(IN); + chomp($blob = ); + waitpid $pid, 0; + + $pid = open2(OUT, IN, qw(git mktree)); + print IN `git ls-tree $head | grep -v $row->{name}` if $head; + print IN "100644 blob $blob\t$row->{name}\n"; + close(IN); + chomp($tree = ); + waitpid $pid, 0; + + $ENV{GIT_AUTHOR_NAME} = "$row->{author} via Trac"; + $ENV{GIT_AUTHOR_EMAIL} = "$row->{author}\@mit.edu"; + $ENV{GIT_AUTHOR_DATE} = $row->{time}; + $pid = open2(OUT, IN, qw{git commit-tree}, $tree, $head ? ('-p', $head) : ()); + print IN $row->{comment}; + close(IN); + chomp($head = ); + waitpid $pid, 0; + + print "committed as $head.\n"; +} -- 2.45.0