# `subvertpy.delta` module documentation

Part of `subvertpy`
Subversion delta operations.

Function | apply_txdelta_window | Apply a txdelta window to a buffer.
Function | apply_txdelta_handler_chunks | Return a function that can be called repeatedly with txdelta windows.
Function | apply_txdelta_handler | Return a function that can be called repeatedly with txdelta windows.
Function | txdelta_apply_ops | Apply txdelta operations to a source view.
Function | send_stream | Send txdelta windows that create stream to handler
Function | encode_length | Encode a length variable.
Function | decode_length | Decode a length variable.
Function | pack_svndiff_instruction | Pack a SVN diff instruction
Function | unpack_svndiff_instruction | Unpack a SVN diff instruction
Function | pack_svndiff0_window | Pack an individual window using svndiff0.
Function | pack_svndiff0 | Pack a SVN diff file.
Function | unpack_svndiff0 | Unpack a version 0 svndiff text.

def apply_txdelta_window(sbuf, (sview_offset, sview_len, tview_len, src_ops, ops, new_data)):
Apply a txdelta window to a buffer.

Parameters | sbuf | Source buffer (as bytestring)
| sview_offset | Offset of the source view
| sview_len | Length of the source view
| tview_len | Target view length
| src_ops | Operations to apply to sview
| ops | Ops to apply
| new_data | Buffer with possible new data
Returns | Target buffer

def apply_txdelta_handler_chunks(source_chunks, target_chunks):
Return a function that can be called repeatedly with txdelta windows.

Parameters | sbuf | Source buffer
| target_stream | Target stream

def apply_txdelta_handler(sbuf, target_stream):
Return a function that can be called repeatedly with txdelta windows.

Parameters | sbuf | Source buffer
| target_stream | Target stream

def txdelta_apply_ops(src_ops, ops, new_data, sview):
Apply txdelta operations to a source view.

Parameters | src_ops | Source operations, ignored.
| ops | List of operations (action, offset, length).
| new_data | Buffer to fetch fragments with new data from
| sview | Source data
Returns | Result data

def send_stream(stream, handler, block_size=DELTA_WINDOW_SIZE):
Send txdelta windows that create stream to handler

Parameters | stream | file-like object to read the file from
| handler | txdelta window handler function
Returns | MD5 hash over the stream

def encode_length(len):
Encode a length variable.

Parameters | len | Length to encode
Returns | String with encoded length

def decode_length(text):
Decode a length variable.

Parameters | text | Bytestring to decode
Returns | Integer with actual length

def pack_svndiff_instruction((action, offset, length)):
Pack a SVN diff instruction

Parameters | action | Action
| offset | Offset
| length | Length
Returns | encoded text

def unpack_svndiff_instruction(text):
Unpack a SVN diff instruction

Parameters | text | Text to parse
Returns | tuple with operation, remaining text

def pack_svndiff0_window(window):
Pack an individual window using svndiff0.

Parameters | window | Window to pack
Returns | Packed diff (as bytestring)

def pack_svndiff0(windows):
Pack a SVN diff file.

Parameters | windows | Iterator over diff windows
Returns | text

def unpack_svndiff0(text):
Unpack a version 0 svndiff text.

Parameters | text | Text to unpack.
Returns | yields tuples with sview_offset, sview_len, tview_len, ops_len, ops, newdata