I'm trying to call fs.change_rev_prop2 (https://goo.gl/6b6TG5) from Python /
SWIG - and apparently can't figure out how to pass old_value_p as what I'm
assuming needs to be a double pointer from Python.
(Also posted to http://stackoverflow.com/q/32239234/751158 . Looking for
more visibility, and/or for someone here to earn a bounty there that I've
Minimized code sample:
from svn import repos, fs, core
fs_ptr = repos.fs(repos.open("/opt/app/svn/repos/test"))
rev_num = 1
user = fs.revision_prop(fs_ptr, rev_num, "svn:author")
# Works, but is is deprecated in favor of fs.change_rev_prop2 .
fs.change_rev_prop(fs_ptr, rev_num, "svn:author", user.lower())
# fs.change_rev_prop2(fs_ptr, rev_num, "svn:author", user, user.lower())
# > svn.core.SubversionException: 160049 - revprop 'svn:author' has
unexpected value in filesystem
# fs.change_rev_prop2(fs_ptr, rev_num, "svn:author", None, user.lower())
# Per svn_ra.h: If the capability is not advertised, then @a old_value_p
MUST be @c NULL.
# This results in a successful change of the revision property, but then
this program ends with a segmentation fault.
Details of the # 160049 error:
Traceback (most recent call last):
File "./normalize-usernames.py", line 10, in <module>
fs.change_rev_prop2(fs_ptr, rev_num, "svn:author", user, user.lower())
File "/opt/app/subversion/lib/svn-python/libsvn/fs.py", line 711, in
svn.core.SubversionException: 160049 - revprop 'svn:author' has unexpected
value in filesystem
I believe the value I'm attempting to pass is "correct". After all, I'm
obtaining it from the API immediately before attempting to set it back. I'm
assuming I'm just not passing the value correctly in a way that the native
API can accept it.
So I could just continue using change_rev_prop - but it is clearly marked as
deprecated in the API ("Provided for backward compatibility with the 1.6
API"). Should be able to do better, though...
Interestingly, calling change_rev_prop2 with None for old_value_p results in
the desired change taking effect in the repository - but not without causing
the Python program to then immediately terminate with a Segmentation Fault.
It would seem that I need to pass the old / current value as a pointer -
possibly to be able to differentiate to the API the difference between a
null pointer (value not provided) and a pointer to a null value (value is
provided, but value is null)? However, I've tried all the combinations I can
think of here without success - including using various wrappers from ctypes.
StackOverflow is appropriately suggesting a good number of questions that
may already have the answer here - but it appears that most of them cover
cases where the author has control over the C sources and with
recommendations to alter the C API to avoid the complexity entirely - which
I don't see to be an option here. This is largely my only experience with
Python and SWIG so far, and any tips would be appreciated, thanks!
Received on 2015-09-02 02:05:39 CEST