Search code examples
pythonsvnsvn-propset

Change svn node properties with Python raises a SubversionException


When changing a svn node property with python, using

svn.fs.change_node_prop(root, path, "thisisa:property", "andthisisavalue") 

raises an exception with the message "svn.core.SubversionException: ('Root object must be a transaction root', 160022)"

root is made with this:

canon_path = svn.core.svn_path_canonicalize(repos_path)
repos_ptr = svn.repos.open(canon_path)
fsob = svn.repos.fs(repos_ptr)
headrev = svn.fs.youngest_rev(fsob)
root = svn.fs.revision_root(fsob, headrev)

and path is a directory path, like "proyect/a/directory"

I can't find the documentation about svn module in python, so I don't know how to solve this.

Can you help me with this?

Thank you.


Solution

  • I was wrong using root as the head revision root.

    I needed to begin a transaction for commit and get it's transaction root.

    For doing this I made,

    txn = svn.repos.fs_begin_txn_for_commit(repos_ptr, headrev, SVN_COMMIT_USER, SVN_COMMIT_MESSAGE)
    root = svn.fs.txn_root(txn)
    

    Hope this helps to anyone.