~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

  • Committer: Robert Collins
  • Date: 2007-11-09 17:50:31 UTC
  • mto: This revision was merged to the branch mainline in revision 2988.
  • Revision ID: robertc@robertcollins.net-20071109175031-agaiy6530rvbprmb
Change (without backwards compatibility) the
iter_lines_added_or_present_in_versions VersionedFile API to yield the
text version that each line is being returned from. This is useful for
reconcile in determining what inventories reference what texts.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
560
560
                     ['base\n', 'lancestor\n', 'otherchild\n'])
561
561
        def iter_with_versions(versions, expected):
562
562
            # now we need to see what lines are returned, and how often.
563
 
            lines = {'base\n':0,
564
 
                     'lancestor\n':0,
565
 
                     'rancestor\n':0,
566
 
                     'child\n':0,
567
 
                     'otherchild\n':0,
568
 
                     }
 
563
            lines = {}
569
564
            progress = InstrumentedProgress()
570
565
            # iterate over the lines
571
 
            for line in vf.iter_lines_added_or_present_in_versions(versions, 
 
566
            for line in vf.iter_lines_added_or_present_in_versions(versions,
572
567
                pb=progress):
 
568
                lines.setdefault(line, 0)
573
569
                lines[line] += 1
574
 
            if []!= progress.updates: 
 
570
            if []!= progress.updates:
575
571
                self.assertEqual(expected, progress.updates)
576
572
            return lines
577
573
        lines = iter_with_versions(['child', 'otherchild'],
579
575
                                    ('Walking content.', 1, 2),
580
576
                                    ('Walking content.', 2, 2)])
581
577
        # we must see child and otherchild
582
 
        self.assertTrue(lines['child\n'] > 0)
583
 
        self.assertTrue(lines['otherchild\n'] > 0)
 
578
        self.assertTrue(lines[('child\n', 'child')] > 0)
 
579
        self.assertTrue(lines[('otherchild\n', 'otherchild')] > 0)
584
580
        # we dont care if we got more than that.
585
581
        
586
582
        # test all lines
591
587
                                          ('Walking content.', 4, 5),
592
588
                                          ('Walking content.', 5, 5)])
593
589
        # all lines must be seen at least once
594
 
        self.assertTrue(lines['base\n'] > 0)
595
 
        self.assertTrue(lines['lancestor\n'] > 0)
596
 
        self.assertTrue(lines['rancestor\n'] > 0)
597
 
        self.assertTrue(lines['child\n'] > 0)
598
 
        self.assertTrue(lines['otherchild\n'] > 0)
 
590
        self.assertTrue(lines[('base\n', 'base')] > 0)
 
591
        self.assertTrue(lines[('lancestor\n', 'lancestor')] > 0)
 
592
        self.assertTrue(lines[('rancestor\n', 'rancestor')] > 0)
 
593
        self.assertTrue(lines[('child\n', 'child')] > 0)
 
594
        self.assertTrue(lines[('otherchild\n', 'otherchild')] > 0)
599
595
 
600
596
    def test_add_lines_with_ghosts(self):
601
597
        # some versioned file formats allow lines to be added with parent