SOURCES: subversion-python_bindings.patch (NEW) - New file: patch ...

japhy japhy at pld-linux.org
Sun Jul 22 02:09:14 CEST 2007


Author: japhy                        Date: Sun Jul 22 00:09:14 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- New file: patch for Subversion Python bindings to make it work with bzr-svn.

---- Files affected:
SOURCES:
   subversion-python_bindings.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/subversion-python_bindings.patch
diff -u /dev/null SOURCES/subversion-python_bindings.patch:1.1
--- /dev/null	Sun Jul 22 02:09:14 2007
+++ SOURCES/subversion-python_bindings.patch	Sun Jul 22 02:09:09 2007
@@ -0,0 +1,949 @@
+Source: http://samba.org/~metze/subversion-1.4.0-metze-python-bindings.patch
+diff -Npur subversion-1.4.0-clean/subversion/bindings/swig/include/apr.swg subversion-1.4.0-patch1/subversion/bindings/swig/include/apr.swg
+--- subversion-1.4.0-clean/subversion/bindings/swig/include/apr.swg	2005-10-25 06:39:49.000000000 +0200
++++ subversion-1.4.0-patch1/subversion/bindings/swig/include/apr.swg	2007-01-26 17:54:33.463524500 +0100
+@@ -146,14 +146,24 @@ typedef apr_int32_t time_t;
+ 
+ /* -----------------------------------------------------------------------
+    create an OUTPUT argument defn for an apr_hash_t ** which is storing
++   dirent values
++*/
++%typemap(python,in,numinputs=0) apr_hash_t **DIRENTHASH = apr_hash_t **OUTPUT;
++%typemap(python,argout,fragment="t_output_helper") apr_hash_t **DIRENTHASH {
++    $result = t_output_helper($result,
++                              svn_swig_py_convert_hash(*$1, 
++                                                       SWIGTYPE_p_svn_dirent_t,
++                                                       NULL));
++}
++
++/* -----------------------------------------------------------------------
++   create an OUTPUT argument defn for an apr_hash_t ** which is storing
+    property values
+ */
+ 
+ %typemap(python,in,numinputs=0) apr_hash_t **PROPHASH = apr_hash_t **OUTPUT;
+-%typemap(python,argout) apr_hash_t **PROPHASH {
+-    /* toss prior result, get new result from the hash */
+-    Py_DECREF($result);
+-    $result = svn_swig_py_prophash_to_dict(*$1);
++%typemap(python,argout,fragment="t_output_helper") apr_hash_t **PROPHASH {
++    $result = t_output_helper($result, svn_swig_py_prophash_to_dict(*$1));
+ }
+ 
+ %typemap(perl5,in,numinputs=0) apr_hash_t **PROPHASH = apr_hash_t **OUTPUT;
+diff -Npur subversion-1.4.0-clean/subversion/bindings/swig/include/proxy_apr.swg subversion-1.4.0-patch1/subversion/bindings/swig/include/proxy_apr.swg
+--- subversion-1.4.0-clean/subversion/bindings/swig/include/proxy_apr.swg	2006-03-05 08:31:48.000000000 +0100
++++ subversion-1.4.0-patch1/subversion/bindings/swig/include/proxy_apr.swg	2007-01-26 17:54:33.795545250 +0100
+@@ -159,6 +159,28 @@ struct apr_pool_t {
+           del self._parent_pool
+         if hasattr(self, "_is_valid"):
+           del self._is_valid
++        
++        # Clear out any pool-owned references inserted by typemaps
++        if hasattr(self, "_owned_refs"):
++          del self._owned_refs
++
++      def _add_owned_ref(self, ref):
++        """Add a new 'owned' reference -- i.e. a Python object contained in a C
++           structure allocated in this pool.  Used by the typemaps to manage
++           reference counting semantics."""
++        if not hasattr(self, "_owned_refs"):
++          self._owned_refs = {}
++        if self._owned_refs.has_key(ref):
++          self._owned_refs[ref] += 1
++        else:
++          self._owned_refs[ref] = 1
++      
++      def _remove_owned_ref(self, ref):
++        """Remove an existing 'owned' reference.  Also used by typemaps."""
++        if hasattr(self, "_owned_refs") and self._owned_refs.has_key(ref):
++          self._owned_refs[ref] -= 1
++          if self._owned_refs[ref] == 0:
++            del self._owned_refs[ref]
+   
+       def __del__(self):
+         """Automatically destroy memory pools, if necessary"""
+diff -Npur subversion-1.4.0-clean/subversion/bindings/swig/include/svn_types.swg subversion-1.4.0-patch1/subversion/bindings/swig/include/svn_types.swg
+--- subversion-1.4.0-clean/subversion/bindings/swig/include/svn_types.swg	2006-04-20 04:47:39.000000000 +0200
++++ subversion-1.4.0-patch1/subversion/bindings/swig/include/svn_types.swg	2007-01-27 09:05:41.585591500 +0100
+@@ -444,6 +444,12 @@
+   svn_swig_rb_set_baton($result, (VALUE)$2);
+ };
+ 
++%typemap(python, in) (svn_commit_callback2_t callback, void *callback_baton)
++{
++  $1 = svn_swig_py_commit_callback2;
++  $2 = (void *)$input;
++}
++
+ /* -----------------------------------------------------------------------
+    Callback: svn_cancel_func_t
+ */
+@@ -519,6 +525,33 @@
+   $1 = svn_swig_rb_make_stream($input);
+ }
+ 
++#ifdef SWIGPYTHON
++%typemap(in) (svn_commit_callback_t callback, void *callback_baton)
++{
++  $1 = svn_swig_py_commit_callback;
++  $2 = (void *)$input;
++}
++#endif
++
++/* -----------------------------------------------------------------------
++   Mapper to automatically turn Python objects into void* batons on assignment
++*/
++
++#ifdef SWIGPYTHON
++%typemap(in) void *PY_AS_VOID (PyObject *newRef) {
++  newRef = $input;
++  if ($input == Py_None) {
++    $1 = newRef = NULL;
++  } else {
++    newRef = $input;
++    $1 = (void *)$input;
++  }
++  if (svn_swig_py_pool_set_owned_ref(obj0, (PyObject *)arg1->$1_name, newRef)) {
++    SWIG_fail;
++  }
++}
++#endif
++
+ /* -----------------------------------------------------------------------
+    Wrap the digest output for functions populating digests.
+ */
+diff -Npur subversion-1.4.0-clean/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c subversion-1.4.0-patch1/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
+--- subversion-1.4.0-clean/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c	2006-04-18 21:49:41.000000000 +0200
++++ subversion-1.4.0-patch1/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c	2007-01-27 08:57:48.532027500 +0100
+@@ -104,6 +104,8 @@ static apr_pool_t *_global_pool = NULL;
+ static PyObject *_global_svn_swig_py_pool = NULL;
+ static char assertValid[] = "assert_valid";
+ static char parentPool[] = "_parent_pool";
++static char addOwnedRef[] = "_add_owned_ref";
++static char removeOwnedRef[] = "_remove_owned_ref";
+ static char wrap[] = "_wrap";
+ static char unwrap[] = "_unwrap";
+ static char setParentPool[] = "set_parent_pool";
+@@ -166,6 +168,51 @@ static int proxy_set_pool(PyObject **pro
+ 
+   return 0;
+ }
++
++/* Get the parent pool of a proxy object, or return the global application
++ * pool if one is not set.  Returns a BORROWED reference! */
++static PyObject *proxy_get_pool(PyObject *proxy)
++{
++  PyObject *result;
++
++  if (PyObject_HasAttrString(proxy, parentPool)) {
++    result = PyObject_GetAttrString(proxy, parentPool);
++    Py_DECREF(result);
++  } else {
++    result = _global_svn_swig_py_pool;
++  }
++
++  return result;
++}
++
++/* Change an 'owned reference' allocated in a pool from oldRef to newRef.
++ * If oldRef is non-NULL and present in the parent pool of proxy, it is removed.
++ */
++int svn_swig_py_pool_set_owned_ref(PyObject *proxy, PyObject *oldRef,
++                                   PyObject *newRef)
++{
++  PyObject *temp;
++  PyObject *py_pool = proxy_get_pool(proxy);
++
++  if (oldRef != NULL) {
++    temp = PyObject_CallMethod(py_pool, removeOwnedRef, objectTuple, oldRef);
++    if (temp == NULL) {
++      return 1;
++    } else {
++      Py_DECREF(temp);
++    }
++  }
++  if (newRef != NULL) {
++    temp = PyObject_CallMethod(py_pool, addOwnedRef, objectTuple, newRef);
++    if (temp == NULL) {
++      return 1;
++    } else {
++      Py_DECREF(temp);
++    }
++  }
++
++  return 0;
++}
+ 
+ /* Wrapper for SWIG_TypeQuery */
+ #define svn_swig_TypeQuery(x) SWIG_TypeQuery(x)
+@@ -239,14 +286,11 @@ void *svn_swig_MustGetPtr(void *input, s
+     }
+     Py_DECREF(result);
+   }
++
+   if (py_pool != NULL) {
+-    if (PyObject_HasAttrString(input, parentPool)) {
+-      *py_pool = PyObject_GetAttrString(input, parentPool);
+-      Py_DECREF(*py_pool);
+-    } else {
+-      *py_pool = _global_svn_swig_py_pool;
+-    }
++    *py_pool = proxy_get_pool((PyObject *) input);
+   }
++
+   if (PyObject_HasAttrString(input, unwrap)) {
+     input = PyObject_CallMethod(input, unwrap, emptyTuple);
+     if (input == NULL) {
+@@ -486,6 +530,47 @@ PyObject *svn_swig_py_prophash_to_dict(a
+   return convert_hash(hash, convert_svn_string_t, NULL, NULL);
+ }
+ 
++static PyObject *proparray_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_t prop;
++    PyObject *py_key, *py_value;
++
++    prop = APR_ARRAY_IDX(array, i, svn_prop_t);
++
++    py_key = PyString_FromString(prop.name);
++    if (py_key == NULL) {
++      goto error;
++    }
++
++    if (prop.value == NULL) {
++      py_value = Py_None;
++      Py_INCREF(Py_None);
++    } else {
++      py_value = PyString_FromStringAndSize((void *)prop.value->data,
++                                            prop.value->len);
++      if (py_value == NULL) {
++        Py_DECREF(py_key);
++        goto error;
++      }
++    }
++
++    PyDict_SetItem(dict, py_key, py_value);
++  }
++
++  return dict;
++
++error:
++  Py_DECREF(dict);
++  return NULL;
++}
+ 
+ PyObject *svn_swig_py_locationhash_to_dict(apr_hash_t *hash)
+ {
+@@ -552,6 +637,8 @@ DECLARE_SWIG_CONSTRUCTOR(lock, svn_lock_
+ DECLARE_SWIG_CONSTRUCTOR(auth_ssl_server_cert_info,
+     svn_auth_ssl_server_cert_info_dup)
+ DECLARE_SWIG_CONSTRUCTOR(info, svn_info_dup)
++DECLARE_SWIG_CONSTRUCTOR(commit_info, svn_commit_info_dup)
++DECLARE_SWIG_CONSTRUCTOR(wc_notify, svn_wc_dup_notify)
+ 
+ static PyObject *convert_log_changed_path(void *value, void *ctx,
+                                           PyObject *py_pool)
+@@ -1448,6 +1535,14 @@ write_handler_pyio(void *baton, const ch
+   return err;
+ }
+ 
++static svn_error_t *
++close_handler_pyio(void *baton)
++{
++  PyObject *py_io = baton;
++  Py_DECREF(py_io);
++  return SVN_NO_ERROR;
++}
++
+ svn_stream_t *
+ svn_swig_py_make_stream(PyObject *py_io, apr_pool_t *pool)
+ {
+@@ -1458,9 +1553,11 @@ svn_swig_py_make_stream(PyObject *py_io,
+    * bindings, and we will be finished with the py_io object before we return
+    * to python. I.e. DO NOT STORE AWAY THE RESULTING svn_stream_t * for use
+    * over multiple calls into the bindings. */
++  Py_INCREF(py_io);
+   stream = svn_stream_create(py_io, pool);
+   svn_stream_set_read(stream, read_handler_pyio);
+   svn_stream_set_write(stream, write_handler_pyio);
++  svn_stream_set_close(stream, close_handler_pyio);
+ 
+   return stream;
+ }
+@@ -1507,6 +1604,40 @@ void svn_swig_py_notify_func(void *baton
+   svn_swig_py_release_py_lock();
+ }
+ 
++void svn_swig_py_notify_func2(void *baton,
++                              const svn_wc_notify_t *notify,
++                              apr_pool_t *pool)
++{
++  PyObject *function = baton;
++  PyObject *result;
++  svn_error_t *err = SVN_NO_ERROR;
++
++  if (function == NULL || function == Py_None) {
++    return;
++  }
++
++  svn_swig_py_acquire_py_lock();
++
++  if ((result = PyObject_CallFunction(function,
++                                      (char *)"(O&O&)",
++                                      make_ob_wc_notify, notify,
++                                      make_ob_pool, pool)) == NULL) {
++    err = callback_exception_error();
++  } else {
++    /* The callback shouldn't be returning anything. */
++    if (result != Py_None) {
++      err = callback_bad_return_error("Not None");
++    }
++    Py_DECREF(result);
++  }
++
++  /* Our error has no place to go. :-( */
++  if (err) {
++    svn_error_clear(err);
++  }
++
++  svn_swig_py_release_py_lock();
++}
+ 
+ void svn_swig_py_status_func(void *baton,
+                              const char *path,
+@@ -2142,3 +2273,353 @@ svn_swig_py_auth_ssl_client_cert_pw_prom
+   *cred = creds;
+   return err;
+ }
++
++/* svn_ra_callbacks_t */
++static svn_error_t *
++ra_callbacks_open_tmp_file(apr_file_t **fp,
++                           void *callback_baton,
++                           apr_pool_t *pool)
++{
++  PyObject *callbacks = (PyObject *)callback_baton;
++  PyObject *result;
++  svn_error_t *err = SVN_NO_ERROR;
++
++  svn_swig_py_acquire_py_lock();
++
++  if ((result = PyObject_CallMethod(callbacks, 
++                                    "open_tmp_file",
++                                    (char *)"O&", 
++                                    make_ob_pool, pool)) == NULL) {
++    err = callback_exception_error();
++  } else if (result == Py_None) {
++    *fp = NULL;
++  } else {
++    *fp = svn_swig_py_make_file(result, pool);
++    if (*fp == NULL) {
++      err = callback_exception_error();
++    }
++  }
++
++  Py_XDECREF(result);
++  svn_swig_py_release_py_lock();
++  return err;
++}
++
++void
++svn_swig_py_setup_ra_callbacks(svn_ra_callbacks2_t **callbacks,
++                               void **baton,
++                               PyObject *py_callbacks,
++                               apr_pool_t *pool)
++{
++  svn_error_t *err = svn_ra_create_callbacks(callbacks, pool);
++  PyObject *py_auth_baton;
++
++  if (err) {
++    svn_swig_py_svn_exception(err);
++    return;
++  }
++
++  (*callbacks)->open_tmp_file = ra_callbacks_open_tmp_file;
++
++  py_auth_baton = PyObject_GetAttrString(py_callbacks, "auth_baton");
++
++  if (svn_swig_ConvertPtrString(py_auth_baton, 
++                                (void **)&((*callbacks)->auth_baton),
++                                "svn_auth_baton_t *")) {
++    err = type_conversion_error("svn_auth_baton_t *");
++    svn_swig_py_svn_exception(err);
++    Py_DECREF(py_auth_baton);
++    return;
++  }
++  
++  Py_XDECREF(py_auth_baton);
++
++  *baton = py_callbacks;
++}
++
++svn_error_t *svn_swig_py_commit_callback2(const svn_commit_info_t *commit_info,
++                                          void *baton,
++                                          apr_pool_t *pool)
++{
++  PyObject *receiver = baton;
++  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();
++
++  if ((result = PyObject_CallFunction(receiver,
++                                      (char *)"O&O&",
++                                      make_ob_commit_info, commit_info,
++                                      make_ob_pool, pool)) == NULL) {
++    err = callback_exception_error();
++  } else {
++    if (result != Py_None) {
++      err = callback_bad_return_error("Not None");
++    }
++    Py_DECREF(result);
++  }
++
++  svn_swig_py_release_py_lock();
++
++  return err;
++}
++
++svn_error_t *svn_swig_py_commit_callback(svn_revnum_t new_revision,
++                                         const char *date,
++                                         const char *author,
++                                         void *baton)
++{
++  PyObject *receiver = baton;
++  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();
++
++  if ((result = PyObject_CallFunction(receiver,
++                                      (char *)"lss",
++                                      new_revision, date, author)) == NULL) {
++    err = callback_exception_error();
++  } else {
++    if (result != Py_None) {
++      err = callback_bad_return_error("Not None");
++    }
++    Py_DECREF(result);
++  }
++
++  svn_swig_py_release_py_lock();
++
++  return err;
++}
++
++svn_error_t *svn_swig_py_ra_file_rev_handler_func(void *baton,
++                                                  const char *path,
++                                                  svn_revnum_t rev,
++                                                  apr_hash_t *rev_props,
++                                                  svn_txdelta_window_handler_t *delta_handler,
++                                                  void **delta_baton,
++                                                  apr_array_header_t *prop_diffs,
++                                                  apr_pool_t *pool)
++{
++  PyObject *handler = baton;
++  PyObject *result, *py_rev_props = NULL, *py_prop_diffs = NULL;
++  svn_error_t *err = SVN_NO_ERROR;
++
++  if ((handler == NULL) || (handler == Py_None)) {
++    return SVN_NO_ERROR;
++  }
++
++  svn_swig_py_acquire_py_lock();
++
++  py_rev_props = svn_swig_py_prophash_to_dict(rev_props);
++  if (py_rev_props == NULL) {
++    err = type_conversion_error("apr_hash_t *");
++    goto error;
++  }
++
++  py_prop_diffs = proparray_to_dict(prop_diffs);
++
++  if (py_prop_diffs == NULL) {
++    err = type_conversion_error("apr_array_header_t *");
++    goto error;
++  }
++
++  if ((result = PyObject_CallFunction(handler,
++                                      (char *)"slOOO&",
++                                      path, rev, py_rev_props, py_prop_diffs,
++                                      make_ob_pool, pool)) == NULL) {
++    err = callback_exception_error();
++  } else {
++    if (result != Py_None) {
++      err = callback_bad_return_error("Not None");
++    }
++
++    /* FIXME: Support returned TxDeltaWindow object and
++     * set delta_handler and delta_baton */
++    *delta_handler = NULL;
++    *delta_baton = NULL;
++
++    Py_XDECREF(result);
++  }
++
++error:
++
++  Py_XDECREF(py_rev_props);
++  Py_XDECREF(py_prop_diffs);
++
++  svn_swig_py_release_py_lock();
++
++  return err;
++}
++
++static svn_error_t *reporter_set_path(void *report_baton,
++                                      const char *path,
++                                      svn_revnum_t revision,
++                                      svn_boolean_t start_empty,
++                                      const char *lock_token,
++                                      apr_pool_t *pool)
++{
++  svn_error_t *err = SVN_NO_ERROR;
++  PyObject *py_reporter = report_baton, *result;
++
++  if (py_reporter == NULL || py_reporter == Py_None) {
++    return SVN_NO_ERROR;
++  }
++
++  svn_swig_py_acquire_py_lock();
++
++  if ((result = PyObject_CallMethod(py_reporter,
++                                    (char *)"set_path",
++                                    (char *)"slbsO&",
++                                    path, revision,
++                                    start_empty, lock_token,
++                                    make_ob_pool, pool)) == NULL) {
++    err = callback_exception_error();
++  } else if (result != Py_None) {
++    err = callback_bad_return_error("Not None");
++  }
++
++  Py_XDECREF(result);
++
++  svn_swig_py_release_py_lock();
++
++  return err;
++}
++
++static svn_error_t *reporter_delete_path(void *report_baton,
++                         const char *path,
++                        apr_pool_t *pool)
++{
++  svn_error_t *err = SVN_NO_ERROR;
++  PyObject *py_reporter = report_baton, *result;
++
++  if (py_reporter == NULL || py_reporter == Py_None) {
++    return SVN_NO_ERROR;
++  }
++
++  svn_swig_py_acquire_py_lock();
++
++  if ((result = PyObject_CallMethod(py_reporter,
++                                    (char *)"delete_path",
++                                    (char *)"sO&",
++                                    path, 
++                                    make_ob_pool, pool)) == NULL) {
++    err = callback_exception_error();
++  } else if (result != Py_None) {
++    err = callback_bad_return_error("Not None");
++  }
++
++  Py_XDECREF(result);
++
++  svn_swig_py_release_py_lock();
++
++  return err;
++}
++    
++static svn_error_t *reporter_link_path(void *report_baton,
++                                       const char *path,
++                                       const char *url,
++                                       svn_revnum_t revision,
++                                       svn_boolean_t start_empty,
++                                       const char *lock_token,
++                                       apr_pool_t *pool)
++{
++  svn_error_t *err = SVN_NO_ERROR;
++  PyObject *py_reporter = report_baton, *result;
++
++  if (py_reporter == NULL || py_reporter == Py_None) {
++    return SVN_NO_ERROR;
++  }
++
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list