b.v.VersionedFileRepository(Repository) : class documentation

Part of bzrlib.vf_repository View In Hierarchy

Known subclasses: bzrlib.plugins.weave_fmt.repository.AllInOneRepository, bzrlib.vf_repository.MetaDirVersionedFileRepository

Repository holding history for one or more branches.

The repository holds and retrieves historical information including revisions and file history. It's normally accessed only by the Branch, which views a particular line of development through that history.

The Repository builds on top of some byte storage facilies (the revisions, signatures, inventories, texts and chk_bytes attributes) and a Transport, which respectively provide byte storage and a means to access the (possibly remote) disk.

The byte storage facilities are addressed via tuples, which we refer to as 'keys' throughout the code base. Revision_keys, inventory_keys and signature_keys are all 1-tuples: (revision_id,). text_keys are two-tuples: (file_id, revision_id). chk_bytes uses CHK keys - a 1-tuple with a single byte string made up of a hash identifier and a hash value. We use this interface because it allows low friction with the underlying code that implements disk indices, network encoding and other parts of bzrlib.

Instance VariablesrevisionsA bzrlib.versionedfile.VersionedFiles instance containing the serialised revisions for the repository. This can be used to obtain revision graph information or to access raw serialised revisions. The result of trying to insert data into the repository via this store is undefined: it should be considered read-only except for implementors of repositories.
signaturesA bzrlib.versionedfile.VersionedFiles instance containing the serialised signatures for the repository. This can be used to obtain access to raw serialised signatures. The result of trying to insert data into the repository via this store is undefined: it should be considered read-only except for implementors of repositories.
inventoriesA bzrlib.versionedfile.VersionedFiles instance containing the serialised inventories for the repository. This can be used to obtain unserialised inventories. The result of trying to insert data into the repository via this store is undefined: it should be considered read-only except for implementors of repositories.
textsA bzrlib.versionedfile.VersionedFiles instance containing the texts of files and directories for the repository. This can be used to obtain file texts or file graphs. Note that Repository.iter_file_bytes is usually a better interface for accessing file texts. The result of trying to insert data into the repository via this store is undefined: it should be considered read-only except for implementors of repositories.
chk_bytesA bzrlib.versionedfile.VersionedFiles instance containing any data the repository chooses to store or have indexed by its hash. The result of trying to insert data into the repository via this store is undefined: it should be considered read-only except for implementors of repositories.
_transportTransport for file access to repository, typically pointing to .bzr/repository.
Method add_fallback_repository Add a repository to use for looking up data not held locally.
Method unlock Undocumented
Method add_inventory Add the inventory inv to the repository as revision_id.
Method add_inventory_by_delta Add a new inventory expressed as a delta against another revision.
Method add_revision Add rev to the revision store as revision_id.
Method __init__ Instantiate a VersionedFileRepository.
Method gather_stats See Repository.gather_stats().
Method get_commit_builder Obtain a CommitBuilder for this repository.
Method get_missing_parent_inventories Return the keys of missing inventory parents for revisions added in
Method has_revisions Probe to find out the presence of multiple revisions.
Method get_revision_reconcile 'reconcile' helper routine that allows access to a revision always.
Method get_revisions Get many revisions at once.
Method add_signature_text Store a signature text for a revision.
Method find_text_key_references Find the text key references within the repository.
Method fileids_altered_by_revision_ids Find the file ids and versions affected by revisions.
Method iter_files_bytes Iterate through file versions.
Method item_keys_introduced_by Get an iterable listing the keys of all the data introduced by a set
Method get_inventory Get Inventory object by revision id.
Method iter_inventories Get many inventories by revision_ids.
Method get_serializer_format Undocumented
Method revision_tree Return Tree for a revision on this branch.
Method revision_trees Return Trees for revisions in this repository.
Method get_parent_map See graph.StackedParentsProvider.get_parent_map
Method get_known_graph_ancestry Return the known graph for a set of revision ids and their ancestors.
Method get_file_graph Return the graph walker for text revisions.
Method has_signature_for_revision_id Query for a revision signature for revision_id in the repository.
Method get_signature_text Return the text for a signature.
Method _add_inventory_checked Add inv to the repository after checking the inputs.
Method _inventory_add_lines Store lines in inv_vf and return the sha1 of the inventory.
Method _add_revision Undocumented
Method _check_inventories Check the inventories found from the revision scan.
Method _do_check_inventories Helper for _check_inventories.
Method _check_record Check a single text from this repository.
Method _check_text Check a single text.
Method _eliminate_revisions_not_present Check every revision id in revision_ids to see if we have it.
Method _get_revisions Core work logic to get many revisions without sanity checks.
Method _iter_revisions Iterate over revision objects.
Method _inventory_xml_lines_for_keys Get a line iterator of the sort needed for findind references.
Method _find_file_ids_from_xml_inventory_lines Helper routine for fileids_altered_by_revision_ids.
Method _find_parent_keys_of_revisions Similar to _find_parent_ids_of_revisions, but used with keys.
Method _generate_text_key_index Generate a new text key index for the repository.
Method _do_generate_text_key_index Helper for _generate_text_key_index to avoid deep nesting.
Method _find_file_keys_to_fetch Undocumented
Method _find_non_file_keys_to_fetch Undocumented
Method _iter_inventories single-document based inventory iteration.
Method _iter_inventory_xmls Undocumented
Method _deserialise_inventory Transform the xml into an inventory object.
Method _get_inventory_xml Get serialized inventory as a string.
Method _filtered_revision_trees Return Tree for a revision on this branch with only some files.
Method _get_versioned_file_checker Return an object suitable for checking versioned files.
Method _check Undocumented
Method _find_inconsistent_revision_parents Find revisions with different parent lists in the revision object
Method _check_for_inconsistent_revision_parents Undocumented
Method _get_sink Return a sink for streaming into this repository.
Method _get_source Return a source for streaming from this repository.

Inherited from Repository:

Method abort_write_group Commit the contents accrued within the current write group.
Method all_revision_ids Returns a list of all the revision ids in the repository.
Method break_lock Break a lock if one is present from another instance.
Static Method create Construct the current default format repository in controldir.
Method user_transport Undocumented
Method control_transport Undocumented
Method __repr__ Undocumented
Method has_same_location Returns a boolean indicating if this repository is at the same
Method is_in_write_group Return True if there is an open write group.
Method is_locked Undocumented
Method is_write_locked Return True if this object is write locked.
Method lock_write Lock this repository for writing.
Method lock_read Lock the repository for read operations.
Method get_physical_lock_status Undocumented
Method leave_lock_in_place Tell this repository not to release the physical lock when this
Method dont_leave_lock_in_place Tell this repository to release the physical lock when this
Method find_branches Find branches underneath this repository.
Method search_missing_revision_ids Return the revision ids that other has that this does not.
Static Method open Open the repository rooted at base.
Method copy_content_into Make a complete copy of the content in self into destination.
Method commit_write_group Commit the contents accrued within the current write group.
Method suspend_write_group Undocumented
Method refresh_data Re-read any data needed to synchronise with disk.
Method resume_write_group Undocumented
Method fetch Fetch the content required to construct revision_id from source.
Method create_bundle Undocumented
Method clone Clone this repository into controldir using the current format.
Method start_write_group Start a write group in the repository.
Method sprout Create a descendent repository for new development.
Method has_revision True if this repository has a copy of the revision.
Method get_revision Return the Revision object for a named revision.
Method get_deltas_for_revisions Produce a generator of revision deltas.
Method get_revision_delta Return the delta for one revision.
Method store_revision_signature Undocumented
Method get_rev_id_for_revno Return the revision id of a revno, given a later (revno, revid)
Method iter_reverse_revision_history Iterate backwards through revision ids in the lefthand history
Method is_shared Return True if this repository is flagged as a shared repository.
Method reconcile Reconcile this repository.
Method get_ancestry Return a list of revision-ids integrated by a revision.
Method pack Compress the data within the repository.
Method get_transaction Undocumented
Method get_graph Return the graph walker for this repository format
Method revision_ids_to_search_result Convert a set of revision ids to a graph SearchResult.
Method set_make_working_trees Set the policy flag for making working trees when creating branches.
Method make_working_trees Returns the policy for making working trees on new branches.
Method sign_revision Undocumented
Method verify_revision Verify the signature on a revision.
Method check Check consistency of all history of given revision_ids.
Method supports_rich_root Undocumented
Method _abort_write_group Template method for per-repository write group cleanup.
Method _check_fallback_repository Check that this repository can fallback to repository safely.
Method _all_revision_ids Returns a list of all the revision ids in the repository.
Method _has_same_fallbacks Returns true if the repositories have the same fallbacks.
Method _commit_write_group Template method for per-repository write group cleanup.
Method _resume_write_group Undocumented
Method _start_write_group Template method for per-repository write group startup.
Method _create_sprouting_repo Undocumented
Method _find_parent_ids_of_revisions Find all parent ids that are mentioned in the revision graph.
Method _refresh_data Helper called from lock_* to ensure coherency with disk.
Method _get_parent_map_no_fallbacks Same as Repository.get_parent_map except doesn't query fallbacks.
Method _make_parents_provider Undocumented
Method _make_parents_provider_unstacked Undocumented
Method _warn_if_deprecated Undocumented
Method _check_ascii_revisionid Private helper for ascii-only repositories.

Inherited from _RelockDebugMixin (via Repository):

Method _note_lock Undocumented
def add_fallback_repository(self, repository):
Add a repository to use for looking up data not held locally.
ParametersrepositoryA repository.
@only_raises(errors.LockNotHeld, errors.LockBroken)
def unlock(self):
Undocumented
def add_inventory(self, revision_id, inv, parents):
Add the inventory inv to the repository as revision_id.
ParametersparentsThe revision ids of the parents that revision_id is known to have and are in the repository already.
ReturnsThe validator(which is a sha1 digest, though what is sha'd is repository format specific) of the serialized inventory.
def _add_inventory_checked(self, revision_id, inv, parents):
Add inv to the repository after checking the inputs.

This function can be overridden to allow different inventory styles.

See Alsoadd_inventory, for the contract.
def add_inventory_by_delta(self, basis_revision_id, delta, new_revision_id, parents, basis_inv=None, propagate_caches=False):
Add a new inventory expressed as a delta against another revision.

See the inventory developers documentation for the theory behind inventory deltas.

Parametersbasis_revision_idThe inventory id the delta was created against. (This does not have to be a direct parent.)
deltaThe inventory delta (see Inventory.apply_delta for details).
new_revision_idThe revision id that the inventory is being added for.
parentsThe revision ids of the parents that revision_id is known to have and are in the repository already. These are supplied for repositories that depend on the inventory graph for revision graph access, as well as for those that pun ancestry with delta compression.
basis_invThe basis inventory if it is already known, otherwise None.
propagate_cachesIf True, the caches for this inventory are copied to and updated for the result if possible.
Returns(validator, new_inv) The validator(which is a sha1 digest, though what is sha'd is repository format specific) of the serialized inventory, and the resulting inventory.
def _inventory_add_lines(self, revision_id, parents, lines, check_content=True):
Store lines in inv_vf and return the sha1 of the inventory.
def add_revision(self, revision_id, rev, inv=None, config=None):
Add rev to the revision store as revision_id.
Parametersrevision_idthe revision id to use.
revThe revision object.
invThe inventory for the revision. if None, it will be looked up in the inventory storer
configIf None no digital signature will be created. If supplied its signature_needed method will be used to determine if a signature should be made.
def _add_revision(self, revision):
Undocumented
def _check_inventories(self, checker):
Check the inventories found from the revision scan.

This is responsible for verifying the sha1 of inventories and creating a pending_keys set that covers data referenced by inventories.

def _do_check_inventories(self, checker, bar):
Helper for _check_inventories.
def _check_record(self, kind, record, checker, last_object, item_data):
Check a single text from this repository.
def _check_text(self, record, checker, item_data):
Check a single text.
@needs_read_lock
def _eliminate_revisions_not_present(self, revision_ids):
Check every revision id in revision_ids to see if we have it.

Returns a set of the present revisions.

def __init__(self, _format, a_bzrdir, control_files):
Instantiate a VersionedFileRepository.
Parameters_formatThe format of the repository on disk.
controldirThe ControlDir of the repository.
control_filesControl files to use for locking, etc.
@needs_read_lock
def gather_stats(self, revid=None, committers=None):
See Repository.gather_stats().
def get_commit_builder(self, branch, parents, config, timestamp=None, timezone=None, committer=None, revprops=None, revision_id=None, lossy=False):
Obtain a CommitBuilder for this repository.
ParametersbranchBranch to commit to.
parentsRevision ids of the parents of the new revision.
configConfiguration to use.
timestampOptional timestamp recorded for commit.
timezoneOptional timezone for timestamp.
committerOptional committer to set for commit.
revpropsOptional dictionary of revision properties.
revision_idOptional revision id.
lossyWhether to discard data that can not be natively represented, when pushing to a foreign VCS
def get_missing_parent_inventories(self, check_for_missing_texts=True):
Return the keys of missing inventory parents for revisions added in this write group.

A revision is not complete if the inventory delta for that revision cannot be calculated. Therefore if the parent inventories of a revision are not present, the revision is incomplete, and e.g. cannot be streamed by a smart server. This method finds missing inventory parents for revisions added in this write group.

@needs_read_lock
def has_revisions(self, revision_ids):
Probe to find out the presence of multiple revisions.
Parametersrevision_idsAn iterable of revision_ids.
ReturnsA set of the revision_ids that were present.
@needs_read_lock
def get_revision_reconcile(self, revision_id):
'reconcile' helper routine that allows access to a revision always.

This variant of get_revision does not cross check the weave graph against the revision one as get_revision does: but it should only be used by reconcile, or reconcile-alike commands that are correcting or testing the revision graph.

@needs_read_lock
def get_revisions(self, revision_ids):
Get many revisions at once.

Repositories that need to check data on every revision read should subclass this method.

@needs_read_lock
def _get_revisions(self, revision_ids):
Core work logic to get many revisions without sanity checks.
def _iter_revisions(self, revision_ids):
Iterate over revision objects.
Parametersrevision_idsAn iterable of revisions to examine. None may be passed to request all revisions known to the repository. Note that not all repositories can find unreferenced revisions; for those repositories only referenced ones will be returned.
ReturnsAn iterator of (revid, revision) tuples. Absent revisions ( those asked for but not available) are returned as (revid, None).
@needs_write_lock
def add_signature_text(self, revision_id, signature):
Store a signature text for a revision.
Parametersrevision_idRevision id of the revision
signatureSignature text.
def find_text_key_references(self):
Find the text key references within the repository.
ReturnsA dictionary mapping text keys ((fileid, revision_id) tuples) to whether they were referred to by the inventory of the revision_id that they contain. The inventory texts from all present revision ids are assessed to generate this report.
def _inventory_xml_lines_for_keys(self, keys):
Get a line iterator of the sort needed for findind references.

Not relevant for non-xml inventory repositories.

Ghosts in revision_keys are ignored.

Parametersrevision_keysThe revision keys for the inventories to inspect.
ReturnsAn iterator over (inventory line, revid) for the fulltexts of all of the xml inventories specified by revision_keys.
def _find_file_ids_from_xml_inventory_lines(self, line_iterator, revision_keys):
Helper routine for fileids_altered_by_revision_ids.

This performs the translation of xml lines to revision ids.

Parametersline_iteratorAn iterator of lines, origin_version_id
revision_keysThe revision ids to filter for. This should be a set or other type which supports efficient __contains__ lookups, as the revision key from each parsed line will be looked up in the revision_keys filter.
Returnsa dictionary mapping altered file-ids to an iterable of revision_ids. Each altered file-ids has the exact revision_ids that altered it listed explicitly.
def _find_parent_keys_of_revisions(self, revision_keys):
Similar to _find_parent_ids_of_revisions, but used with keys.
Parametersrevision_keysAn iterable of revision_keys.
ReturnsThe parents of all revision_keys that are not already in revision_keys
def fileids_altered_by_revision_ids(self, revision_ids, _inv_weave=None):
Find the file ids and versions affected by revisions.
Parametersrevisionsan iterable containing revision ids.
_inv_weaveThe inventory weave from this repository or None. If None, the inventory weave will be opened automatically.
Returnsa dictionary mapping altered file-ids to an iterable of revision_ids. Each altered file-ids has the exact revision_ids that altered it listed explicitly.
def iter_files_bytes(self, desired_files):
Iterate through file versions.

Files will not necessarily be returned in the order they occur in desired_files. No specific order is guaranteed.

Yields pairs of identifier, bytes_iterator. identifier is an opaque value supplied by the caller as part of desired_files. It should uniquely identify the file version in the caller's context. (Examples: an index number or a TreeTransform trans_id.)

bytes_iterator is an iterable of bytestrings for the file. The kind of iterable and length of the bytestrings are unspecified, but for this implementation, it is a list of bytes produced by VersionedFile.get_record_stream().

Parametersdesired_filesa list of (file_id, revision_id, identifier) triples
def _generate_text_key_index(self, text_key_references=None, ancestors=None):
Generate a new text key index for the repository.

This is an expensive function that will take considerable time to run.

ReturnsA dict mapping text keys ((file_id, revision_id) tuples) to a list of parents, also text keys. When a given key has no parents, the parents list will be [NULL_REVISION].
def _do_generate_text_key_index(self, ancestors, text_key_references, pb):
Helper for _generate_text_key_index to avoid deep nesting.
def item_keys_introduced_by(self, revision_ids, _files_pb=None):
Get an iterable listing the keys of all the data introduced by a set of revision IDs.

The keys will be ordered so that the corresponding items can be safely fetched and inserted in that order.

ReturnsAn iterable producing tuples of (knit-kind, file-id, versions). knit-kind is one of 'file', 'inventory', 'signatures', 'revisions'. file-id is None unless knit-kind is 'file'.
def _find_file_keys_to_fetch(self, revision_ids, pb):
Undocumented
def _find_non_file_keys_to_fetch(self, revision_ids):
Undocumented
@needs_read_lock
def get_inventory(self, revision_id):
Get Inventory object by revision id.
def iter_inventories(self, revision_ids, ordering=None):
Get many inventories by revision_ids.

This will buffer some or all of the texts used in constructing the inventories in memory, but will only parse a single inventory at a time.

Parametersrevision_idsThe expected revision ids of the inventories.
orderingoptional ordering, e.g. 'topological'. If not specified, the order of revision_ids will be preserved (by buffering if necessary).
ReturnsAn iterator of inventories.
def _iter_inventories(self, revision_ids, ordering):
single-document based inventory iteration.
def _iter_inventory_xmls(self, revision_ids, ordering):
Undocumented
def _deserialise_inventory(self, revision_id, xml):
Transform the xml into an inventory object.
Parametersrevision_idThe expected revision id of the inventory.
xmlA serialised inventory.
def get_serializer_format(self):
Undocumented
@needs_read_lock
def _get_inventory_xml(self, revision_id):
Get serialized inventory as a string.
@needs_read_lock
def revision_tree(self, revision_id):
Return Tree for a revision on this branch.

revision_id may be NULL_REVISION for the empty tree revision.

def revision_trees(self, revision_ids):
Return Trees for revisions in this repository.
Parametersrevision_idsa sequence of revision-ids; a revision-id may not be None or 'null:'
def _filtered_revision_trees(self, revision_ids, file_ids):
Return Tree for a revision on this branch with only some files.
Parametersrevision_idsa sequence of revision-ids; a revision-id may not be None or 'null:'
file_idsif not None, the result is filtered so that only those file-ids, their parents and their children are included.
def get_parent_map(self, revision_ids):
See graph.StackedParentsProvider.get_parent_map
@needs_read_lock
def get_known_graph_ancestry(self, revision_ids):
Return the known graph for a set of revision ids and their ancestors.
@needs_read_lock
def get_file_graph(self):
Return the graph walker for text revisions.
def _get_versioned_file_checker(self, text_key_references=None, ancestors=None):
Return an object suitable for checking versioned files.
Parameterstext_key_referencesif non-None, an already built dictionary mapping text keys ((fileid, revision_id) tuples) to whether they were referred to by the inventory of the revision_id that they contain. If None, this will be calculated.
ancestorsOptional result from self.get_graph().get_parent_map(self.all_revision_ids()) if already available.
@needs_read_lock
def has_signature_for_revision_id(self, revision_id):
Query for a revision signature for revision_id in the repository.
@needs_read_lock
def get_signature_text(self, revision_id):
Return the text for a signature.
@needs_read_lock
def _check(self, revision_ids, callback_refs, check_repo):
Undocumented
def _find_inconsistent_revision_parents(self, revisions_iterator=None):
Find revisions with different parent lists in the revision object and in the index graph.
Parametersrevisions_iteratorNone, or an iterator of (revid, Revision-or-None). This iterator controls the revisions checked.
Returnsan iterator yielding tuples of (revison-id, parents-in-index, parents-in-revision).
def _check_for_inconsistent_revision_parents(self):
Undocumented
def _get_sink(self):
Return a sink for streaming into this repository.
def _get_source(self, to_format):
Return a source for streaming from this repository.
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.