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

SWIG (Perl) prospective patch

From: John Beranek <john_at_redux.org.uk>
Date: Tue, 16 Jun 2009 13:21:09 +0100

Hello all,

So I've just started using the Subversion API, from Perl. Currently have
  Subversion 1.6.1 rebuilt from a source RPM on my Fedora 10 development
system.

Was looking into examining transactions in a pre-commit hook, using the
Perl Subversion API.

Got some way down the road and got to _p_svn_fs_root_t->paths_changed()
(aka svn_fs_paths_changed() in the C API).

Started reading the C API and discovered svn_fs_paths_changed2() which
returns the seemingly valuable extra info that svn_fs_path_change2_t was
created to add in Subversion 1.6.

So, wanted to call this from Perl, only to find the Perl bindings didn't
implement that call.

After much ado the attached patch is my attempt at adding said call to
the SWIG bindings for Perl. There are a few provisos/apologies:

* This is a patch against the Subversion 1.6.1 code from the SRPM I
started from, not trunk or any Subversion branch.
* I'm not convinced of the change to svn_fs.h and svn_fs.i, whether this
is the way to achieve what I've done.
* I've not yet written complete Perldoc for my additions to SVN::Fs.
* I've tested the additions and ->copyfrom_path() and ->copyfrom_rev()
and they return what's expected if the change is indeed a copy. If the
change isn't a copy ->copyfrom_known() still appears to be true, and
->copyfrom_path()/->copyfrom_rev() just return empty. Is this as
expected, the C API docs are far from clear here?

Right, I hope this is helpful to someone...

Cheers,

John.

-- 
John Beranek                         To generalise is to be an idiot.
http://redux.org.uk/                                 -- William Blake
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2362435

diff -r -U 5 subversion-1.6.1/subversion/bindings/swig/perl/native/Fs.pm subversion-1.6.1-modified/subversion/bindings/swig/perl/native/Fs.pm
--- subversion-1.6.1/subversion/bindings/swig/perl/native/Fs.pm 2006-09-13 14:23:59.000000000 +0100
+++ subversion-1.6.1-modified/subversion/bindings/swig/perl/native/Fs.pm 2009-06-16 11:07:37.000000000 +0100
@@ -257,10 +257,18 @@
 The keys are the paths of the files changed, starting with C</> to
 indicate the top-level directory of the repository. The values
 are C<_p_svn_fs_path_change_t> objects which contain information about
 what kind of changes are made.
 
+=item $root-E<gt>paths_changed2()
+
+A reference to a hash indicating what changes are made in the root.
+The keys are the paths of the files changed, starting with C</> to
+indicate the top-level directory of the repository. The values
+are C<_p_svn_fs_path_change2_t> objects which contain information about
+what kind of changes are made.
+
 =item $root-E<gt>revision_link
 
 =item $root-E<gt>revision_root_revision
 
 Revision number of the revision the root comes from.
@@ -274,11 +282,11 @@
                  check_path close_root copied_from copy
                  dir_entries delete file_contents closest_copy
                  file_length file_md5_checksum is_dir is_file
                  is_revision_root is_txn_root make_dir make_file
                  node_created_rev node_history node_id node_prop
- node_proplist paths_changed revision_link
+ node_proplist paths_changed paths_changed2 revision_link
                  revision_root_revision/;
 
 *fs = *SVN::Fs::root_fs;
 *txn_name = *_p_svn_fs_txn_t::root_name;
 
@@ -479,6 +487,12 @@
 =cut
 
 package SVN::Fs::PathChange;
 use SVN::Base qw(Fs svn_fs_path_change_);
 
+package _p_svn_fs_path_change2_t;
+use SVN::Base qw(Fs svn_fs_path_change2_t_);
+
+package SVN::Fs::PathChange2;
+use SVN::Base qw(Fs svn_fs_path_change2_);
+
 1;
diff -r -U 5 subversion-1.6.1/subversion/bindings/swig/svn_fs.i subversion-1.6.1-modified/subversion/bindings/swig/svn_fs.i
--- subversion-1.6.1/subversion/bindings/swig/svn_fs.i 2009-02-13 16:48:08.000000000 +0000
+++ subversion-1.6.1-modified/subversion/bindings/swig/svn_fs.i 2009-06-16 12:47:16.000000000 +0100
@@ -55,10 +55,11 @@
 %apply svn_stream_t *WRAPPED_STREAM { svn_stream_t * };
 #endif
 
 %hash_argout_typemap(entries_p, svn_fs_dirent_t *)
 %hash_argout_typemap(changed_paths_p, svn_fs_path_change_t *)
+%hash_argout_typemap(changed_paths2_p, svn_fs_path_change2_t *)
 
 #ifndef SWIGPERL
 %callback_typemap(svn_fs_get_locks_callback_t get_locks_func,
                   void *get_locks_baton,
                   svn_swig_py_fs_get_locks_func,
diff -r -U 5 subversion-1.6.1/subversion/include/svn_fs.h subversion-1.6.1-modified/subversion/include/svn_fs.h
--- subversion-1.6.1/subversion/include/svn_fs.h 2009-02-16 20:35:25.000000000 +0000
+++ subversion-1.6.1-modified/subversion/include/svn_fs.h 2009-06-16 12:47:36.000000000 +0100
@@ -1135,11 +1135,11 @@
  * Use @c pool for all allocations, including the hash and its values.
  *
  * @since New in 1.6.
  */
 svn_error_t *
-svn_fs_paths_changed2(apr_hash_t **changed_paths_p,
+svn_fs_paths_changed2(apr_hash_t **changed_paths2_p,
                       svn_fs_root_t *root,
                       apr_pool_t *pool);
 
 
 /** Same as svn_fs_paths_changed2(), only with @c svn_fs_path_change_t * values
Received on 2009-06-16 14:30:51 CEST

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.