~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Aaron Bentley
  • Date: 2006-06-25 01:38:56 UTC
  • mto: This revision was merged to the branch mainline in revision 1811.
  • Revision ID: aaron.bentley@utoronto.ca-20060625013856-1b97ee9125d90988
Documentation and cleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
515
515
        return diff_hunks
516
516
 
517
517
    def _get_components_positions(self, version_ids):
 
518
        """Produce a map of position data for the components of versions.
 
519
 
 
520
        This data is indended to be used for retrieving the knit records.
 
521
 
 
522
        A dict of version_id to (method, data_pos, data_size, next) is
 
523
        returned.
 
524
        method is the way referenced data should be applied.
 
525
        data_pos is the position of the data in the knit.
 
526
        data_size is the size of the data in the knit.
 
527
        next is the build-parent of the version, or None for fulltexts.
 
528
        """
518
529
        component_data = {}
519
530
        for version_id in version_ids:
520
 
            basis = self.basis_knit
521
 
            basis_versions = []
522
531
            cursor = version_id
523
532
 
524
533
            while cursor is not None and cursor not in component_data:
666
675
        return self.get_line_list([version_id])[0]
667
676
 
668
677
    def _get_record_map(self, version_ids):
 
678
        """Produce a dictionary of knit records.
 
679
        
 
680
        The keys are version_ids, the values are tuples of (method, content,
 
681
        digest, next).
 
682
        method is the way the content should be applied.  
 
683
        content is a KnitContent object.
 
684
        digest is the SHA1 digest of this version id after all steps are done
 
685
        next is the build-parent of the version, i.e. the leftmost ancestor.
 
686
        If the method is fulltext, next will be None.
 
687
        """
669
688
        position_map = self._get_components_positions(version_ids)
670
689
        records = [(c, p, s) for c, (m, p, s, n) in position_map.iteritems()]
671
690
        record_map = {}
689
708
        return [text_map[v] for v in version_ids]
690
709
 
691
710
    def _get_content_maps(self, version_ids):
 
711
        """Produce maps of text and KnitContents
 
712
        
 
713
        :return: (text_map, content_map) where text_map contains the texts for
 
714
        the requested versions and content_map contains the KnitContents.
 
715
        Both dicts are take version_ids as their keys.
 
716
        """
692
717
        for version_id in version_ids:
693
718
            if not self.has_version(version_id):
694
719
                raise RevisionNotPresent(version_id, self.filename)
1386
1411
        for version_id, pos, size in records:
1387
1412
            if version_id not in self._records:
1388
1413
                needed_records.add((version_id, pos, size))
 
1414
 
 
1415
        # turn our set into a list, sorted by file position
1389
1416
        needed_records = sorted(needed_records, key=operator.itemgetter(1))
1390
1417
 
1391
1418
        if len(needed_records):