/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/workingtree_implementations/test_workingtree.py

Merge bzr.dev, fix minor conflict in cmd_revision_history().

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from bzrlib.tests import TestSkipped
31
31
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
32
32
from bzrlib.trace import mutter
 
33
import bzrlib.urlutils as urlutils
33
34
import bzrlib.workingtree as workingtree
34
35
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
35
36
                                WorkingTree)
37
38
 
38
39
class TestWorkingTree(TestCaseWithWorkingTree):
39
40
 
40
 
    def test_listfiles(self):
 
41
    def test_list_files(self):
41
42
        tree = self.make_branch_and_tree('.')
42
 
        os.mkdir('dir')
43
 
        print >> open('file', 'w'), "content"
 
43
        self.build_tree(['dir/', 'file'])
44
44
        if has_symlinks():
45
45
            os.symlink('target', 'symlink')
46
46
        files = list(tree.list_files())
49
49
        if has_symlinks():
50
50
            self.assertEqual(files[2], ('symlink', '?', 'symlink', None, TreeLink()))
51
51
 
 
52
    def test_list_files_sorted(self):
 
53
        tree = self.make_branch_and_tree('.')
 
54
        self.build_tree(['dir/', 'file', 'dir/file', 'dir/b', 'dir/subdir/', 'a', 'dir/subfile',
 
55
                'zz_dir/', 'zz_dir/subfile'])
 
56
        files = [(path, kind) for (path, versioned, kind, file_id, entry) in tree.list_files()]
 
57
        self.assertEqual([
 
58
            ('a', 'file'),
 
59
            ('dir', 'directory'),
 
60
            ('file', 'file'),
 
61
            ('zz_dir', 'directory'),
 
62
            ], files)
 
63
 
 
64
        tree.add(['dir', 'zz_dir'])
 
65
        files = [(path, kind) for (path, versioned, kind, file_id, entry) in tree.list_files()]
 
66
        self.assertEqual([
 
67
            ('a', 'file'),
 
68
            ('dir', 'directory'),
 
69
            ('dir/b', 'file'),
 
70
            ('dir/file', 'file'),
 
71
            ('dir/subdir', 'directory'),
 
72
            ('dir/subfile', 'file'),
 
73
            ('file', 'file'),
 
74
            ('zz_dir', 'directory'),
 
75
            ('zz_dir/subfile', 'file'),
 
76
            ], files)
 
77
 
52
78
    def test_open_containing(self):
53
79
        branch = self.make_branch_and_tree('.').branch
54
80
        wt, relpath = WorkingTree.open_containing()
55
81
        self.assertEqual('', relpath)
56
 
        self.assertEqual(wt.basedir + '/', branch.base)
 
82
        self.assertEqual(wt.basedir + '/', urlutils.local_path_from_url(branch.base))
57
83
        wt, relpath = WorkingTree.open_containing(u'.')
58
84
        self.assertEqual('', relpath)
59
 
        self.assertEqual(wt.basedir + '/', branch.base)
 
85
        self.assertEqual(wt.basedir + '/', urlutils.local_path_from_url(branch.base))
60
86
        wt, relpath = WorkingTree.open_containing('./foo')
61
87
        self.assertEqual('foo', relpath)
62
 
        self.assertEqual(wt.basedir + '/', branch.base)
 
88
        self.assertEqual(wt.basedir + '/', urlutils.local_path_from_url(branch.base))
63
89
        wt, relpath = WorkingTree.open_containing('file://' + getcwd() + '/foo')
64
90
        self.assertEqual('foo', relpath)
65
 
        self.assertEqual(wt.basedir + '/', branch.base)
 
91
        self.assertEqual(wt.basedir + '/', urlutils.local_path_from_url(branch.base))
66
92
 
67
93
    def test_basic_relpath(self):
68
94
        # for comprehensive relpath tests, see whitebox.py.