[MERGE] Add scan_unvalidated_index to _KnitGraphIndex, add external_refernces to GraphIndex and BTreeGraphIndex.

Robert Collins robert.collins at canonical.com
Thu Feb 19 22:32:05 GMT 2009


On Fri, 2009-02-20 at 09:08 +1100, Andrew Bennetts wrote:

index.py:
> +    def external_references(self, ref_list_num=None):

Please get right of the =None here, the code below does not handle it.


> === modified file 'bzrlib/knit.py'
> --- bzrlib/knit.py      2009-02-02 05:56:34 +0000
> +++ bzrlib/knit.py      2009-02-19 03:49:50 +0000
> @@ -1881,6 +1881,14 @@
>                  self._kndx_cache[prefix] = (orig_cache, orig_history)
>                  raise
>  
> +    def scan_unvalidated_index(self, graph_index):
> +        """See _KnitGraphIndex.scan_unvalidated_index."""
> +        raise NotImplementedError(self.scan_unvalidated_index)

This deserves a comment ("kndx files do not support atomic insertion,
and cannot support this method")
> 
> +    def get_missing_compression_parents(self):
> +        """See _KnitGraphIndex.get_missing_compression_parents."""
> +        return frozenset()

And I think this one should raise as well, because it doesn't make sense
without the other method (scan) working.

> @@ -2263,6 +2272,26 @@
>                  result.append((key, value))
>          self._add_callback(result)
>          
> +    def scan_unvalidated_index(self, graph_index):
> +        """Inform this _KnitGraphIndex that there is an unvalidated
> index.
> +
> +        This allows this _KnitGraphIndex to keep track of any missing
> +        compression parents we may want to have filled in to make
> those
> +        indices valid.
> +
> +        :param graph_index: A GraphIndex
> +        """
> +        self._missing_compression_parents.update(
> +            graph_index.external_references(ref_list_num=1))
> +        self._missing_compression_parents.difference_update(
> +            self.get_parent_map(self._missing_compression_parents))

This could be tweaked:
(btw, the hard coded ref_list_num=1) is probably a bug, no-delta
versioned files objects won't want to scan at all. Probably a missing
smoke test case somewhere).
if not self.delta:
    return
new_missing = graph_index.external_references(ref_list_num=1)
self._missing_compression_parents.update(new_missing)
self._missing_compression_parents.difference_update(
    self.get_parent_map(new_missing))


> === modified file 'bzrlib/repofmt/pack_repo.py'
> --- bzrlib/repofmt/pack_repo.py 2009-01-08 16:57:10 +0000
> +++ bzrlib/repofmt/pack_repo.py 2009-02-19 03:37:40 +0000
> @@ -1971,6 +1971,13 @@
>          self._pack_collection._start_write_group()
>  
>      def _commit_write_group(self):
> +        vfs = [self.revisions, self.inventories, self.texts,
> self.signatures]
> +        for vf in vfs:
> +            missing = vf._index.get_missing_compression_parents()
> +            if missing:
> +                raise errors.BzrCheckError(
> +                    "Repository %s has missing compression parent(s)
> %r "
> +                    "in %r" % (self, list(missing), vf))
>          return self._pack_collection._commit_write_group()

This is non-test code, lets use slightly longer/better variable names.
Secondly, lets accumulate all the missing keys, then report rather than
reporting the first missing ones.


> +    def test_external_references_two_records(self):
> +        index = self.make_index(ref_lists=1, nodes=[
> +            (('key-1',), 'value', ([('key-2',)],)),
> +            (('key-2',), 'value', ([],)),
> +            ])
> +        self.assertEqual(set([]), index.external_references(0))
> +
> +
> +
>  
>  class TestCombinedGraphIndex(TestCaseWithMemoryTransport):

too much VWS here :(.

-Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090220/fef75f84/attachment.pgp 


More information about the bazaar mailing list