~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
from bzrlib import (
78
78
    cache_utf8,
79
79
    errors,
 
80
    progress,
80
81
    )
81
82
from bzrlib.errors import FileExists, NoSuchFile, KnitError, \
82
83
        InvalidRevisionId, KnitCorrupt, KnitHeaderError, \
798
799
            text_map[version_id] = text 
799
800
        return text_map, final_content 
800
801
 
801
 
    def iter_lines_added_or_present_in_versions(self, version_ids=None):
 
802
    def iter_lines_added_or_present_in_versions(self, version_ids=None, 
 
803
                                                pb=None):
802
804
        """See VersionedFile.iter_lines_added_or_present_in_versions()."""
803
805
        if version_ids is None:
804
806
            version_ids = self.versions()
 
807
        if pb is None:
 
808
            pb = progress.DummyProgress()
805
809
        # we don't care about inclusions, the caller cares.
806
810
        # but we need to setup a list of records to visit.
807
811
        # we need version_id, position, length
819
823
                data_pos, length = self._index.get_position(version_id)
820
824
                version_id_records.append((version_id, data_pos, length))
821
825
 
822
 
        pb = bzrlib.ui.ui_factory.nested_progress_bar()
823
826
        count = 0
824
827
        total = len(version_id_records)
825
 
        try:
 
828
        pb.update('Walking content.', count, total)
 
829
        for version_id, data, sha_value in \
 
830
            self._data.read_records_iter(version_id_records):
826
831
            pb.update('Walking content.', count, total)
827
 
            for version_id, data, sha_value in \
828
 
                self._data.read_records_iter(version_id_records):
829
 
                pb.update('Walking content.', count, total)
830
 
                method = self._index.get_method(version_id)
831
 
                version_idx = self._index.lookup(version_id)
832
 
                assert method in ('fulltext', 'line-delta')
833
 
                if method == 'fulltext':
834
 
                    content = self.factory.parse_fulltext(data, version_idx)
835
 
                    for line in content.text():
 
832
            method = self._index.get_method(version_id)
 
833
            version_idx = self._index.lookup(version_id)
 
834
            assert method in ('fulltext', 'line-delta')
 
835
            if method == 'fulltext':
 
836
                content = self.factory.parse_fulltext(data, version_idx)
 
837
                for line in content.text():
 
838
                    yield line
 
839
            else:
 
840
                delta = self.factory.parse_line_delta(data, version_idx)
 
841
                for start, end, count, lines in delta:
 
842
                    for origin, line in lines:
836
843
                        yield line
837
 
                else:
838
 
                    delta = self.factory.parse_line_delta(data, version_idx)
839
 
                    for start, end, count, lines in delta:
840
 
                        for origin, line in lines:
841
 
                            yield line
842
 
                count +=1
843
 
            pb.update('Walking content.', total, total)
844
 
            pb.finished()
845
 
        except:
846
 
            pb.update('Walking content.', total, total)
847
 
            pb.finished()
848
 
            raise
 
844
            count +=1
 
845
        pb.update('Walking content.', total, total)
849
846
        
850
847
    def num_versions(self):
851
848
        """See VersionedFile.num_versions()."""