~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Robert Collins
  • Date: 2005-11-28 05:13:41 UTC
  • mfrom: (1185.33.54 merge-recovered)
  • Revision ID: robertc@robertcollins.net-20051128051341-059936f2f29a12c8
Merge from Martin. Adjust check to work with HTTP again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
import os
19
19
from bzrlib.branch import Branch
20
 
from bzrlib.errors import NotVersionedError
21
 
from bzrlib.selftest import TestCaseInTempDir
 
20
from bzrlib.errors import NotBranchError, NotVersionedError
 
21
from bzrlib.tests import TestCaseInTempDir
22
22
from bzrlib.trace import mutter
23
23
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
24
24
                                WorkingTree)
60
60
        self.assertEqual(files[1], ('file', '?', 'file', None, TreeFile()))
61
61
        self.assertEqual(files[2], ('symlink', '?', 'symlink', None, TreeLink()))
62
62
 
 
63
    def test_open_containing(self):
 
64
        branch = Branch.initialize('.')
 
65
        wt, relpath = WorkingTree.open_containing()
 
66
        self.assertEqual('', relpath)
 
67
        self.assertEqual(wt.basedir, branch.base)
 
68
        wt, relpath = WorkingTree.open_containing('.')
 
69
        self.assertEqual('', relpath)
 
70
        self.assertEqual(wt.basedir, branch.base)
 
71
        wt, relpath = WorkingTree.open_containing('./foo')
 
72
        self.assertEqual('foo', relpath)
 
73
        self.assertEqual(wt.basedir, branch.base)
 
74
        # paths that are urls are just plain wrong for working trees.
 
75
        self.assertRaises(NotBranchError,
 
76
                          WorkingTree.open_containing, 
 
77
                          'file:///' + os.getcwdu())
 
78
 
63
79
    def test_construct_with_branch(self):
64
80
        branch = Branch.initialize('.')
65
81
        tree = WorkingTree(branch.base, branch)
96
112
    def get_pullable_branches(self):
97
113
        self.build_tree(['from/', 'from/file', 'to/'])
98
114
        br_a = Branch.initialize('from')
99
 
        br_a.add('file')
100
 
        br_a.working_tree().commit('foo', rev_id='A')
 
115
        tree = br_a.working_tree()
 
116
        tree.add('file')
 
117
        tree.commit('foo', rev_id='A')
101
118
        br_b = Branch.initialize('to')
102
119
        return br_a, br_b
103
120
 
125
142
 
126
143
        self.assertRaises(NotVersionedError,
127
144
                          b.working_tree().revert, ['hello.txt'])
128
 
        
129
 
        b.add(['hello.txt'])
130
 
        b.working_tree().commit('create initial hello.txt')
 
145
        tree = WorkingTree(b.base, b)
 
146
        tree.add(['hello.txt'])
 
147
        tree.commit('create initial hello.txt')
131
148
 
132
149
        self.check_file_contents('hello.txt', 'initial hello')
133
150
        file('hello.txt', 'w').write('new hello')
134
151
        self.check_file_contents('hello.txt', 'new hello')
135
152
 
136
 
        wt = b.working_tree()
137
 
 
138
153
        # revert file modified since last revision
139
 
        wt.revert(['hello.txt'])
 
154
        tree.revert(['hello.txt'])
140
155
        self.check_file_contents('hello.txt', 'initial hello')
141
156
        self.check_file_contents('hello.txt~', 'new hello')
142
157
 
143
158
        # reverting again does not clobber the backup
144
 
        wt.revert(['hello.txt'])
 
159
        tree.revert(['hello.txt'])
145
160
        self.check_file_contents('hello.txt', 'initial hello')
146
161
        self.check_file_contents('hello.txt~', 'new hello')
 
162
 
 
163
    def test_unknowns(self):
 
164
        b = Branch.initialize('.')
 
165
        tree = WorkingTree('.', b)
 
166
        self.build_tree(['hello.txt',
 
167
                         'hello.txt~'])
 
168
        self.assertEquals(list(tree.unknowns()),
 
169
                          ['hello.txt'])
 
170