Part of bzrlib.versionedfile View In Hierarchy
Known subclasses: bzrlib.weave.Weave
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 |
Parameters | versions | The versions to include. Each version is a tuple (version,). |
ordering | Either 'unordered' or 'topological'. A topologically sorted stream has compression parents strictly before their children. | |
include_delta_closure | If 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. | |
Returns | An iterator of ContentFactory objects, each of which is only valid until the iterator is advanced. |
Parameters | stream | A stream of records to insert. |
Returns | None | |
See Also |
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.
This takes the same parameters as add_lines and returns the same.
Present Since | 0.90 |
Records should be iterables of version, parents, expected_sha1, mpdiff. mpdiff should be a MultiParent instance.
Raises RevisionNotPresent if version is not present in file history.
Raises RevisionNotPresent if version is not present in file history.
Raises RevisionNotPresent if version is not present in file history.
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.
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.
Parameters | version_ids | The version ids to look up parents for. |
Returns | A mapping from version id to parents. |
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.
Return a list of (version-id, line) tuples for version_id. :raise RevisionNotPresent: If the given version is not present in file history.
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).
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