~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

iter_interesting_nodes no longer buffers record objects.
Instead, it double-requests them, which means that we can now cleanly
clear the refcycle from lazy content manager to the lazy content.
(at the end of get_record_stream()).

Show diffs side-by-side

added added

removed removed

Lines of Context:
506
506
                self._manager._prepare_for_extract()
507
507
                block = self._manager._block
508
508
                self._bytes = block.extract(self.key, self._start, self._end)
509
 
                # XXX: It seems the smart fetch extracts inventories and chk
510
 
                #      pages as fulltexts to find the next chk pages, but then
511
 
                #      passes them down to be inserted as a
512
 
                #      groupcompress-block, so this is not safe to do. Perhaps
513
 
                #      we could just change the storage kind to "fulltext" at
514
 
                #      that point?
 
509
                # There are code paths that first extract as fulltext, and then
 
510
                # extract as storage_kind (smart fetch). So we don't break the
 
511
                # refcycle here, but instead in manager.get_record_stream()
515
512
                # self._manager = None
516
513
            if storage_kind == 'fulltext':
517
514
                return self._bytes
551
548
            yield factory
552
549
            # Break the ref-cycle
553
550
            factory._bytes = None
554
 
            # XXX: this is not safe, the smart fetch code requests the content
555
 
            #      as both a 'fulltext', and then later on as a
556
 
            #      groupcompress-block. The iter_interesting_nodes code also is
557
 
            #      still buffering multiple records and returning them later.
558
 
            #      So that code would need to be updated to either re-fetch the
559
 
            #      original object, or buffer it somehow.
560
 
            # factory._manager = None
 
551
            factory._manager = None
561
552
        # TODO: Consider setting self._factories = None after the above loop,
562
553
        #       as it will break the reference cycle
563
554
 
667
658
            record_header = '%s\n%s\n%d\n%d\n' % (
668
659
                key_bytes, parent_bytes, factory._start, factory._end)
669
660
            header_lines.append(record_header)
 
661
            # TODO: Can we break the refcycle at this point and set
 
662
            #       factory._manager = None?
670
663
        header_bytes = ''.join(header_lines)
671
664
        del header_lines
672
665
        header_bytes_len = len(header_bytes)