~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

Introduce a api specifically for looking at lines in some versions of the inventory, for fileid_involved.

Show diffs side-by-side

added added

removed removed

Lines of Context:
398
398
        if self.has_version(version_id):
399
399
            raise RevisionAlreadyPresent(version_id, self.filename)
400
400
 
401
 
        if True or __debug__:
 
401
        if False or __debug__:
402
402
            for l in lines:
403
403
                assert '\n' not in l[:-1]
404
404
 
466
466
        """See VersionedFile.get_lines()."""
467
467
        return self._get_content(version_id).text()
468
468
 
 
469
    def iter_lines_added_or_present_in_versions(self, version_ids=None):
 
470
        """See VersionedFile.iter_lines_added_or_present_in_versions()."""
 
471
        if version_ids is None:
 
472
            version_ids = self.versions()
 
473
        # we dont care about inclusions, the caller cares.
 
474
        # but we need to setup a list of records to visit.
 
475
        # we need version_id, position, length
 
476
        version_id_records = []
 
477
        for version_id in version_ids:
 
478
            if not self.has_version(version_id):
 
479
                raise RevisionNotPresent(version_id, self.filename)
 
480
            data_pos, length = self._index.get_position(version_id)
 
481
            version_id_records.append((version_id, data_pos, length))
 
482
        for version_id, data, sha_value in \
 
483
            self._data.read_records_iter(version_id_records):
 
484
            method = self._index.get_method(version_id)
 
485
            version_idx = self._index.lookup(version_id)
 
486
            assert method in ('fulltext', 'line-delta')
 
487
            if method == 'fulltext':
 
488
                content = self.factory.parse_fulltext(data, version_idx)
 
489
                for line in content.text():
 
490
                    yield line
 
491
            else:
 
492
                delta = self.factory.parse_line_delta(data, version_idx)
 
493
                for start, end, count, lines in delta:
 
494
                    for origin, line in lines:
 
495
                        yield line
 
496
        
469
497
    def num_versions(self):
470
498
        """See VersionedFile.num_versions()."""
471
499
        return self._index.num_versions()
525
553
 
526
554
        return self.factory.lower_fulltext(KnitContent(new_lines))
527
555
 
 
556
    #@deprecated_method(zero_eight)
528
557
    def walk(self, version_ids):
529
558
        """See VersionedFile.walk."""
530
559
        # We take the short path here, and extract all relevant texts