~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 15:27:29 UTC
  • mto: This revision was merged to the branch mainline in revision 5241.
  • Revision ID: parth.malwankar@gmail.com-20100512152729-n279zca61l6nf33z
remote push now shows estimated work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1585
1585
                        record.get_bytes_as('fulltext'))
1586
1586
        return result
1587
1587
 
1588
 
    def insert_record_stream(self, stream, record_counter=None):
 
1588
    def insert_record_stream(self, stream, stream_type=None, record_counter=None):
1589
1589
        """Insert a record stream into this container.
1590
1590
 
1591
1591
        :param stream: A stream of records to insert.
1597
1597
        # groupcompress-nograph, this needs to be revisited while addressing
1598
1598
        # 'bzr branch' performance issues.
1599
1599
        for _ in self._insert_record_stream(stream, random_id=False,
1600
 
                record_counter=record_counter):
 
1600
                stream_type=stream_type, record_counter=record_counter):
1601
1601
            pass
1602
1602
 
1603
1603
    def _insert_record_stream(self, stream, random_id=False, nostore_sha=None,
1604
 
                              reuse_blocks=True, record_counter=None):
 
1604
                              reuse_blocks=True, stream_type=None,
 
1605
                              record_counter=None):
1605
1606
        """Internal core to insert a record stream into this container.
1606
1607
 
1607
1608
        This helper function has a different interface than insert_record_stream
1653
1654
        inserted_keys = set()
1654
1655
        reuse_this_block = reuse_blocks
1655
1656
        counter = 0
 
1657
        key_count = 0
1656
1658
        if record_counter and record_counter.max > 0:
1657
1659
            pb = ui.ui_factory.nested_progress_bar()
1658
1660
            pb.update('', record_counter.current, record_counter.max)
1659
1661
        for record in stream:
1660
1662
            # update progressbar only every 51 records
1661
1663
            if record_counter and record_counter.max > 0:
1662
 
                if counter == 51:
1663
 
                    if record_counter.current > record_counter.max:
1664
 
                        record_counter.max += record_counter.key_count
 
1664
                if counter == record_counter.step:
 
1665
                    record_counter.increment(counter)
1665
1666
                    pb.update('', record_counter.current, record_counter.max)
1666
 
                    record_counter.current += counter
1667
1667
                    counter = 0
1668
1668
                counter += 1
1669
 
            if (record_counter and
1670
 
                    record_counter.substream_type == 'revisions' and
1671
 
                    record_counter.key_count == -1):
1672
 
                record_counter.current += 1
 
1669
            if stream_type == 'revisions':
 
1670
                key_count += 1
1673
1671
 
1674
1672
            # Raise an error when a record is missing.
1675
1673
            if record.storage_kind == 'absent':
1779
1777
        self._compressor = None
1780
1778
        if record_counter and record_counter.max > 0:
1781
1779
            pb.finished()
1782
 
        if (record_counter and
1783
 
                record_counter.substream_type == 'revisions' and
1784
 
                record_counter.key_count == -1):
1785
 
            record_counter.key_count = record_counter.current
1786
 
            record_counter.max = int(record_counter.current * 9.7)
 
1780
        if stream_type == 'revisions':
 
1781
            record_counter.setup(key_count,
 
1782
                record_counter.current,
 
1783
                record_counter.stream_type)
1787
1784
 
1788
1785
 
1789
1786
    def iter_lines_added_or_present_in_keys(self, keys, pb=None):