in subversion/bindings/ctypes-python/csvn/txn.py [0:0]
def replay(self, editor, session, base_rev, baton):
subpool = Pool()
child_baton = c_void_p()
file_baton = c_void_p()
if self.path is None:
SVN_ERR(editor.open_root(baton, svn_revnum_t(base_rev), subpool,
byref(child_baton)))
else:
if self.action == "DELETE" or self.action == "REPLACE":
SVN_ERR(editor.delete_entry(self.path, base_rev, baton,
subpool))
elif self.action == "OPEN":
if self.kind == svn_node_dir:
SVN_ERR(editor.open_directory(self.path, baton,
svn_revnum_t(base_rev), subpool,
byref(child_baton)))
else:
SVN_ERR(editor.open_file(self.path, baton,
svn_revnum_t(base_rev), subpool,
byref(file_baton)))
if self.action in ("ADD", "REPLACE"):
copyfrom_path = None
if self.copyfrom_path is not None:
copyfrom_path = session._abs_copyfrom_path(
self.copyfrom_path)
if self.kind == svn_node_dir:
SVN_ERR(editor.add_directory(
self.path, baton, copyfrom_path,
svn_revnum_t(self.copyfrom_rev), subpool,
byref(child_baton)))
else:
SVN_ERR(editor.add_file(self.path, baton,
copyfrom_path, svn_revnum_t(self.copyfrom_rev),
subpool, byref(file_baton)))
# Write out changes to properties
for (name, value) in self.properties.items():
if value is None:
svn_value = POINTER(svn_string_t)()
else:
svn_value = svn_string_ncreate(value, len(value),
subpool)
if file_baton:
SVN_ERR(editor.change_file_prop(file_baton, name,
svn_value, subpool))
elif child_baton:
SVN_ERR(editor.change_dir_prop(child_baton, name,
svn_value, subpool))
# If there's a source file, and we opened a file to write,
# write out the contents
if self.local_path and file_baton:
handler = svn_txdelta_window_handler_t()
handler_baton = c_void_p()
f = POINTER(apr_file_t)()
SVN_ERR(editor.apply_textdelta(file_baton, NULL, subpool,
byref(handler), byref(handler_baton)))
svn_io_file_open(byref(f), self.local_path, APR_READ,
APR_OS_DEFAULT, subpool)
contents = svn_stream_from_aprfile(f, subpool)
svn_txdelta_send_stream(contents, handler, handler_baton,
NULL, subpool)
svn_io_file_close(f, subpool)
# If we opened a file, we need to close it
if file_baton:
SVN_ERR(editor.close_file(file_baton, NULL, subpool))
if self.kind == svn_node_dir and self.action != "DELETE":
assert(child_baton)
# Look at the children
for op in self.ops.values():
op.replay(editor, session, base_rev, child_baton)
if self.path:
# Close the directory
SVN_ERR(editor.close_directory(child_baton, subpool))
else:
# Close the editor
SVN_ERR(editor.close_edit(baton, subpool))