/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/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-28 18:13:00 UTC
  • mto: (2255.11.3 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: john@arbash-meinel.com-20070228181300-3hpf53zdxpz16bjg
Add a _walkdirs_utf8 which returns utf8 paths instead of Unicode. Approx 20% faster in walking utf8 filesystems

Show diffs side-by-side

added added

removed removed

Lines of Context:
559
559
        self.assertEqual(expected_dirblocks[1:],
560
560
            [(dirinfo, [line[0:3] for line in block]) for dirinfo, block in result])
561
561
 
 
562
    def test__walkdirs_utf8(self):
 
563
        tree = [
 
564
            '.bzr',
 
565
            '0file',
 
566
            '1dir/',
 
567
            '1dir/0file',
 
568
            '1dir/1dir/',
 
569
            '2file'
 
570
            ]
 
571
        self.build_tree(tree)
 
572
        expected_dirblocks = [
 
573
                (('', '.'),
 
574
                 [('0file', '0file', 'file'),
 
575
                  ('1dir', '1dir', 'directory'),
 
576
                  ('2file', '2file', 'file'),
 
577
                 ]
 
578
                ),
 
579
                (('1dir', './1dir'),
 
580
                 [('1dir/0file', '0file', 'file'),
 
581
                  ('1dir/1dir', '1dir', 'directory'),
 
582
                 ]
 
583
                ),
 
584
                (('1dir/1dir', './1dir/1dir'),
 
585
                 [
 
586
                 ]
 
587
                ),
 
588
            ]
 
589
        result = []
 
590
        found_bzrdir = False
 
591
        for dirdetail, dirblock in osutils._walkdirs_utf8('.'):
 
592
            if len(dirblock) and dirblock[0][1] == '.bzr':
 
593
                # this tests the filtering of selected paths
 
594
                found_bzrdir = True
 
595
                del dirblock[0]
 
596
            result.append((dirdetail, dirblock))
 
597
 
 
598
        self.assertTrue(found_bzrdir)
 
599
        self.assertEqual(expected_dirblocks,
 
600
            [(dirinfo, [line[0:3] for line in block]) for dirinfo, block in result])
 
601
        # you can search a subdir only, with a supplied prefix.
 
602
        result = []
 
603
        for dirblock in osutils.walkdirs('./1dir', '1dir'):
 
604
            result.append(dirblock)
 
605
        self.assertEqual(expected_dirblocks[1:],
 
606
            [(dirinfo, [line[0:3] for line in block]) for dirinfo, block in result])
 
607
 
562
608
    def assertPathCompare(self, path_less, path_greater):
563
609
        """check that path_less and path_greater compare correctly."""
564
610
        self.assertEqual(0, osutils.compare_paths_prefix_order(