[merge] faster knit extraction & better errors if unable to get delta parent

Robert Collins robertc at robertcollins.net
Tue Oct 23 07:10:08 BST 2007


On Tue, 2007-10-23 at 15:59 +1000, Martin Pool wrote:
> 
> === modified file 'bzrlib/knit.py'
> --- bzrlib/knit.py      2007-10-22 01:23:51 +0000
> +++ bzrlib/knit.py      2007-10-22 07:34:32 +0000
> @@ -815,7 +815,17 @@
>                  if method == 'fulltext':
>                      next = None
>                  else:
> -                    next = self.get_parents(cursor)[0]
> +                    parents = self.get_parents_with_ghosts(cursor)

This part is fine and good...

> +                    try:
> +                        next = parents[0]
> +                    except IndexError:
> +                        raise KnitCorrupt(
> +                            self,
> +                            "\nversion %s\n"
> +                            "    has compression method %r " \
> +                            "but index parents %r " % (
> +                            cursor, method, parents))
> +                    next = parents[0]

However this isn't - for two reasons.
The first is that it was triggering before because get_parents was
reducing the parents by removing absent keys, and
get_parents_with_ghosts won't do that, so you will need a index with no
parents at all to trigger this for that record.
Secondly, there is a cost for exception contexts, and this is right in
an inner loop, so I would actually expect this to cost performance
as-is.

>                  index_memo = self._index.get_position(cursor)
>                  component_data[cursor] = (method, index_memo, next)
>                  cursor = next

-Rob

-- 
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/20071023/bc210cb2/attachment.pgp 


More information about the bazaar mailing list