dulwich.pack.PackData(object)
class documentationdulwich.pack
(View In Hierarchy)
Known subclasses: dulwich.contrib.swift.SwiftPackData
The data contained in a packfile.
Pack files can be accessed both sequentially for exploding a pack, and directly with the help of an index to retrieve a specific object.
The objects within are either complete or a delta against another.
The header is variable length. If the MSB of each byte is set then it indicates that the subsequent byte is still part of the header. For the first byte the next MS bits are the type, which tells you the type of object, and whether it is a delta. The LS byte is the lowest bits of the size. For each subsequent byte the LS 7 bits are the next MS bits of the size, i.e. the last byte of the header contains the MS bits of the size.
For the complete objects the data is stored as zlib deflated data. The size in the header is the uncompressed object size, so to uncompress you need to just keep feeding data to zlib until you get an object back, or it errors on bad data. This is done here by just giving the complete buffer from the start of the deflated object on. This is bad, but until I get mmap sorted out it will have to do.
Currently there are no integrity checks done. Also no attempt is made to try and detect the delta case, or a request for an object at the wrong position. It will all just throw a zlib or KeyError.
Method | __init__ | Create a PackData object representing the pack in the given filename. |
Method | filename | Undocumented |
Method | path | Undocumented |
Class Method | from_file | Undocumented |
Class Method | from_path | Undocumented |
Method | close | Undocumented |
Method | __enter__ | Undocumented |
Method | __exit__ | Undocumented |
Method | __len__ | Returns the number of objects in this pack. |
Method | calculate_checksum | Calculate the checksum for this pack. |
Method | get_ref | Get the object for a ref SHA, only looking in this pack. |
Method | resolve_object | Resolve an object, possibly resolving deltas when necessary. |
Method | iterobjects | Undocumented |
Method | iterentries | Yield entries summarizing the contents of this pack. |
Method | sorted_entries | Return entries in this pack, sorted by SHA. |
Method | create_index_v1 | Create a version 1 file for this data file. |
Method | create_index_v2 | Create a version 2 index file for this data file. |
Method | create_index | Create an index file for this data file. |
Method | get_stored_checksum | Return the expected checksum stored in this pack. |
Method | check | Check the consistency of this pack. |
Method | get_compressed_data_at | Given offset in the packfile return compressed data that is there. |
Method | get_object_at | Given an offset in to the packfile return the object that is there. |
Method | _get_size | Undocumented |
Method | _iter_unpacked | Undocumented |
Create a PackData object representing the pack in the given filename.
The file must exist and stay readable until the object is disposed of. It must also stay the same size. It will be mapped whenever needed.
Currently there is a restriction on the size of the pack as the python mmap implementation is flawed.
Returns | 20-byte binary SHA1 digest |
Returns | Tuple with object type and contents. |
Parameters | progress | Progress function, called with current and total object count. |
Returns | iterator of tuples with (sha, offset, crc32) |
Parameters | progress | Progress function, called with current and total object count |
Returns | List of tuples with (sha, offset, crc32) |
Parameters | filename | Index filename. |
progress | Progress report function | |
Returns | Checksum of index file |
Parameters | filename | Index filename. |
progress | Progress report function | |
Returns | Checksum of index file |
Parameters | filename | Index filename. |
progress | Progress report function | |
Returns | Checksum of index file |
Given offset in the packfile return compressed data that is there.
Using the associated index the location of an object can be looked up, and then the packfile can be asked directly for that object using this function.
Given an offset in to the packfile return the object that is there.
Using the associated index the location of an object can be looked up, and then the packfile can be asked directly for that object using this function.