~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-10-29 16:54:00 UTC
  • mfrom: (2947.1.6 pack-progress)
  • mto: This revision was merged to the branch mainline in revision 3038.
  • Revision ID: robertc@robertcollins.net-20071029165400-vewpp1vwd60ycibq
Progress bar take two.

Show diffs side-by-side

added added

removed removed

Lines of Context:
617
617
        if self._new_pack is not None:
618
618
            raise errors.BzrError('call to create_pack_from_packs while '
619
619
                'another pack is being written.')
620
 
        if revision_ids is not None and len(revision_ids) == 0:
621
 
            # silly fetch request.
622
 
            return None
 
620
        if revision_ids is not None:
 
621
            if len(revision_ids) == 0:
 
622
                # silly fetch request.
 
623
                return None
 
624
            else:
 
625
                revision_ids = frozenset(revision_ids)
623
626
        pb = ui.ui_factory.nested_progress_bar()
624
627
        try:
625
628
            return self._create_pack_from_packs(packs, suffix, revision_ids,
629
632
 
630
633
    def _create_pack_from_packs(self, packs, suffix, revision_ids, pb):
631
634
        pb.update("Opening pack", 0, 5)
632
 
        revision_ids = frozenset(revision_ids)
633
635
        new_pack = NewPack(self._upload_transport, self._index_transport,
634
636
            self._pack_transport, upload_suffix=suffix)
635
637
        # buffer data - we won't be reading-back during the pack creation and
840
842
        return pack_operations
841
843
 
842
844
    def _copy_nodes(self, nodes, index_map, writer, write_index):
 
845
        """Copy knit nodes between packs with no graph references."""
 
846
        pb = ui.ui_factory.nested_progress_bar()
 
847
        try:
 
848
            return self._do_copy_nodes(nodes, index_map, writer,
 
849
                write_index, pb)
 
850
        finally:
 
851
            pb.finished()
 
852
 
 
853
    def _do_copy_nodes(self, nodes, index_map, writer, write_index, pb):
 
854
        # for record verification
 
855
        knit_data = _KnitData(None)
843
856
        # plan a readv on each source pack:
844
857
        # group by pack
845
858
        nodes = sorted(nodes)
852
865
            if index not in request_groups:
853
866
                request_groups[index] = []
854
867
            request_groups[index].append((key, value))
 
868
        record_index = 0
 
869
        pb.update("Copied record", record_index, len(nodes))
855
870
        for index, items in request_groups.iteritems():
856
871
            pack_readv_requests = []
857
872
            for key, value in items:
868
883
            for (names, read_func), (_1, _2, (key, eol_flag)) in \
869
884
                izip(reader.iter_records(), pack_readv_requests):
870
885
                raw_data = read_func(None)
 
886
                # check the header only
 
887
                df, _ = knit_data._parse_record_header(key[-1], raw_data)
 
888
                df.close()
871
889
                pos, size = writer.add_bytes_record(raw_data, names)
872
890
                write_index.add_node(key, eol_flag + "%d %d" % (pos, size))
 
891
                pb.update("Copied record", record_index)
 
892
                record_index += 1
873
893
 
874
894
    def _copy_nodes_graph(self, nodes, index_map, writer, write_index,
875
895
        output_lines=False):