You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2013/04/05 10:50:31 UTC
svn commit: r1464891 - in /subversion/trunk/subversion/bindings/swig:
include/svn_containers.swg include/svn_types.swg
python/libsvn_swig_py/swigutil_py.c python/libsvn_swig_py/swigutil_py.h
python/tests/client.py
Author: philip
Date: Fri Apr 5 08:50:30 2013
New Revision: 1464891
URL: http://svn.apache.org/r1464891
Log:
Add SWIG python support for inherited properties with svn_client_propget5
and svn_client_proplist4.
* subversion/bindings/swig/include/svn_containers.swg:
(OUTPUT_OF_PROP_INHERITED_ITEM): New.
* subversion/bindings/swig/include/svn_types.swg
(svn_proplist_receiver2_t): New.
* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h
* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
(svn_swig_py_propinheriteditemarray_to_dict,
svn_swig_py_proplist_receiver2): New.
* subversion/bindings/swig/python/tests/client.py
(test_inherited_props): New.
Modified:
subversion/trunk/subversion/bindings/swig/include/svn_containers.swg
subversion/trunk/subversion/bindings/swig/include/svn_types.swg
subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h
subversion/trunk/subversion/bindings/swig/python/tests/client.py
Modified: subversion/trunk/subversion/bindings/swig/include/svn_containers.swg
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/include/svn_containers.swg?rev=1464891&r1=1464890&r2=1464891&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/include/svn_containers.swg (original)
+++ subversion/trunk/subversion/bindings/swig/include/svn_containers.swg Fri Apr 5 08:50:30 2013
@@ -421,6 +421,19 @@
*/
/* -----------------------------------------------------------------------
+ Output of apr_array_header_t * <svn_prop_inherited_item_t *>
+*/
+#ifdef SWIGPYTHON
+%typemap(argout) apr_array_header_t **OUTPUT_OF_PROP_INHERITED_ITEM {
+ %append_output(svn_swig_py_propinheriteditemarray_to_dict(*$1));
+}
+
+%apply apr_array_header_t **OUTPUT_OF_PROP_INHERITED_ITEM {
+ apr_array_header_t **inherited_props
+};
+#endif
+
+/* -----------------------------------------------------------------------
Output of apr_array_header_t * <svn_prop_t *>
*/
#ifdef SWIGRUBY
Modified: subversion/trunk/subversion/bindings/swig/include/svn_types.swg
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/include/svn_types.swg?rev=1464891&r1=1464890&r2=1464891&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/include/svn_types.swg (original)
+++ subversion/trunk/subversion/bindings/swig/include/svn_types.swg Fri Apr 5 08:50:30 2013
@@ -906,6 +906,17 @@ svn_ ## TYPE ## _swig_rb_closed(VALUE se
#endif
/* -----------------------------------------------------------------------
+ Callback: svn_proplist_receiver2_t
+*/
+#ifdef SWIGPYTHON
+%typemap(in) (svn_proplist_receiver2_t receiver, void *receiver_baton)
+{
+ $1 = svn_swig_py_proplist_receiver2;
+ $2 = (void *)$input;
+}
+#endif
+
+/* -----------------------------------------------------------------------
Callback: svn_fs_warning_callback_t
*/
Modified: subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c?rev=1464891&r1=1464890&r2=1464891&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c (original)
+++ subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c Fri Apr 5 08:50:30 2013
@@ -709,6 +709,48 @@ PyObject *svn_swig_py_mergeinfo_catalog_
return convert_hash(hash, convert_mergeinfo_hash, type, py_pool);
}
+PyObject *
+svn_swig_py_propinheriteditemarray_to_dict(const apr_array_header_t *array)
+{
+ PyObject *dict = PyDict_New();
+ int i;
+
+ if (dict == NULL)
+ return NULL;
+
+ for (i = 0; i < array->nelts; ++i)
+ {
+ svn_prop_inherited_item_t *prop_inherited_item
+ = APR_ARRAY_IDX(array, i, svn_prop_inherited_item_t *);
+ apr_hash_t *prop_hash = prop_inherited_item->prop_hash;
+ PyObject *py_key, *py_value;
+
+ py_key = PyString_FromString(prop_inherited_item->path_or_url);
+ if (py_key == NULL)
+ goto error;
+
+ py_value = svn_swig_py_prophash_to_dict(prop_hash);
+ if (py_value == NULL)
+ {
+ Py_DECREF(py_key);
+ goto error;
+ }
+
+ if (PyDict_SetItem(dict, py_key, py_value) == -1)
+ {
+ Py_DECREF(py_value);
+ Py_DECREF(py_key);
+ goto error;
+ }
+ }
+
+ return dict;
+
+ error:
+ Py_DECREF(dict);
+ return NULL;
+}
+
PyObject *svn_swig_py_proparray_to_dict(const apr_array_header_t *array)
{
PyObject *dict = PyDict_New();
@@ -2588,6 +2630,88 @@ svn_error_t *svn_swig_py_repos_history_f
}
+svn_error_t *svn_swig_py_proplist_receiver2(void *baton,
+ const char *path,
+ apr_hash_t *prop_hash,
+ apr_array_header_t *inherited_props,
+ apr_pool_t *pool)
+{
+ PyObject *receiver = baton;
+ PyObject *py_pool;
+ PyObject *py_props;
+ PyObject *py_iprops;
+ PyObject *result;
+ svn_error_t *err = SVN_NO_ERROR;
+
+ if ((receiver == NULL) || (receiver == Py_None))
+ return SVN_NO_ERROR;
+
+ svn_swig_py_acquire_py_lock();
+
+ py_pool = make_ob_pool(pool);
+ if (py_pool == NULL)
+ {
+ err = callback_exception_error();
+ goto finished;
+ }
+
+ if (prop_hash)
+ {
+ py_props = svn_swig_py_prophash_to_dict(prop_hash);
+ if (py_props == NULL)
+ {
+ err = type_conversion_error("apr_hash_t *");
+ Py_DECREF(py_pool);
+ goto finished;
+ }
+ }
+ else
+ {
+ py_props = Py_None;
+ Py_INCREF(Py_None);
+ }
+
+ if (inherited_props)
+ {
+ py_iprops = svn_swig_py_propinheriteditemarray_to_dict(inherited_props);
+ if (py_iprops == NULL)
+ {
+ err = type_conversion_error("apr_array_header_t *");
+ Py_DECREF(py_props);
+ Py_DECREF(py_pool);
+ goto finished;
+ }
+ }
+ else
+ {
+ py_iprops = Py_None;
+ Py_INCREF(Py_None);
+ }
+
+ result = PyObject_CallFunction(receiver,
+ (char *)"sOOO",
+ path, py_props, py_iprops, py_pool);
+ if (result == NULL)
+ {
+ err = callback_exception_error();
+ }
+ else
+ {
+ if (result != Py_None)
+ err = callback_bad_return_error("Not None");
+ Py_DECREF(result);
+ }
+
+ Py_DECREF(py_props);
+ Py_DECREF(py_iprops);
+ Py_DECREF(py_pool);
+
+finished:
+ svn_swig_py_release_py_lock();
+ return err;
+}
+
+
svn_error_t *svn_swig_py_log_receiver(void *baton,
apr_hash_t *changed_paths,
svn_revnum_t rev,
Modified: subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h?rev=1464891&r1=1464890&r2=1464891&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h (original)
+++ subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h Fri Apr 5 08:50:30 2013
@@ -215,6 +215,13 @@ apr_array_header_t *svn_swig_py_proparra
SVN_SWIG_SWIGUTIL_EXPORT
PyObject *svn_swig_py_proparray_to_dict(const apr_array_header_t *array);
+/* helper function to convert a 'apr_array_header_t *' of
+ 'svn_prop_inherited_item_t' to a Python dictionary mapping strings
+ to dictionary. */
+SVN_SWIG_SWIGUTIL_EXPORT
+PyObject *
+svn_swig_py_propinheriteditemarray_to_dict(const apr_array_header_t *array);
+
/* helper function to convert a Python dictionary mapping strings to
strings into an apr_hash_t mapping const char *'s to svn_string_t's,
allocated in POOL. */
@@ -399,6 +406,14 @@ svn_error_t *svn_swig_py_log_entry_recei
svn_log_entry_t *log_entry,
apr_pool_t *pool);
+/* thunked proplist receiver2 function */
+SVN_SWIG_SWIGUTIL_EXPORT
+svn_error_t *svn_swig_py_proplist_receiver2(void *baton,
+ const char *path,
+ apr_hash_t *prop_hash,
+ apr_array_header_t *inherited_props,
+ apr_pool_t *pool);
+
/* thunked info receiver function */
SVN_SWIG_SWIGUTIL_EXPORT
svn_error_t *svn_swig_py_info_receiver_func(void *py_receiver,
Modified: subversion/trunk/subversion/bindings/swig/python/tests/client.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/python/tests/client.py?rev=1464891&r1=1464890&r2=1464891&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/python/tests/client.py (original)
+++ subversion/trunk/subversion/bindings/swig/python/tests/client.py Fri Apr 5 08:50:30 2013
@@ -397,6 +397,37 @@ class SubversionClientTestCase(unittest.
core.svn_auth_set_gnome_keyring_unlock_prompt_func(self.client_ctx.auth_baton, prompt_func)
+ def test_inherited_props(self):
+ """Test inherited props"""
+
+ trunk_url = self.repos_uri + '/trunk'
+ client.propset_remote('svn:global-ignores', '*.q', trunk_url,
+ False, 12, {}, None, self.client_ctx)
+
+ head = core.svn_opt_revision_t()
+ head.kind = core.svn_opt_revision_head
+ props, iprops, rev = client.propget5('svn:global-ignores', trunk_url,
+ head, head, core.svn_depth_infinity,
+ None, self.client_ctx)
+ self.assertEquals(props[trunk_url], '*.q\n')
+
+ dir1_url = trunk_url + '/dir1'
+ props, iprops, rev = client.propget5('svn:global-ignores', dir1_url,
+ head, head, core.svn_depth_infinity,
+ None, self.client_ctx)
+ self.assertEquals(iprops[trunk_url], {'svn:global-ignores':'*.q\n'})
+
+ def proplist_receiver_trunk(path, props, iprops, pool):
+ self.assertEquals(props['svn:global-ignores'], '*.q\n')
+ client.proplist4(trunk_url, head, head, core.svn_depth_empty, None, True,
+ proplist_receiver_trunk, self.client_ctx)
+
+ def proplist_receiver_dir1(path, props, iprops, pool):
+ self.assertEquals(iprops[trunk_url], {'svn:global-ignores':'*.q\n'})
+ client.proplist4(dir1_url, head, head, core.svn_depth_empty, None, True,
+ proplist_receiver_dir1, self.client_ctx)
+
+
def suite():
return unittest.defaultTestLoader.loadTestsFromTestCase(
SubversionClientTestCase)