#!/usr/bin/perl # parse the historic CHANGESTODO.txt file and produce # a csv according to csv2trac format: # # 12 Each line in the CSV file needs to have the following entries # 13 type text -- the ticket purpose # 14 time integer -- the time it was created # 15 changetime integer # 16 component text # 17 severity text # 18 priority text # 19 owner text -- who is this ticket assigned to # 20 reporter text # 21 cc text -- email addresses to notify # 22 url text -- url related to this ticket # 23 version text -- # 24 milestone text -- # 25 status text # 26 resolution text # 27 summary text -- one-line summary # 28 description text -- problem description (long) # 29 keywords text use locale; my $changestodofile = shift or die 'Please provide path to CHANGESTODO.txt'; open(I, "/usr/bin/expand $changestodofile |") or die "Failed to /usr/bin/expand $changestodofile"; print < 'defect', '+' => 'enhancement', '*' => 'task', '?' => 'question', # needs to be added by trac-admin ); sub output { return unless $first; my $t = $types{$type}; die 'no type' unless $t; $summary = ($first && $sub) ? "$sub: $first" : ($first || $sub); die 'expand failed' if $summary =~ /\t/ or $text =~ /\t/; # $summary =~ s/\t/ /gm; # $text =~ s/\t/ /gm; $text =~ s/\n/\\n/gm; my $mytime = 1234567890; print <; # skip first line while () { next if /^[_¯]+$/; next if /^\|/; if ( /^== (.+) =====/ ) { &output; $headline = $1; undef $sub; next; } if ( /^(-|\+|\?|\*) (.+)$/ ) { &output; $type = $1; $first = "$1 $2"; next; } if ( /^\> (.+)$/ ) { &output; $sub = $1; # print STDERR $_; next; } if ( /^\>\>\>/ ) { &output; undef $sub; next; } if ( /^=+$/ ) { &output; exit; } # if ( /^ (.+)$/ or /^\t(.+)$/ ) { # $text .= $1; # next; # } $text .= $_; # print STDERR; }