# An obsession with data (Subversion edition) => .. Up a Level # ## Setup ## ## Directives use strict; use warnings; ## ## Input Process ## ## Since this was all in one Subversion tree, we just pipe “svn log” to ## the input. my $last_timestamp = “undef”; my %files = (); while () { # Clean up the line and ignore blanks. chomp; next if /^s*$/; # In general, we will have two types of lines. One is in a # timestamp and the other is the name of the file. # rd+ | user | 2010-07-10 21:45:57 -0500 (Sat, 10 Jul 2010) | 1 line if (/(d+)-(d+)-(d+) (d+):(d+):(d+)/) { # We only care about the date of the check-in. $last_timestamp = “$1-$2-$3”; } else { # For everything else, we get a filename. There are a few # things that we frequently ignore, such as hidden files # (start with a period). s/^s+//sg; unless (/^(M|A|D)s+(.*?)$/) { # An unkown line, so skip it. next; } ``` # We add the file and the current timestamp to the # hash. Since we replace with each one, and `git log` goes # backwards in time, the last time we see the file is the # point it was first added to the repository. # Print out the line. my $file = $2; $file =~ s/s*(.*?$//; $files{$file} = $last_timestamp; } ``` } ## Now that we are done parsing, we output the merged results. open REPORT, “>svn.files” or die "Cannot write svn.files ($!)"; foreach my $file (sort(keys(%files))) { # Pull out the date. my $date = $files{$file}; # Keep track if this file exists. my $exists = 0; # They don't exist in this case $exists = 1 if -f “$dir/$file”; ``` #print "$filet$daten"; #print "$datet$existst$filen"; ``` print REPORT “$filet$existst$daten”; } close REPORT; # Metadata Categories: => /categories/programming/ Programming => /categories/writing/ Writing Tags: => /tags/perl/ Perl # Footer Below are various useful links within this site and to related sites (not all have been converted over to Gemini). => /now/ Now => /contact/ Contact => /bio/ Biography => /bibliography/ Bibliography => /support/ Support => /fiction/ Fiction => //fedran.com/ Fedran => https://mfgames.com/ Coding => https://moonfire.us/ The Moonfires => /categories/ Categories => /tags/ Tags => /privacy/ Privacy => /colophon/ Colophon => /license/ License => https://lists.typewriter.press/subscription?f=RDQ6f3AFHXnX2o763d5TgUmaYP7N763gR6FjZyGUUFWhyRkpgZF9I35ySICDBEdFFtgG Mailing List => https://d.moonfire.us/blog/2012/04/28/an-obsession-with-data-subversion-edition/