# # To determine what changed in the doc set on TWiki.org we have to guess # what the baseline document was. This is because Cairo was generated by # a _manual_ copy of the docs (with a manual edit) into a new, hidden # web. The docs on twiki.org and the docs used for Cairo are mutant # crossbreeds of eachother. # # The best we can do is to establish the differences between the latest # docs on twiki.org and the rev of those docs that existed at the time # Cairo was released. # # So, for each doc, we have to: # get the cairo rev of the doc from a local Cairo install # determine what the date of that rev is # get the # of the rev of the doc at that date from twiki.org TWiki web # diff that rev against the latest rev on TWiki.org # # The results are saved locally. use strict; use LWP; use Time::ParseDate; # Path to local cairo install my $cairoDir = '/home/twiki/cairo'; # Get list of topics in Cairo install my @topics; opendir(DIR, $cairoDir.'/data/TWiki'); push(@topics, map { $_ =~ s/\.txt$//; $_; } grep { /\.txt$/ && -e $cairoDir.'/data/TWiki/'.$_.',v' } readdir DIR ); closedir(DIR); # foreach topic foreach my $doc ( @topics ) { next if $doc =~ /^Web/; next if $doc =~ /^TWikiPreferences/; next if $doc =~ /^TWikiDocumentation/; next if $doc =~ /Plugin$/; next if $doc =~ /Contrib$/; next if -e "${doc}diff.html"; # get the cairo rev number my $cairorev = `rlog $cairoDir/data/TWiki/$doc.txt`; $cairorev =~ s/^.*?revision\s+1.(\d+)\s+.*?\ndate:\s+(\S+\s+\S+);.*$/$1/s; # convert it to a date my $cairodate = $2; print "$doc $cairodate $cairorev\n"; $cairodate = Time::ParseDate::parsedate($cairodate); # get the complete history of the doc from twiki.org my $userAgent = new LWP::UserAgent(); $userAgent->agent( 'SPAM' ); my $response = $userAgent->get( 'http://twiki.org/cgi-bin/rdiff/TWiki/'.$doc.'?render=raw' ); die 'Failed to GET ',$doc,' ', $response->request->uri, ' -- ', $response->status_line, "\n".'Aborting' unless $response->is_success; my $text = $response->content(); # find the rev number at that date on twiki.org my( $rev, $day, $month, $year, $latest ) = ( 0, 0, 0, 0, 0 ); while( $text =~ s(Difference Topic.*?>r1.(\d+) - (\d+) (\w+) (\d+))()s ) { ( $rev, $day, $month, $year ) = ( $1, $2, $3, $4 ); $latest = $rev unless $latest; my $time = Time::ParseDate::parsedate("$day $month $year"); last if( $time < $cairodate ); } # get the diff between that rev and the latest rev my $url = 'http://twiki.org/cgi-bin/rdiff/TWiki/'.$doc.'?rev1=1.'.$rev.';rev2=1.'.$latest; print "GET $url\n"; $response = $userAgent->get( $url ); die 'Failed to GET ',$doc,' ', $response->request->uri, ' -- ', $response->status_line, "\n".'Aborting' unless $response->is_success; # store the result locally for later reference open(F, ">${doc}diff.html"); print F $response->content(); close(F); } 1;