/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/blackbox/test_versioning.py

[merge] (Goffredo) faster merge/fetch by peeking into weave

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import os
24
24
 
25
 
from bzrlib.selftest import BzrTestBase, TestCaseInTempDir
 
25
from bzrlib.tests import BzrTestBase, TestCaseInTempDir
26
26
from bzrlib.branch import Branch
27
27
from bzrlib.trace import mutter
 
28
from bzrlib.osutils import pathjoin
28
29
 
29
30
 
30
31
class TestVersioning(TestCaseInTempDir):
40
41
 
41
42
        from bzrlib.diff import compare_trees
42
43
        from bzrlib.branch import Branch
43
 
        b = Branch.open('.')
 
44
        b = Branch.open(u'.')
44
45
        
45
46
        delta = compare_trees(b.basis_tree(), b.working_tree())
46
47
 
65
66
 
66
67
        from bzrlib.diff import compare_trees
67
68
        from bzrlib.branch import Branch
68
 
        b = Branch.open('.')
 
69
        b = Branch.open(u'.')
69
70
        
70
71
        delta = compare_trees(b.basis_tree(), b.working_tree())
71
72
 
73
74
 
74
75
        self.assertEquals(len(delta.added), 2)
75
76
        self.assertEquals(delta.added[0][0], 'dir')
76
 
        self.assertEquals(delta.added[1][0], os.path.join('dir','subdir'))
 
77
        self.assertEquals(delta.added[1][0], pathjoin('dir','subdir'))
77
78
        self.failIf(delta.modified)
78
79
 
79
80
    def test_mkdir_w_nested_trees(self):
94
95
        self.failUnless(os.path.isdir('a/b/dir'))
95
96
 
96
97
        from bzrlib.diff import compare_trees
97
 
        b = Branch.open('.')
 
98
        b = Branch.open(u'.')
98
99
        b_a = Branch.open('a')
99
100
        b_b = Branch.open('a/b')
100
101
        
113
114
        self.assertEquals(delta.added[0][0], 'dir')
114
115
        self.failIf(delta.modified)
115
116
 
116
 
    def test_branch_add_in_unversioned(self):
 
117
    def test_working_tree_add_in_unversioned(self):
117
118
        """Try to add a file in an unversioned directory.
118
119
 
119
 
        "bzr add" adds the parent as necessary, but simple branch add
 
120
        "bzr add" adds the parent as necessary, but simple working tree add
120
121
        doesn't do that.
121
122
        """
122
123
        from bzrlib.branch import Branch
123
124
        from bzrlib.errors import NotVersionedError
 
125
        from bzrlib.workingtree import WorkingTree
124
126
 
125
 
        b = Branch.initialize('.')
 
127
        b = Branch.initialize(u'.')
126
128
 
127
129
        self.build_tree(['foo/',
128
130
                         'foo/hello'])
129
131
 
130
132
        self.assertRaises(NotVersionedError,
131
 
                          b.add,
 
133
                          WorkingTree(b.base, b).add,
132
134
                          'foo/hello')
133
135
        
134
136
        self.check_branch()
135
137
 
136
 
    def test_add_in_unversioned(self):
137
 
        """Try to add a file in an unversioned directory.
138
 
 
139
 
        "bzr add" should add the parent(s) as necessary.
140
 
        """
141
 
        from bzrlib.branch import Branch
142
 
        eq = self.assertEqual
143
 
 
144
 
        b = Branch.initialize('.')
145
 
 
146
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
147
 
        eq(list(b.unknowns()), ['inertiatic'])
148
 
        self.run_bzr('add', 'inertiatic/esp')
149
 
        eq(list(b.unknowns()), [])
150
 
 
151
 
        # Multiple unversioned parents
152
 
        self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
153
 
        eq(list(b.unknowns()), ['veil'])
154
 
        self.run_bzr('add', 'veil/cerpin/taxt')
155
 
        eq(list(b.unknowns()), [])
156
 
 
157
 
        # Check whacky paths work
158
 
        self.build_tree(['cicatriz/', 'cicatriz/esp'])
159
 
        eq(list(b.unknowns()), ['cicatriz'])
160
 
        self.run_bzr('add', 'inertiatic/../cicatriz/esp')
161
 
        eq(list(b.unknowns()), [])
162
 
 
163
 
    def test_add_in_versioned(self):
164
 
        """Try to add a file in a versioned directory.
165
 
 
166
 
        "bzr add" should do this happily.
167
 
        """
168
 
        from bzrlib.branch import Branch
169
 
        eq = self.assertEqual
170
 
 
171
 
        b = Branch.initialize('.')
172
 
 
173
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
174
 
        eq(list(b.unknowns()), ['inertiatic'])
175
 
        self.run_bzr('add', '--no-recurse', 'inertiatic')
176
 
        eq(list(b.unknowns()), ['inertiatic'+os.sep+'esp'])
177
 
        self.run_bzr('add', 'inertiatic/esp')
178
 
        eq(list(b.unknowns()), [])
179
 
 
180
 
    def test_subdir_add(self):
181
 
        """Add in subdirectory should add only things from there down"""
182
 
        
183
 
        from bzrlib.branch import Branch
184
 
        
185
 
        eq = self.assertEqual
186
 
        ass = self.assert_
187
 
        chdir = os.chdir
188
 
        
189
 
        b = Branch.initialize('.')
190
 
        t = b.working_tree()
191
 
        self.build_tree(['src/', 'README'])
192
 
        
193
 
        eq(sorted(b.unknowns()),
194
 
           ['README', 'src'])
195
 
        
196
 
        self.run_bzr('add', 'src')
197
 
        
198
 
        self.build_tree(['src/foo.c'])
199
 
        
200
 
        chdir('src')
201
 
        self.run_bzr('add')
202
 
        
203
 
        eq(sorted(b.unknowns()), 
204
 
           ['README'])
205
 
        eq(len(t.read_working_inventory()), 3)
206
 
                
207
 
        chdir('..')
208
 
        self.run_bzr('add')
209
 
        eq(list(b.unknowns()), [])
210
 
 
211
 
        self.check_branch()
212
 
 
213
138
    def check_branch(self):
214
139
        """After all the above changes, run the check and upgrade commands.
215
140
 
216
141
        The upgrade should be a no-op."""
217
 
        b = Branch.open('.')
 
142
        b = Branch.open(u'.')
218
143
        mutter('branch has %d revisions', b.revno())
219
144
        
220
145
        mutter('check branch...')
232
157
        self.build_tree(['a/', 'b/'])
233
158
        
234
159
        run_bzr('init')
235
 
        b = Branch.open('.')
 
160
        b = Branch.open(u'.')
236
161
        
237
162
        for fn in ('a/one', 'b/two', 'top'):
238
163
            file(fn, 'w').write('old contents')