~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Robert Collins
  • Date: 2007-08-24 00:05:53 UTC
  • mto: (2592.5.3 pack-repository)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20070824000553-zt52bftmpw60ylv4
hackish fix, but all tests passing again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
            # inv 'knit' has been used : update it.
103
103
            self.repo._inv_all_indices.insert_index(0,
104
104
                pack.inventory_index)
 
105
            self.repo._inv_pack_map[pack.inventory_index] = pack.transport, pack.name + '.pack'
105
106
        if self.repo._text_all_indices is not None:
106
107
            # text 'knits' have been used : update it.
107
108
            self.repo._text_all_indices.insert_index(0,
242
243
            revision_keys = None
243
244
        revision_nodes = self._index_contents(revision_index_map, revision_keys)
244
245
        # copy revision keys and adjust values
245
 
        self._copy_nodes_graph(revision_nodes, revision_index_map, writer, revision_index)
 
246
        list(self._copy_nodes_graph(revision_nodes, revision_index_map, writer,
 
247
            revision_index))
246
248
        if 'fetch' in debug.debug_flags:
247
249
            mutter('%s: create_pack: revisions copied: %s%s %d items t+%6.3fs',
248
250
                time.ctime(), self.repo._upload_transport.base, random_name,
252
254
        inv_keys = revision_keys # currently the same keyspace
253
255
        inv_nodes = self._index_contents(inventory_index_map, inv_keys)
254
256
        # copy inventory keys and adjust values
255
 
        self._copy_nodes_graph(inv_nodes, inventory_index_map, writer, inv_index)
 
257
        # XXX: Should be a helper function to allow different inv representation
 
258
        # at this point.
 
259
        inv_lines = self._copy_nodes_graph(inv_nodes, inventory_index_map,
 
260
            writer, inv_index, output_lines=True)
 
261
        for line in inv_lines:
 
262
            pass
256
263
        if 'fetch' in debug.debug_flags:
257
264
            mutter('%s: create_pack: inventories copied: %s%s %d items t+%6.3fs',
258
265
                time.ctime(), self.repo._upload_transport.base, random_name,
261
268
        # select text keys
262
269
        text_nodes = self._index_contents(text_index_map)
263
270
        # copy text keys and adjust values
264
 
        self._copy_nodes_graph(text_nodes, text_index_map, writer, text_index)
 
271
        list(self._copy_nodes_graph(text_nodes, text_index_map, writer,
 
272
            text_index))
265
273
        if 'fetch' in debug.debug_flags:
266
274
            mutter('%s: create_pack: file texts copied: %s%s %d items t+%6.3fs',
267
275
                time.ctime(), self.repo._upload_transport.base, random_name,
488
496
                pos, size = writer.add_bytes_record(raw_data, names)
489
497
                write_index.add_node(key, eol_flag + "%d %d" % (pos, size))
490
498
 
491
 
    def _copy_nodes_graph(self, nodes, index_map, writer, write_index):
 
499
    def _copy_nodes_graph(self, nodes, index_map, writer, write_index,
 
500
        output_lines=False):
 
501
        """Copy knit nodes between packs.
 
502
 
 
503
        :param output_lines: Return lines present in the copied data as
 
504
            an iterator.
 
505
        """
492
506
        # for record verification
493
507
        knit_data = _KnitData(None)
 
508
        # for line extraction when requested (inventories only)
 
509
        if output_lines:
 
510
            factory = knit.KnitPlainFactory()
494
511
        # plan a readv on each source pack:
495
512
        # group by pack
496
513
        nodes = sorted(nodes)
519
536
            for (names, read_func), (_1, _2, (key, eol_flag, references)) in \
520
537
                izip(reader.iter_records(), pack_readv_requests):
521
538
                raw_data = read_func(None)
522
 
                df, _ = knit_data._parse_record_header(key[-1], raw_data)
523
 
                df.close()
 
539
                if output_lines:
 
540
                    # read the entire thing
 
541
                    content, _ = knit_data._parse_record(key[-1], raw_data)
 
542
                    if len(references[-1]) == 0:
 
543
                        line_iterator = factory.get_fulltext_content(content)
 
544
                    else:
 
545
                        line_iterator = factory.get_linedelta_content(content)
 
546
                    for line in line_iterator:
 
547
                        yield line
 
548
                else:
 
549
                    # check the header only
 
550
                    df, _ = knit_data._parse_record_header(key[-1], raw_data)
 
551
                    df.close()
524
552
                pos, size = writer.add_bytes_record(raw_data, names)
525
553
                write_index.add_node(key, eol_flag + "%d %d" % (pos, size), references)
526
554