You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by fu...@apache.org on 2021/01/01 14:21:27 UTC

svn commit: r1885007 - /subversion/trunk/subversion/bindings/swig/python/svn/fs.py

Author: futatuki
Date: Fri Jan  1 14:21:27 2021
New Revision: 1885007

URL: http://svn.apache.org/viewvc?rev=1885007&view=rev
Log:
Follow up to r1880967: swig-py: Restore return value type of svn.fs.commit_txn

On r1880967 we reverted a "wrong" behavior of svn.fs.commit_txn, that it
returned always a 2-tuple of None and new_rev if it didn't raise Exception.
However we reconsidered that it is more important to keep compatibility on
existing program codes.  To keep code simple, we adjust return value on
Python code rather than SWIG typemap. 

* subversion/bindings/swig/python/svn/fs.py
  (): rename the wrapper function svn_fs_commit_txn imported from
    libsvn.fs module into internal name '_svn_fs_commit_txn'.
  (svn_fs_commit_txn):
    New function to wrap _svn_fs_commit_txn to adjust return value type.

Modified:
    subversion/trunk/subversion/bindings/swig/python/svn/fs.py

Modified: subversion/trunk/subversion/bindings/swig/python/svn/fs.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/python/svn/fs.py?rev=1885007&r1=1885006&r2=1885007&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/python/svn/fs.py (original)
+++ subversion/trunk/subversion/bindings/swig/python/svn/fs.py Fri Jan  1 14:21:27 2021
@@ -24,6 +24,34 @@
 ######################################################################
 
 from libsvn.fs import *
+
+######################################################################
+# Any adjustment of SWIG generated wrapper functions on svn.fs module
+# should be placed before adding alternative names for them.
+
+# fs.commit_txn() should return a 2-tupple of conflict_p and new_rev.
+# However if conflict_p is None, SWIG generated wrapper function
+# libsvn.fs.svn_fs_commit_txn returns an integer value of new_rev.
+# This is a bug of SWIG generated wrapper function, so we fix it here.
+#
+# (There was discussion about this behavior because C API
+# svn_fs_commit_txn() always set NULL to conflict_p if it returns
+# SVN_NO_ERROR and so it seems to be reasonable that fs.commit_txn()
+# returns only rev_new value. However for compatibility, we decided
+# that # fs.commit_txn always returns 2-tuple if it does not raises
+# an exception.)
+
+_svn_fs_commit_txn = svn_fs_commit_txn
+
+def svn_fs_commit_txn(*args):
+    r"""svn_fs_commit_txn(svn_fs_txn_t txn, apr_pool_t pool) -> svn_error_t"""
+    ret = _svn_fs_commit_txn(*args)
+    if not isinstance(ret, tuple):
+      ret = (None, ret)
+    return ret
+
+######################################################################
+
 from svn.core import _unprefix_names, Pool, _as_list
 _unprefix_names(locals(), 'svn_fs_')
 _unprefix_names(locals(), 'SVN_FS_')