NAME

SVN::Dumpfilter - Perl extension to filter Subversion dumpfiles

SYNOPSIS

use SVN::Dumpfilter;

sub my_filter (\%;$);
my $dumpfile = shift @ARGV; # filename or '-' for STDIN
my $outfile  = shift @ARGV; # filename or '-' for STDOUT

Dumpfilter($dumpfile, $outfile, \&my_filter);

sub my_filter (\%;$)
 {
   my $href   = shift;
   my $recalc = shift || 0;
   my $header = $href->{'header'};
   my $prop   = $href->{'properties'};

   # Do something (modify, add, delete) with the current node given by the
   # hash ref $href
   # e.g.:
   if (exists $header->{Node-path})
    {
     $header->{Node-path} =~ s/OLD/NEW/;
     $recalc = 1;
    }

   # The node content is accessible as scalar with ${$href->{content}}
   # Can be in every possible text or binary format.

   if ($recalc)
    {
     svn_recalc_prop_header(%$href);        # call if you changed properties
     svn_recalc_textcontent_header(%$href); # call if you modified text content
    }
 }


To filter a dumpfile:
shell #  svnadmin create /path/to/new/repository
shell #  svnadmin dump /path/to/repository | my_svndumpfilter - - | svnadmin load /path/to/new/repository

DESCRIPTION

SVN::Dumpfilter reads a Subversion (http://subversion.tigris.org/) dumpfile. The file is parsed and a call-back subfunction is called with a hash-reference for every 'node'. This function can modify, add or delete headers, properties and the content of the node. After processing of the call-back function the node is re-assembled and stored in an output file.

The parse and re-assemble processes are done by dedicated subfunctions which can be also exported ('internal' tag) for special filters (e.g. merging filter which has to write the output file by its own).

The node hash looks like this for a normal node:

$href = { 'content' => \'(content)', # scalar ref 'properties_order' => [], # array ref (helps with verification, but not needed) 'properties' => {}, # hash ref 'header' => { # hash ref 'Content-length' => '922', 'Text-content-length' => 922, 'Node-action' => 'change', 'Node-kind' => 'file', 'Node-path' => 'trunk/filename.pl', 'Text-content-md5' => 'c7ed3072d412de68da477350f8e8056f' } };

and like this for a revision node:

$href = { 'properties_order' => [ 'svn:log', 'svn:author', 'svn:date' ], 'properties' => { 'svn:log' => 'Log message, ...', 'svn:date' => '2006-05-10T13:31:40.486172Z', 'svn:author' => 'martin' }, 'header' => { 'Content-length' => '151', 'Prop-content-length' => 151, 'Revision-number' => '58' } };

EXPORT

By default:

&Dumpfilter &svn_recalc_content_header &svn_recalc_textcontent_header &svn_recalc_prop_header

Tags:

'recalc'

svn_recalc_content_header svn_recalc_textcontent_header svn_recalc_prop_header

'filters'

dos2unix_filter null_filter null_recalc_filter

'internal'

svn_read_entry svn_print_entry svn_get_properties svn_props2str svn_header_sanitycheck

SEE ALSO

Authors Module Website: http://www.scharrer-online.de/svn/dumpfilter.shtml

AUTHOR

Martin Scharrer, <martin@scharrer-online.de>; http://www.scharrer-online.de/

COPYRIGHT AND LICENSE

Copyright (C) 2006-2008 by Martin Scharrer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.