/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: Parth Malwankar
  • Date: 2010-05-13 06:54:21 UTC
  • mfrom: (5225 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5241.
  • Revision ID: parth.malwankar@gmail.com-20100513065421-bde255i4ga5o3oqe
merged in changes from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    pack,
34
34
    static_tuple,
35
35
    trace,
 
36
    ui,
36
37
    )
37
38
from bzrlib.btree_index import BTreeBuilder
38
39
from bzrlib.lru_cache import LRUSizeCache
1584
1585
                        record.get_bytes_as('fulltext'))
1585
1586
        return result
1586
1587
 
1587
 
    def insert_record_stream(self, stream):
 
1588
    def insert_record_stream(self, stream, stream_type=None, record_counter=None):
1588
1589
        """Insert a record stream into this container.
1589
1590
 
1590
1591
        :param stream: A stream of records to insert.
1595
1596
        # test_insert_record_stream_existing_keys fail for groupcompress and
1596
1597
        # groupcompress-nograph, this needs to be revisited while addressing
1597
1598
        # 'bzr branch' performance issues.
1598
 
        for _ in self._insert_record_stream(stream, random_id=False):
 
1599
        for _ in self._insert_record_stream(stream, random_id=False,
 
1600
                stream_type=stream_type, record_counter=record_counter):
1599
1601
            pass
1600
1602
 
1601
1603
    def _insert_record_stream(self, stream, random_id=False, nostore_sha=None,
1602
 
                              reuse_blocks=True):
 
1604
                              reuse_blocks=True, stream_type=None,
 
1605
                              record_counter=None):
1603
1606
        """Internal core to insert a record stream into this container.
1604
1607
 
1605
1608
        This helper function has a different interface than insert_record_stream
1650
1653
        # XXX: TODO: remove this, it is just for safety checking for now
1651
1654
        inserted_keys = set()
1652
1655
        reuse_this_block = reuse_blocks
 
1656
        counter = 0
 
1657
        key_count = 0
 
1658
        if record_counter and record_counter.max > 0:
 
1659
            pb = ui.ui_factory.nested_progress_bar()
 
1660
            pb.update('', record_counter.current, record_counter.max)
1653
1661
        for record in stream:
 
1662
            # update progressbar only every 51 records
 
1663
            if record_counter and record_counter.max > 0:
 
1664
                if counter == record_counter.step:
 
1665
                    record_counter.increment(counter)
 
1666
                    pb.update('', record_counter.current, record_counter.max)
 
1667
                    counter = 0
 
1668
                counter += 1
 
1669
            if stream_type == 'revisions':
 
1670
                key_count += 1
 
1671
 
1654
1672
            # Raise an error when a record is missing.
1655
1673
            if record.storage_kind == 'absent':
1656
1674
                raise errors.RevisionNotPresent(record.key, self)
1757
1775
        if len(keys_to_add):
1758
1776
            flush()
1759
1777
        self._compressor = None
 
1778
        if record_counter and record_counter.max > 0:
 
1779
            pb.finished()
 
1780
        if stream_type == 'revisions':
 
1781
            record_counter.setup(key_count,
 
1782
                record_counter.current,
 
1783
                record_counter.stream_type)
 
1784
 
1760
1785
 
1761
1786
    def iter_lines_added_or_present_in_keys(self, keys, pb=None):
1762
1787
        """Iterate over the lines in the versioned files from keys.