b.v.VersionedFile(object) : class documentation

Part of bzrlib.versionedfile View In Hierarchy

Known subclasses: bzrlib.weave.Weave

Versioned text file storage.

A versioned file manages versions of line-based text files, keeping track of the originating version for each line.

To clients the "lines" of the file are represented as a list of strings. These strings will typically have terminal newline characters, but this is not required. In particular files commonly do not have a newline at the end of the file.

Texts are identified by a version-id string.

Static Method check_not_reserved_id Undocumented
Method copy_to Copy this versioned file to name on transport.
Method get_record_stream Get a stream of records for versions.
Method has_version Returns whether version is present.
Method insert_record_stream Insert a record stream into this versioned file.
Method add_lines Add a single text on top of the versioned file.
Method add_lines_with_ghosts Add lines to the versioned file, allowing ghosts to be present.
Method check Check the versioned file for integrity.
Method get_format_signature Get a text description of the data encoding in this file.
Method make_mpdiffs Create multiparent diffs for specified versions.
Method add_mpdiffs Add mpdiffs to this VersionedFile.
Method get_text Return version contents as a text string.
Method get_texts Return the texts of listed versions as a list of strings.
Method get_lines Return version contents as a sequence of lines.
Method get_ancestry Return a list of all ancestors of given version(s). This
Method get_ancestry_with_ghosts Return a list of all ancestors of given version(s). This
Method get_parent_map Get a map of the parents of version_ids.
Method get_parents_with_ghosts Return version names for parents of version_id.
Method annotate Return a list of (version-id, line) tuples for version_id.
Method iter_lines_added_or_present_in_versions Iterate over the lines in the versioned file from version_ids.
Method plan_merge Return pseudo-annotation indicating how the two versions merge.
Method weave_merge Undocumented
Method _add_lines Helper to do the class specific add_lines.
Method _add_lines_with_ghosts Helper to do class specific add_lines_with_ghosts.
Method _check_lines_not_unicode Check that lines being added to a versioned file are not unicode.
Method _check_lines_are_lines Check that the lines really are full lines without inline EOL.
Method _extract_blocks Undocumented
Method _get_lf_split_line_list Undocumented
@staticmethod
def check_not_reserved_id(version_id):
Undocumented
def copy_to(self, name, transport):
Copy this versioned file to name on transport.
def get_record_stream(self, versions, ordering, include_delta_closure):
overridden in bzrlib.weave.Weave
Get a stream of records for versions.
ParametersversionsThe versions to include. Each version is a tuple (version,).
orderingEither 'unordered' or 'topological'. A topologically sorted stream has compression parents strictly before their children.
include_delta_closureIf True then the closure across any compression parents will be included (in the data content of the stream, not in the emitted records). This guarantees that 'fulltext' can be used successfully on every record.
ReturnsAn iterator of ContentFactory objects, each of which is only valid until the iterator is advanced.
def has_version(self, version_id):
overridden in bzrlib.weave.Weave
Returns whether version is present.
def insert_record_stream(self, stream):
overridden in bzrlib.weave.Weave
Insert a record stream into this versioned file.
ParametersstreamA stream of records to insert.
ReturnsNone
See Also
def add_lines(self, version_id, parents, lines, parent_texts=None, left_matching_blocks=None, nostore_sha=None, random_id=False, check_content=True):
Add a single text on top of the versioned file.

        Must raise RevisionAlreadyPresent if the new version is
        already present in file history.

        Must raise RevisionNotPresent if any of the given parents are
        not present in file history.

        :param lines: A list of lines. Each line must be a bytestring. And all
            of them except the last must be terminated with 
 and contain no
            other 
's. The last line may either contain no 
's or a single
            terminated 
. If the lines list does meet this constraint the add
            routine may error or may succeed - but you will be unable to read
            the data back accurately. (Checking the lines have been split
            correctly is expensive and extremely unlikely to catch bugs so it
            is not done at runtime unless check_content is True.)
        :param parent_texts: An optional dictionary containing the opaque
            representations of some or all of the parents of version_id to
            allow delta optimisations.  VERY IMPORTANT: the texts must be those
            returned by add_lines or data corruption can be caused.
        :param left_matching_blocks: a hint about which areas are common
            between the text and its left-hand-parent.  The format is
            the SequenceMatcher.get_matching_blocks format.
        :param nostore_sha: Raise ExistingContent and do not add the lines to
            the versioned file if the digest of the lines matches this.
        :param random_id: If True a random id has been selected rather than
            an id determined by some deterministic process such as a converter
            from a foreign VCS. When True the backend may choose not to check
            for uniqueness of the resulting key within the versioned file, so
            this should only be done when the result is expected to be unique
            anyway.
        :param check_content: If True, the lines supplied are verified to be
            bytestrings that are correctly formed lines.
        :return: The text sha1, the number of bytes in the text, and an opaque
                 representation of the inserted version which can be provided
                 back to future add_lines calls in the parent_texts dictionary.
        
def _add_lines(self, version_id, parents, lines, parent_texts, left_matching_blocks, nostore_sha, random_id, check_content):
overridden in bzrlib.weave.Weave
Helper to do the class specific add_lines.
def add_lines_with_ghosts(self, version_id, parents, lines, parent_texts=None, nostore_sha=None, random_id=False, check_content=True, left_matching_blocks=None):
Add lines to the versioned file, allowing ghosts to be present.

This takes the same parameters as add_lines and returns the same.

def _add_lines_with_ghosts(self, version_id, parents, lines, parent_texts, nostore_sha, random_id, check_content, left_matching_blocks):
Helper to do class specific add_lines_with_ghosts.
def check(self, progress_bar=None):
overridden in bzrlib.weave.Weave
Check the versioned file for integrity.
def _check_lines_not_unicode(self, lines):
Check that lines being added to a versioned file are not unicode.
def _check_lines_are_lines(self, lines):
Check that the lines really are full lines without inline EOL.
def get_format_signature(self):
Get a text description of the data encoding in this file.
Present Since0.90
def make_mpdiffs(self, version_ids):
Create multiparent diffs for specified versions.
def _extract_blocks(self, version_id, source, target):
Undocumented
def add_mpdiffs(self, records):
Add mpdiffs to this VersionedFile.

Records should be iterables of version, parents, expected_sha1, mpdiff. mpdiff should be a MultiParent instance.

def get_text(self, version_id):
Return version contents as a text string.

Raises RevisionNotPresent if version is not present in file history.

def get_texts(self, version_ids):
Return the texts of listed versions as a list of strings.

Raises RevisionNotPresent if version is not present in file history.

def get_lines(self, version_id):
overridden in bzrlib.weave.Weave
Return version contents as a sequence of lines.

Raises RevisionNotPresent if version is not present in file history.

def _get_lf_split_line_list(self, version_ids):
Undocumented
def get_ancestry(self, version_ids, topo_sorted=True):
overridden in bzrlib.weave.Weave
Return a list of all ancestors of given version(s). This will not include the null revision.

This list will not be topologically sorted if topo_sorted=False is passed.

Must raise RevisionNotPresent if any of the given versions are not present in file history.

def get_ancestry_with_ghosts(self, version_ids):
Return a list of all ancestors of given version(s). This will not include the null revision.

Must raise RevisionNotPresent if any of the given versions are not present in file history.

Ghosts that are known about will be included in ancestry list, but are not explicitly marked.

def get_parent_map(self, version_ids):
overridden in bzrlib.weave.Weave
Get a map of the parents of version_ids.
Parametersversion_idsThe version ids to look up parents for.
ReturnsA mapping from version id to parents.
def get_parents_with_ghosts(self, version_id):
overridden in bzrlib.weave.Weave
Return version names for parents of version_id.

Will raise RevisionNotPresent if version_id is not present in the history.

Ghosts that are known about will be included in the parent list, but are not explicitly marked.

def annotate(self, version_id):
overridden in bzrlib.weave.Weave
Return a list of (version-id, line) tuples for version_id.

:raise RevisionNotPresent: If the given version is
not present in file history.
def iter_lines_added_or_present_in_versions(self, version_ids=None, pb=None):
overridden in bzrlib.weave.Weave
Iterate over the lines in the versioned file from version_ids.

       This may return lines from other versions. Each item the returned
       iterator yields is a tuple of a line and a text version that that line
       is present in (not introduced in).

       Ordering of results is in whatever order is most suitable for the
       underlying storage format.

       If a progress bar is supplied, it may be used to indicate progress.
       The caller is responsible for cleaning up progress bars (because this
       is an iterator).

       NOTES: Lines are normalised: they will all have 
terminators.
              Lines are returned in arbitrary order.

       :return: An iterator over (line, version_id).
       
def plan_merge(self, ver_a, ver_b):
overridden in bzrlib.weave.Weave
Return pseudo-annotation indicating how the two versions merge.

This is computed between versions a and b and their common base.

Weave lines present in none of them are skipped entirely.

Legend: killed-base Dead in base revision killed-both Killed in each revision killed-a Killed in a killed-b Killed in b unchanged Alive in both a and b (possibly created in both) new-a Created in a new-b Created in b ghost-a Killed in a, unborn in b ghost-b Killed in b, unborn in a irrelevant Not in either revision

def weave_merge(self, plan, a_marker=TextMerge.A_MARKER, b_marker=TextMerge.B_MARKER):
Undocumented
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.