b.r.p.RepositoryPackCollection(object) : class documentation

Part of bzrlib.repofmt.pack_repo View In Hierarchy

Known subclasses: bzrlib.repofmt.groupcompress_repo.GCRepositoryPackCollection, bzrlib.repofmt.knitpack_repo.KnitRepositoryPackCollection

Management of packs within a repository.
Instance Variables_namesmap of {pack_name: (index_size,)}
Method __init__ Create a new RepositoryPackCollection.
Method __repr__ Undocumented
Method add_pack_to_memory Make a Pack object available to the repository to satisfy queries.
Method all_packs Return a list of all the Pack objects this repository has.
Method autopack Pack the pack collection incrementally.
Method lock_names Acquire the mutex around the pack-names index.
Method pack Pack the pack collection totally.
Method plan_autopack_combinations Plan a pack operation.
Method ensure_loaded Ensure we have read names from disk.
Method get_pack_by_name Get a Pack object by name.
Method allocate Allocate name in the list of packs.
Method names Provide an order to the underlying names.
Method pack_distribution Generate a list of the number of revisions to put in each pack.
Method reset Clear all cached data.
Method reload_pack_names Sync our pack listing with what is present in the repository.
Method _do_autopack Undocumented
Method _execute_pack_operations Execute a series of pack operations.
Method _flush_new_pack Undocumented
Method _already_packed Is the collection already packed?
Method _try_pack_operations Calculate the pack operations based on the hint (if any), and
Method _parse_index_sizes Parse a string of index sizes.
Method _resume_pack Get a suspended Pack object by name.
Method _iter_disk_pack_index Iterate over the contents of the pack-names index.
Method _make_index Undocumented
Method _max_pack_count Return the maximum number of packs to use for total revisions.
Method _obsolete_packs Move a number of packs which have been obsoleted out of the way.
Method _pack_tuple Return a tuple with the transport and file name for a pack name.
Method _remove_pack_from_memory Remove pack from the packs accessed by this repository.
Method _remove_pack_indices Remove the indices for pack from the aggregated indices.
Method _unlock_names Release the mutex around the pack-names index.
Method _diff_pack_names Read the pack names from disk, and compare it to the one in memory.
Method _syncronize_pack_names_from_disk_nodes Given the correct set of pack files, update our saved info.
Method _save_pack_names Save the list of packs.
Method _restart_autopack Reload the pack names list, and restart the autopack code.
Method _restart_pack_operations Reload the pack names list, and restart the autopack code.
Method _clear_obsolete_packs Delete everything from the obsolete-packs directory.
Method _start_write_group Undocumented
Method _abort_write_group Undocumented
Method _remove_resumed_pack_indices Undocumented
Method _check_new_inventories Detect missing inventories in this write group.
Method _commit_write_group Undocumented
Method _suspend_write_group Undocumented
Method _resume_write_group Undocumented
def __init__(self, repo, transport, index_transport, upload_transport, pack_transport, index_builder_class, index_class, use_chk_index):
Create a new RepositoryPackCollection.
ParameterstransportAddresses the repository base directory (typically .bzr/repository/).
index_transportAddresses the directory containing indices.
upload_transportAddresses the directory into which packs are written while they're being created.
pack_transportAddresses the directory of existing complete packs.
index_builder_classThe index builder class to use.
index_classThe index class to use.
use_chk_indexWhether to setup and manage a CHK index.
def __repr__(self):
Undocumented
def add_pack_to_memory(self, pack):
Make a Pack object available to the repository to satisfy queries.
ParameterspackA Pack object.
def all_packs(self):
Return a list of all the Pack objects this repository has.

Note that an in-progress pack being created is not returned.

ReturnsA list of Pack objects for all the packs in the repository.
def autopack(self):
Pack the pack collection incrementally.

This will not attempt global reorganisation or recompression, rather it will just ensure that the total number of packs does not grow without bound. It uses the _max_pack_count method to determine if autopacking is needed, and the pack_distribution method to determine the number of revisions in each pack.

If autopacking takes place then the packs name collection will have been flushed to disk - packing requires updating the name collection in synchronisation with certain steps. Otherwise the names collection is not flushed.

ReturnsSomething evaluating true if packing took place.
def _do_autopack(self):
Undocumented
def _execute_pack_operations(self, pack_operations, packer_class, reload_func=None):
Execute a series of pack operations.
Parameterspack_operationsA list of [revision_count, packs_to_combine].
packer_classThe class of packer to use
ReturnsThe new pack names.
def _flush_new_pack(self):
Undocumented
def lock_names(self):
Acquire the mutex around the pack-names index.

This cannot be used in the middle of a read-only transaction on the repository.

def _already_packed(self):
Is the collection already packed?
def pack(self, hint=None, clean_obsolete_packs=False):
Pack the pack collection totally.
def _try_pack_operations(self, hint):
Calculate the pack operations based on the hint (if any), and execute them.
def plan_autopack_combinations(self, existing_packs, pack_distribution):
Plan a pack operation.
Parametersexisting_packsThe packs to pack. (A list of (revcount, Pack) tuples).
pack_distributionA list with the number of revisions desired in each pack.
def ensure_loaded(self):
Ensure we have read names from disk.
ReturnsTrue if the disk names had not been previously read.
def _parse_index_sizes(self, value):
Parse a string of index sizes.
def get_pack_by_name(self, name):
Get a Pack object by name.
ParametersnameThe name of the pack - e.g. '123456'
ReturnsA Pack object.
def _resume_pack(self, name):
Get a suspended Pack object by name.
ParametersnameThe name of the pack - e.g. '123456'
ReturnsA Pack object.
def allocate(self, a_new_pack):
Allocate name in the list of packs.
Parametersa_new_packA NewPack instance to be added to the collection of packs for this repository.
def _iter_disk_pack_index(self):
Iterate over the contents of the pack-names index.

This is used when loading the list from disk, and before writing to detect updates from others during our write operation. :return: An iterator of the index contents.

def _make_index(self, name, suffix, resume=False, is_chk=False):
Undocumented
def _max_pack_count(self, total_revisions):
Return the maximum number of packs to use for total revisions.
Parameterstotal_revisionsThe total number of revisions in the repository.
def names(self):
Provide an order to the underlying names.
def _obsolete_packs(self, packs):
Move a number of packs which have been obsoleted out of the way.

Each pack and its associated indices are moved out of the way.

Note: for correctness this function should only be called after a new pack names index has been written without these pack names, and with the names of packs that contain the data previously available via these packs.

ParameterspacksThe packs to obsolete.
returnNone.
def pack_distribution(self, total_revisions):
Generate a list of the number of revisions to put in each pack.
Parameterstotal_revisionsThe total number of revisions in the repository.
def _pack_tuple(self, name):
Return a tuple with the transport and file name for a pack name.
def _remove_pack_from_memory(self, pack):
Remove pack from the packs accessed by this repository.

Only affects memory state, until self._save_pack_names() is invoked.

def _remove_pack_indices(self, pack, ignore_missing=False):
Remove the indices for pack from the aggregated indices.
Parametersignore_missingSuppress KeyErrors from calling remove_index.
def reset(self):
Clear all cached data.
def _unlock_names(self):
Release the mutex around the pack-names index.
def _diff_pack_names(self):
Read the pack names from disk, and compare it to the one in memory.
Returns(disk_nodes, deleted_nodes, new_nodes) disk_nodes The final set of nodes that should be referenced deleted_nodes Nodes which have been removed from when we started new_nodes Nodes that are newly introduced
def _syncronize_pack_names_from_disk_nodes(self, disk_nodes):
Given the correct set of pack files, update our saved info.
Returns(removed, added, modified) removed pack names removed from self._names added pack names added to self._names modified pack names that had changed value
def _save_pack_names(self, clear_obsolete_packs=False, obsolete_packs=None):
Save the list of packs.

This will take out the mutex around the pack names list for the duration of the method call. If concurrent updates have been made, a three-way merge between the current list and the current in memory list is performed.

Parametersclear_obsolete_packsIf True, clear out the contents of the obsolete_packs directory.
obsolete_packsPacks that are obsolete once the new pack-names file has been written.
ReturnsA list of the names saved that were not previously on disk.
def reload_pack_names(self):
Sync our pack listing with what is present in the repository.

This should be called when we find out that something we thought was present is now missing. This happens when another process re-packs the repository, etc.

ReturnsTrue if the in-memory list of packs has been altered at all.
def _restart_autopack(self):
Reload the pack names list, and restart the autopack code.
def _restart_pack_operations(self):
Reload the pack names list, and restart the autopack code.
def _clear_obsolete_packs(self, preserve=None):
Delete everything from the obsolete-packs directory.
ReturnsA list of pack identifiers (the filename without '.pack') that were found in obsolete_packs.
def _start_write_group(self):
Undocumented
def _abort_write_group(self):
Undocumented
def _remove_resumed_pack_indices(self):
Undocumented
def _check_new_inventories(self):
Detect missing inventories in this write group.
Returnslist of strs, summarising any problems found. If the list is empty no problems were found.
def _commit_write_group(self):
Undocumented
def _suspend_write_group(self):
Undocumented
def _resume_write_group(self, tokens):
Undocumented
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.