~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: Andrew Bennetts
  • Date: 2009-08-25 04:04:23 UTC
  • mto: This revision was merged to the branch mainline in revision 4657.
  • Revision ID: andrew.bennetts@canonical.com-20090825040423-pwb99h8l2yjenooc
Simplify further, comment more.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1021
1021
        """
1022
1022
        if self.manager is None and not self.keys:
1023
1023
            return
 
1024
        # First, determine the list of memos to get.
1024
1025
        memos_to_get = []
1025
 
        keys_to_get = []
1026
1026
        last_read_memo = self.last_read_memo
1027
1027
        for key in self.keys:
1028
1028
            index_memo = self.locations[key][0]
1029
1029
            read_memo = index_memo[:3]
1030
1030
            if last_read_memo != read_memo:
1031
1031
                memos_to_get.append(read_memo)
1032
 
                keys_to_get.append(key)
1033
1032
                last_read_memo = read_memo
 
1033
        # Second, we fetch all those memos in one batch.
1034
1034
        blocks = self.gcvf._get_blocks(memos_to_get)
1035
 
        block_map = {}
1036
 
        for block, key in zip(blocks, keys_to_get):
1037
 
            block_map[key] = block
 
1035
        # Finally, we turn blocks into factories and yield them.
1038
1036
        for key in self.keys:
1039
1037
            index_memo, _, parents, _ = self.locations[key]
1040
1038
            read_memo = index_memo[:3]
1044
1042
                # now, so yield records
1045
1043
                for factory in self.empty_manager():
1046
1044
                    yield factory
1047
 
                # Now start a new manager
1048
 
                block = block_map[key]
 
1045
                # Now start a new manager.  The next block from _get_blocks
 
1046
                # will be the block we need.
 
1047
                block = blocks.next()
1049
1048
                self.manager = _LazyGroupContentManager(block)
1050
1049
                self.last_read_memo = read_memo
1051
1050
            start, end = index_memo[3:5]
1220
1219
            missing.difference_update(set(new_result))
1221
1220
        return result, source_results
1222
1221
 
1223
 
    def _get_blocks(self, index_memos):
1224
 
        read_memos = [index_memo[0:3] for index_memo in index_memos]
 
1222
    def _get_blocks(self, read_memos):
 
1223
        """Get GroupCompressBlocks for the given read_memos.
 
1224
 
 
1225
        Blocks are returned in the order specified in read_memos.
 
1226
        """
1225
1227
        cached = {}
1226
1228
        for read_memo in read_memos:
1227
1229
            try: