~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: Parth Malwankar
  • Date: 2010-05-12 12:08:44 UTC
  • mto: This revision was merged to the branch mainline in revision 5241.
  • Revision ID: parth.malwankar@gmail.com-20100512120844-d60qr48yp275okze
optimized to use "revisions" insert_record_stream for counting #records
rather than getting them eargerly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1652
1652
        # XXX: TODO: remove this, it is just for safety checking for now
1653
1653
        inserted_keys = set()
1654
1654
        reuse_this_block = reuse_blocks
1655
 
        current_count = 0
1656
1655
        counter = 0
1657
 
        pb = ui.ui_factory.nested_progress_bar()
1658
 
        pb.update('', record_counter.current, record_counter.max)
 
1656
        if record_counter.max > 0:
 
1657
            pb = ui.ui_factory.nested_progress_bar()
 
1658
            pb.update('', record_counter.current, record_counter.max)
1659
1659
        for record in stream:
1660
 
            # update progressbar only every 50 records
 
1660
            # update progressbar only every 51 records
1661
1661
            if record_counter.max > 0:
1662
 
                if counter == 50:
 
1662
                if counter == 51:
1663
1663
                    if record_counter.current > record_counter.max:
1664
1664
                        record_counter.max += int(record_counter.key_count / 2)
1665
1665
                    pb.update('', record_counter.current, record_counter.max)
1666
1666
                    record_counter.current += counter
1667
1667
                    counter = 0
1668
 
 
1669
1668
                counter += 1
 
1669
            if record_counter.substream_type == 'revisions' and record_counter.key_count == -1:
 
1670
                record_counter.current += 1
 
1671
 
1670
1672
            # Raise an error when a record is missing.
1671
1673
            if record.storage_kind == 'absent':
1672
1674
                raise errors.RevisionNotPresent(record.key, self)
1774
1776
            flush()
1775
1777
        self._compressor = None
1776
1778
        if record_counter.max > 0:
1777
 
            record_counter.current += counter
1778
 
        pb.finished()
 
1779
            pb.finished()
 
1780
        if record_counter.substream_type == 'revisions' and record_counter.key_count == -1:
 
1781
            record_counter.key_count = record_counter.current
 
1782
            record_counter.max = int(record_counter.current * 9.7)
1779
1783
 
1780
1784
 
1781
1785
    def iter_lines_added_or_present_in_keys(self, keys, pb=None):