b.x.Serializer_v8(XMLSerializer) : class documentation

Part of bzrlib.xml8 View In Hierarchy

Known subclasses: bzrlib.chk_serializer.CHKSerializer, bzrlib.xml6.Serializer_v6

This serialiser adds rich roots.

Its revision format number matches its inventory number.

Method write_inventory_to_lines Return a list of lines with the encoded inventory.
Method write_inventory_to_string Just call write_inventory with a StringIO and return the value.
Method write_inventory Write inventory to a file.
Method _check_revisions Extension point for subclasses to check during serialisation.
Method _check_cache_size Check that the entry_cache is large enough.
Method _append_inventory_root Append the inventory root to output.
Method _pack_revision Revision object -> xml tree
Method _pack_revision_properties Undocumented
Method _unpack_inventory Construct from XML Element
Method _unpack_entry Undocumented
Method _unpack_revision XML Element -> Revision object
Method _unpack_revision_properties Unpack properties onto a revision.
Method _find_text_key_references Core routine for extracting references to texts from inventories.

Inherited from XMLSerializer:

Method read_inventory_from_string Read xml_string into an inventory object.
Method read_inventory See read_inventory_from_string.
Method write_revision Undocumented
Method write_revision_to_string Undocumented
Method read_revision Undocumented
Method read_revision_from_string Undocumented
Method _write_element Undocumented
Method _read_element Undocumented
def _check_revisions(self, inv):
Extension point for subclasses to check during serialisation.
ParametersinvAn inventory about to be serialised, to be checked.
RaisesAssertionError if an error has occurred.
def _check_cache_size(self, inv_size, entry_cache):
Check that the entry_cache is large enough.

We want the cache to be ~2x the size of an inventory. The reason is because we use a FIFO cache, and how Inventory records are likely to change. In general, you have a small number of records which change often, and a lot of records which do not change at all. So when the cache gets full, you actually flush out a lot of the records you are interested in, which means you need to recreate all of those records. An LRU Cache would be better, but the overhead negates the cache coherency benefit.

One way to look at it, only the size of the cache > len(inv) is your 'working' set. And in general, it shouldn't be a problem to hold 2 inventories in memory anyway.

Parametersinv_sizeThe number of entries in an inventory.
def write_inventory_to_lines(self, inv):
Return a list of lines with the encoded inventory.
def write_inventory_to_string(self, inv, working=False):
Just call write_inventory with a StringIO and return the value.
ParametersworkingIf True skip history data - text_sha1, text_size, reference_revision, symlink_target.
def write_inventory(self, inv, f, working=False):
Write inventory to a file.
Parametersinvthe inventory to write.
fthe file to write. (May be None if the lines are the desired output).
workingIf True skip history data - text_sha1, text_size, reference_revision, symlink_target.
ReturnsThe inventory as a list of lines.
def _append_inventory_root(self, append, inv):
Append the inventory root to output.
def _pack_revision(self, rev):
Revision object -> xml tree
def _pack_revision_properties(self, rev, under_element):
Undocumented
def _unpack_inventory(self, elt, revision_id=None, entry_cache=None, return_from_cache=False):
Construct from XML Element
def _unpack_entry(self, elt, entry_cache=None, return_from_cache=False):
Undocumented
def _unpack_revision(self, elt):
XML Element -> Revision object
def _unpack_revision_properties(self, elt, rev):
Unpack properties onto a revision.
def _find_text_key_references(self, line_iterator):
Core routine for extracting references to texts from inventories.

This performs the translation of xml lines to revision ids.

Parametersline_iteratorAn iterator of lines, origin_version_id
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. Note that if that revision_id was not part of the line_iterator's output then False will be given - even though it may actually refer to that key.
API Documentation for Bazaar, generated by pydoctor at 2019-09-20 00:30:04.