[merge][1.0][#164637] KnitVersionedFile.get_data_stream takes compression dependencies into account

Robert Collins robertc at robertcollins.net
Mon Nov 26 20:23:37 GMT 2007


bb:tweak

Cheers,
Rob

On Mon, 2007-11-26 at 18:43 +1100, Martin Pool wrote:
> === modified file 'bzrlib/knit.py'
> --- bzrlib/knit.py      2007-11-09 17:50:31 +0000
> +++ bzrlib/knit.py      2007-11-26 07:20:17 +0000
> @@ -575,7 +575,11 @@
>          """Get a data stream for the specified versions.
>  
>          Versions may be returned in any order, not necessarily the
> order
> -        specified.
> +        specified.  They are returned in a partial order by
> compression
> +        parent, so that the deltas can be applied as the data stream
> is
> +        inserted; however note that compression parents will not be
> sent
> +        unless they were specifically requested, as the client may
> already
> +        have them.
>  
>          :param required_versions: The exact set of versions to be
> extracted.
>              Unlike some other knit methods, this is not used to
> generate a
> @@ -584,35 +588,49 @@
>          :returns: format_signature, list of (version, options,
> length, parents),
>              reader_callable.
>          """
> -        if not isinstance(required_versions, set):
> -            required_versions = set(required_versions)
> -        # we don't care about inclusions, the caller cares.
> -        # but we need to setup a list of records to visit.
> +        required_version_set = frozenset(required_versions)
> +        version_index = {}
> +        # list of revisions that can just be sent without waiting for
> their
> +        # compression parent
> +        ready_to_send = []
> +        # map from revision to the children based on it
> +        deferred = {}
> +        # first, read all relevant index data, enough to sort into
> the right
> +        # order to return
>          for version_id in required_versions:
>              if not self.has_version(version_id):
>                  raise RevisionNotPresent(version_id, self.filename)

The above test is harmful; just nuke it and let the function fail as it
actually accesses data.

> -        # Pick the desired versions out of the index in
> oldest-to-newest order
> -        version_list = []
> -        for version_id in self.versions():
> -            if version_id in required_versions:
> -                version_list.append(version_id)
> -
> -        # create the list of version information for the result
> -        copy_queue_records = []
> -        copy_set = set()
> -        result_version_list = []
> -        for version_id in version_list:
>              options = self._index.get_options(version_id)
>              parents = self._index.get_parents_with_ghosts(version_id)
>              index_memo = self._index.get_position(version_id)
> +            version_index[version_id] = (index_memo, options,
> parents)
> +            if parents and parents[0] in required_version_set:

This test is slightly incorrect, I suggest:
    if 'line-delta' in options and parents[0] in required_version_set:
because being a line-delta is the thing we need to wait on.

> +                # must wait until the parent has been sent
> +                deferred.setdefault(parents[0], []). \
> +                    append(version_id)
> +            else:


 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20071127/498f417b/attachment.pgp 


More information about the bazaar mailing list