[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Add dump_fs2 and load_fs2 to perl bindings

From: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: 2006-10-16 15:56:29 CEST

Hyrum K. Wright wrote:
> Ping...
>
> Has anybody had a chance to look at Troy's patch? If nobody does
> anything with it in the next few days, I'll file an issue.

Filed as issue 2632.

-Hyrum

> Troy Curtis Jr wrote:
>> [[[
>> Add the updated dump_fs2 and load_fs2 functions to the SVN::Repos perl
>> module
>> along with some documentation for these functions.
>>
>> * subversion/bindings/swig/perl/native/Repos.pm:
>> (@methods): Added 'dump_fs2' and 'load_fs2' to be exported as
>> SVN::Repos::dump_fs2 and SVN::Repos::load_fs2.
>> (POD Documentation): Added entries documenting dump_fs2 and load_fs2.
>> ]]]
>>
>> I wanted to create a deltified dump of a repository in my perl script
>> and found that 'dump_fs2' was not immediately available. It turns out
>> all I had to do was put its entry into the list of methods to export
>> to perl and it worked! So while I was at it, I did 'load_fs2' also.
>>
>> I had to dig a little bit to figure out what to use in the
>> 'uuid_action' parameter for 'load_fs2', so I decided to save the next
>> guy some work and added some POD documentation for these two
>> functions. It is my first foray into the POD format, so someone might
>> want to look over it real fast :-).
>>
>> Troy S. Curtis, Jr.
>>
>>
>> ------------------------------------------------------------------------
>>
>> Index: Repos.pm
>> ===================================================================
>> --- Repos.pm (revision 21690)
>> +++ Repos.pm (working copy)
>> @@ -38,6 +38,110 @@
>> API. Functions taking svn_repos_t * as the first inbound argument
>> could be used as methods of the object returned by open or create.
>>
>> +=over
>> +
>> +=item $repos-E<gt>dump_fs($dump_fh, $feedback_fh, $start_rev, $end_rev, $incremental, $cancel_func, $cancel_baton)
>> +
>> +=item $repos-E<gt>dump_fs2($dump_fh, $feedback_fh, $start_rev, $end_rev, $incremental, $deltify, $cancel_func, $cancel_baton)
>> +
>> +Create a dump file of the repository from revision C<$start_rev> to C<$end_rev>
>> +, store it into the filehandle C<$dump_fh>, and write feedback on the progress
>> +of the operation to filehandle C<$feedback_fh>.
>> +
>> +If C<$incremental> is TRUE, the first revision dumped will be a diff
>> +against the previous revision (usually it looks like a full dump of
>> +the tree).
>> +
>> +If C<$use_deltas> is TRUE, output only node properties which have
>> +changed relative to the previous contents, and output text contents
>> +as svndiff data against the previous contents. Regardless of how
>> +this flag is set, the first revision of a non-incremental dump will
>> +be done with full plain text. A dump with @a use_deltas set cannot
>> +be loaded by Subversion 1.0.x.
>> +
>> +According to svn_repos.h, the C<$cancel_func> is a function that is called
>> +periodically and given C<$cancel_baton> as a parameter to determine whether the
>> +client wishes to cancel the dump. I have not tested this functionality, but
>> +you must supply C<undef> at the very least.
>> +
>> +Example:
>> +
>> + use SVN::Core;
>> + use SVN::Repos;
>> +
>> + my $repos = SVN::Repos::open ('/repo/sandbox');
>> +
>> + open my $fh, ">/tmp/tmp.dump" or die "Cannot open file: $!\n";
>> +
>> + my $start_rev = 10;
>> + my $end_rev = 20;
>> + my $incremental = 1;
>> + my $deltify = 1;
>> +
>> + $repos->dump_fs2($fh, \*STDOUT, # Dump file => $fh, Feedback => STDOUT
>> + $start_rev, $end_rev, # Revision Range
>> + $incremental, $deltify, # Options
>> + undef, undef); # Cancel Function
>> +
>> + close $fh;
>> +
>> +=item $repos->load_fs($dumpfile_fh, $feedback_fh, $uuid_action, $parent_dir, $cancel_func, $cancel_baton);
>> +
>> +=item $repos->load_fs2($dumpfile_fh, $feedback_fh, $uuid_action, $parent_dir, $use_pre_commit_hook, $use_post_commit_hook, $cancel_func, $cancel_baton);
>> +
>> +Loads a dumpfile specified by the C<$dumpfile_fh> filehandle into the repository.
>> +If the dumpstream contains copy history that is unavailable in the repository,
>> +an error will be thrown.
>> +
>> +The repository's UUID will be updated iff the dumpstream contains a UUID and
>> +C<$uuid_action> is not equal to C<$SVN::Repos::load_uuid_ignore> and either the
>> +repository contains no revisions or C<$uuid_action> is equal to
>> +C<$SVN::Repos::load_uuid_force>.
>> +
>> +If the dumpstream contains no UUID, then C<$uuid_action> is
>> +ignored and the repository UUID is not touched.
>> +
>> +If C<$parent_dir> is not null, then the parser will reparent all the
>> +loaded nodes, from root to @a parent_dir. The directory C<$parent_dir>
>> +must be an existing directory in the repository.
>> +
>> +If C<$use_pre_commit_hook> is set, call the repository's pre-commit
>> +hook before committing each loaded revision.
>> +
>> +If C<$use_post_commit_hook> is set, call the repository's
>> +post-commit hook after committing each loaded revision.
>> +
>> +According to svn_repos.h:
>> +If C<$cancel_func> is not NULL, it is called periodically with
>> +C<$cancel_baton> as argument to see if the client wishes to cancel
>> +the load.
>> +
>> +I have not tested this functionality (and I am not sure how to do so), but
>> +you must at least provide undef for these parameters for the method call
>> +to work.
>> +
>> +Example:
>> + use SVN::Core;
>> + use SVN::Repos;
>> +
>> + my $repos = SVN::Repos::open ('/repo/test_repo');
>> +
>> + open my $fh, "/repo/sandbox.dump" or die "Cannot open file: $!\n";
>> +
>> + my $parent_dir = '/';
>> + my $use_pre_commit_hook = 0;
>> + my $use_post_commit_hook = 0;
>> +
>> + $repos->load_fs2($fh, \*STDOUT,
>> + $SVN::Repos::load_uuid_ignore, # Ignore uuid
>> + $parent_dir,
>> + $use_pre_commit_hook, # Use pre-commit hook?
>> + $use_post_commit_hook, # Use post-commit hook?
>> + undef, undef);
>> +
>> +
>> + close $fh;
>> +
>> =cut
>>
>> package _p_svn_repos_t;
>> @@ -49,7 +153,7 @@
>> pre_revprop_change_hook post_revprop_change_hook
>> dated_revision fs_commit_txn fs_begin_txn_for_commit
>> fs_begin_txn_for_update fs_change_rev_prop
>> - node_editor dump_fs load_fs get_fs_build_parser/;
>> + node_editor dump_fs dump_fs2 load_fs load_fs2 get_fs_build_parser/;
>>
>> for (@methods) {
>> no strict 'refs';

Received on Mon Oct 16 15:57:24 2006

This is an archived mail posted to the Subversion Dev mailing list.