/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2249.5.7 by John Arbash Meinel
Make sure WorkingTree revision_ids are also returned as utf8 strings
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
from cStringIO import StringIO
19
import os
1711.7.19 by John Arbash Meinel
file:// urls look slightly different on win32
20
import sys
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
21
22
import bzrlib
1830.3.7 by John Arbash Meinel
Check that WorkingTree.add does the right thing.
23
from bzrlib import branch, bzrdir, errors, osutils, urlutils, workingtree
1836.1.18 by John Arbash Meinel
Cleaned up the last failing tests. All tests pass again.
24
from bzrlib.errors import (NotBranchError, NotVersionedError,
1551.7.17 by Aaron Bentley
Switch to PathsNotVersioned, accept extra_trees
25
                           UnsupportedOperation, PathsNotVersionedError)
1685.1.45 by John Arbash Meinel
Moved url functions into bzrlib.urlutils
26
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
1534.5.5 by Robert Collins
Move is_control_file into WorkingTree.is_control_filename and test.
27
from bzrlib.tests import TestSkipped
28
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
29
from bzrlib.trace import mutter
30
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
31
                                WorkingTree)
1551.7.11 by Aaron Bentley
Add WorkingTree.add_conflicts
32
from bzrlib.conflicts import ConflictList, TextConflict, ContentsConflict
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
33
1711.7.19 by John Arbash Meinel
file:// urls look slightly different on win32
34
1711.8.2 by John Arbash Meinel
Test that WorkingTree locks Branch before self, and unlocks self before Branch
35
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
36
class TestWorkingTree(TestCaseWithWorkingTree):
37
1732.1.8 by John Arbash Meinel
Adding a test for list_files
38
    def test_list_files(self):
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
39
        tree = self.make_branch_and_tree('.')
1732.1.8 by John Arbash Meinel
Adding a test for list_files
40
        self.build_tree(['dir/', 'file'])
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
41
        if has_symlinks():
42
            os.symlink('target', 'symlink')
43
        files = list(tree.list_files())
44
        self.assertEqual(files[0], ('dir', '?', 'directory', None, TreeDirectory()))
45
        self.assertEqual(files[1], ('file', '?', 'file', None, TreeFile()))
46
        if has_symlinks():
47
            self.assertEqual(files[2], ('symlink', '?', 'symlink', None, TreeLink()))
48
1732.1.8 by John Arbash Meinel
Adding a test for list_files
49
    def test_list_files_sorted(self):
50
        tree = self.make_branch_and_tree('.')
1836.1.18 by John Arbash Meinel
Cleaned up the last failing tests. All tests pass again.
51
        self.build_tree(['dir/', 'file', 'dir/file', 'dir/b',
52
                         'dir/subdir/', 'a', 'dir/subfile',
53
                         'zz_dir/', 'zz_dir/subfile'])
54
        files = [(path, kind) for (path, v, kind, file_id, entry)
55
                               in tree.list_files()]
1732.1.8 by John Arbash Meinel
Adding a test for list_files
56
        self.assertEqual([
57
            ('a', 'file'),
58
            ('dir', 'directory'),
59
            ('file', 'file'),
1732.1.25 by John Arbash Meinel
Fix list_files test, we don't need to check if children are empty if we fall off the loop.
60
            ('zz_dir', 'directory'),
1732.1.8 by John Arbash Meinel
Adding a test for list_files
61
            ], files)
62
1732.1.25 by John Arbash Meinel
Fix list_files test, we don't need to check if children are empty if we fall off the loop.
63
        tree.add(['dir', 'zz_dir'])
1836.1.18 by John Arbash Meinel
Cleaned up the last failing tests. All tests pass again.
64
        files = [(path, kind) for (path, v, kind, file_id, entry)
65
                               in tree.list_files()]
1732.1.8 by John Arbash Meinel
Adding a test for 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'),
1732.1.22 by John Arbash Meinel
Bug in list_files if the last entry in a directory is another directory
74
            ('zz_dir', 'directory'),
75
            ('zz_dir/subfile', 'file'),
1732.1.8 by John Arbash Meinel
Adding a test for list_files
76
            ], files)
77
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
78
    def test_open_containing(self):
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
79
        branch = self.make_branch_and_tree('.').branch
1711.7.28 by John Arbash Meinel
clean up the WorkingTree.open_containing tests
80
        local_base = urlutils.local_path_from_url(branch.base)
81
82
        # Empty opens '.'
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
83
        wt, relpath = WorkingTree.open_containing()
84
        self.assertEqual('', relpath)
1711.7.28 by John Arbash Meinel
clean up the WorkingTree.open_containing tests
85
        self.assertEqual(wt.basedir + '/', local_base)
86
87
        # '.' opens this dir
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
88
        wt, relpath = WorkingTree.open_containing(u'.')
89
        self.assertEqual('', relpath)
1711.7.28 by John Arbash Meinel
clean up the WorkingTree.open_containing tests
90
        self.assertEqual(wt.basedir + '/', local_base)
91
92
        # './foo' finds '.' and a relpath of 'foo'
93
        wt, relpath = WorkingTree.open_containing('./foo')
94
        self.assertEqual('foo', relpath)
95
        self.assertEqual(wt.basedir + '/', local_base)
96
97
        # abspath(foo) finds '.' and relpath of 'foo'
98
        wt, relpath = WorkingTree.open_containing('./foo')
99
        wt, relpath = WorkingTree.open_containing(getcwd() + '/foo')
100
        self.assertEqual('foo', relpath)
101
        self.assertEqual(wt.basedir + '/', local_base)
102
103
        # can even be a url: finds '.' and relpath of 'foo'
104
        wt, relpath = WorkingTree.open_containing('./foo')
105
        wt, relpath = WorkingTree.open_containing(
106
                    urlutils.local_path_to_url(getcwd() + '/foo'))
107
        self.assertEqual('foo', relpath)
108
        self.assertEqual(wt.basedir + '/', local_base)
109
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
110
111
    def test_basic_relpath(self):
112
        # for comprehensive relpath tests, see whitebox.py.
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
113
        tree = self.make_branch_and_tree('.')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
114
        self.assertEqual('child',
115
                         tree.relpath(pathjoin(getcwd(), 'child')))
116
117
    def test_lock_locks_branch(self):
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
118
        tree = self.make_branch_and_tree('.')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
119
        tree.lock_read()
120
        self.assertEqual('r', tree.branch.peek_lock_mode())
121
        tree.unlock()
122
        self.assertEqual(None, tree.branch.peek_lock_mode())
123
        tree.lock_write()
124
        self.assertEqual('w', tree.branch.peek_lock_mode())
125
        tree.unlock()
126
        self.assertEqual(None, tree.branch.peek_lock_mode())
127
 
128
    def test_revert(self):
129
        """Test selected-file revert"""
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
130
        tree = self.make_branch_and_tree('.')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
131
132
        self.build_tree(['hello.txt'])
133
        file('hello.txt', 'w').write('initial hello')
134
1551.7.17 by Aaron Bentley
Switch to PathsNotVersioned, accept extra_trees
135
        self.assertRaises(PathsNotVersionedError,
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
136
                          tree.revert, ['hello.txt'])
137
        tree.add(['hello.txt'])
138
        tree.commit('create initial hello.txt')
139
140
        self.check_file_contents('hello.txt', 'initial hello')
141
        file('hello.txt', 'w').write('new hello')
142
        self.check_file_contents('hello.txt', 'new hello')
143
144
        # revert file modified since last revision
145
        tree.revert(['hello.txt'])
146
        self.check_file_contents('hello.txt', 'initial hello')
1534.10.29 by Aaron Bentley
Fixed backup numbering to match GNU standard better
147
        self.check_file_contents('hello.txt.~1~', 'new hello')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
148
149
        # reverting again does not clobber the backup
150
        tree.revert(['hello.txt'])
151
        self.check_file_contents('hello.txt', 'initial hello')
1534.10.29 by Aaron Bentley
Fixed backup numbering to match GNU standard better
152
        self.check_file_contents('hello.txt.~1~', 'new hello')
1534.10.28 by Aaron Bentley
Use numbered backup files
153
        
154
        # backup files are numbered
155
        file('hello.txt', 'w').write('new hello2')
156
        tree.revert(['hello.txt'])
157
        self.check_file_contents('hello.txt', 'initial hello')
1534.10.29 by Aaron Bentley
Fixed backup numbering to match GNU standard better
158
        self.check_file_contents('hello.txt.~1~', 'new hello')
159
        self.check_file_contents('hello.txt.~2~', 'new hello2')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
160
1558.12.7 by Aaron Bentley
Fixed revert with missing files
161
    def test_revert_missing(self):
162
        # Revert a file that has been deleted since last commit
163
        tree = self.make_branch_and_tree('.')
164
        file('hello.txt', 'w').write('initial hello')
165
        tree.add('hello.txt')
166
        tree.commit('added hello.txt')
167
        os.unlink('hello.txt')
168
        tree.remove('hello.txt')
169
        tree.revert(['hello.txt'])
170
        self.failUnlessExists('hello.txt')
171
1740.6.1 by Martin Pool
Remove Scratch objects used by doctests
172
    def test_versioned_files_not_unknown(self):
173
        tree = self.make_branch_and_tree('.')
1831.1.1 by Martin Pool
[merge] remove default ignore list & update
174
        self.build_tree(['hello.txt'])
1740.6.1 by Martin Pool
Remove Scratch objects used by doctests
175
        tree.add('hello.txt')
176
        self.assertEquals(list(tree.unknowns()),
177
                          [])
1831.1.1 by Martin Pool
[merge] remove default ignore list & update
178
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
179
    def test_unknowns(self):
180
        tree = self.make_branch_and_tree('.')
181
        self.build_tree(['hello.txt',
1534.10.29 by Aaron Bentley
Fixed backup numbering to match GNU standard better
182
                         'hello.txt.~1~'])
1765.1.1 by Robert Collins
Remove the default ignores list from bzr, lowering the minimum overhead in bzr add.
183
        self.build_tree_contents([('.bzrignore', '*.~*\n')])
184
        tree.add('.bzrignore')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
185
        self.assertEquals(list(tree.unknowns()),
186
                          ['hello.txt'])
187
188
    def test_initialize(self):
189
        # initialize should create a working tree and branch in an existing dir
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
190
        t = self.make_branch_and_tree('.')
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
191
        b = branch.Branch.open('.')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
192
        self.assertEqual(t.branch.base, b.base)
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
193
        t2 = WorkingTree.open('.')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
194
        self.assertEqual(t.basedir, t2.basedir)
195
        self.assertEqual(b.base, t2.branch.base)
196
        # TODO maybe we should check the branch format? not sure if its
197
        # appropriate here.
198
199
    def test_rename_dirs(self):
200
        """Test renaming directories and the files within them."""
201
        wt = self.make_branch_and_tree('.')
202
        b = wt.branch
203
        self.build_tree(['dir/', 'dir/sub/', 'dir/sub/file'])
204
        wt.add(['dir', 'dir/sub', 'dir/sub/file'])
205
206
        wt.commit('create initial state')
207
208
        revid = b.revision_history()[0]
209
        self.log('first revision_id is {%s}' % revid)
210
        
211
        inv = b.repository.get_revision_inventory(revid)
212
        self.log('contents of inventory: %r' % inv.entries())
213
214
        self.check_inventory_shape(inv,
215
                                   ['dir', 'dir/sub', 'dir/sub/file'])
216
217
        wt.rename_one('dir', 'newdir')
218
219
        self.check_inventory_shape(wt.read_working_inventory(),
220
                                   ['newdir', 'newdir/sub', 'newdir/sub/file'])
221
222
        wt.rename_one('newdir/sub', 'newdir/newsub')
223
        self.check_inventory_shape(wt.read_working_inventory(),
224
                                   ['newdir', 'newdir/newsub',
225
                                    'newdir/newsub/file'])
226
227
    def test_add_in_unversioned(self):
228
        """Try to add a file in an unversioned directory.
229
230
        "bzr add" adds the parent as necessary, but simple working tree add
231
        doesn't do that.
232
        """
233
        from bzrlib.errors import NotVersionedError
234
        wt = self.make_branch_and_tree('.')
235
        self.build_tree(['foo/',
236
                         'foo/hello'])
237
        self.assertRaises(NotVersionedError,
238
                          wt.add,
239
                          'foo/hello')
240
241
    def test_add_missing(self):
242
        # adding a msising file -> NoSuchFile
243
        wt = self.make_branch_and_tree('.')
244
        self.assertRaises(errors.NoSuchFile, wt.add, 'fpp')
245
246
    def test_remove_verbose(self):
247
        #FIXME the remove api should not print or otherwise depend on the
248
        # text UI - RBC 20060124
249
        wt = self.make_branch_and_tree('.')
250
        self.build_tree(['hello'])
251
        wt.add(['hello'])
252
        wt.commit(message='add hello')
253
        stdout = StringIO()
254
        stderr = StringIO()
255
        self.assertEqual(None, self.apply_redirected(None, stdout, stderr,
256
                                                     wt.remove,
257
                                                     ['hello'],
258
                                                     verbose=True))
259
        self.assertEqual('?       hello\n', stdout.getvalue())
260
        self.assertEqual('', stderr.getvalue())
261
262
    def test_clone_trivial(self):
263
        wt = self.make_branch_and_tree('source')
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
264
        cloned_dir = wt.bzrdir.clone('target')
265
        cloned = cloned_dir.open_workingtree()
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
266
        self.assertEqual(cloned.get_parent_ids(), wt.get_parent_ids())
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
267
268
    def test_last_revision(self):
269
        wt = self.make_branch_and_tree('source')
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
270
        self.assertEqual([], wt.get_parent_ids())
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
271
        wt.commit('A', allow_pointless=True, rev_id='A')
2249.5.7 by John Arbash Meinel
Make sure WorkingTree revision_ids are also returned as utf8 strings
272
        parent_ids = wt.get_parent_ids()
273
        self.assertEqual(['A'], parent_ids)
274
        for parent_id in parent_ids:
275
            self.assertIsInstance(parent_id, str)
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
276
277
    def test_set_last_revision(self):
278
        wt = self.make_branch_and_tree('source')
1908.1.1 by Robert Collins
Relax WorkingTree.set_last-revision to allow any revision to be set.
279
        # set last-revision to one not in the history
280
        wt.set_last_revision('A')
281
        # set it back to None for an empty tree.
282
        wt.set_last_revision(None)
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
283
        wt.commit('A', allow_pointless=True, rev_id='A')
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
284
        self.assertEqual(['A'], wt.get_parent_ids())
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
285
        # None is aways in the branch
286
        wt.set_last_revision(None)
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
287
        self.assertEqual([], wt.get_parent_ids())
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
288
        # and now we can set it to 'A'
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
289
        # because some formats mutate the branch to set it on the tree
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
290
        # we need to alter the branch to let this pass.
2230.3.27 by Aaron Bentley
Skip arbitrary revision-history test for Branch6
291
        try:
292
            wt.branch.set_revision_history(['A', 'B'])
293
        except errors.NoSuchRevision, e:
294
            self.assertEqual('B', e.revision)
295
            raise TestSkipped("Branch format does not permit arbitrary"
296
                              " history")
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
297
        wt.set_last_revision('A')
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
298
        self.assertEqual(['A'], wt.get_parent_ids())
2229.2.1 by Aaron Bentley
Reject reserved ids in versiondfile, tree, branch and repository
299
        self.assertRaises(errors.ReservedId, wt.set_last_revision, 'A:')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
300
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
301
    def test_set_last_revision_different_to_branch(self):
302
        # working tree formats from the meta-dir format and newer support
303
        # setting the last revision on a tree independently of that on the 
304
        # branch. Its concievable that some future formats may want to 
305
        # couple them again (i.e. because its really a smart server and
306
        # the working tree will always match the branch). So we test
307
        # that formats where initialising a branch does not initialise a 
308
        # tree - and thus have separable entities - support skewing the 
309
        # two things.
310
        branch = self.make_branch('tree')
311
        try:
312
            # if there is a working tree now, this is not supported.
313
            branch.bzrdir.open_workingtree()
314
            return
315
        except errors.NoWorkingTree:
316
            pass
317
        wt = branch.bzrdir.create_workingtree()
318
        wt.commit('A', allow_pointless=True, rev_id='A')
319
        wt.set_last_revision(None)
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
320
        self.assertEqual([], wt.get_parent_ids())
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
321
        self.assertEqual('A', wt.branch.last_revision())
322
        # and now we can set it back to 'A'
323
        wt.set_last_revision('A')
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
324
        self.assertEqual(['A'], wt.get_parent_ids())
1508.1.19 by Robert Collins
Give format3 working trees their own last-revision marker.
325
        self.assertEqual('A', wt.branch.last_revision())
326
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
327
    def test_clone_and_commit_preserves_last_revision(self):
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
328
        """Doing a commit into a clone tree does not affect the source."""
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
329
        wt = self.make_branch_and_tree('source')
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
330
        cloned_dir = wt.bzrdir.clone('target')
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
331
        wt.commit('A', allow_pointless=True, rev_id='A')
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
332
        self.assertNotEqual(cloned_dir.open_workingtree().get_parent_ids(),
333
                            wt.get_parent_ids())
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
334
335
    def test_clone_preserves_content(self):
336
        wt = self.make_branch_and_tree('source')
337
        self.build_tree(['added', 'deleted', 'notadded'], transport=wt.bzrdir.transport.clone('..'))
338
        wt.add('deleted', 'deleted')
339
        wt.commit('add deleted')
340
        wt.remove('deleted')
341
        wt.add('added', 'added')
342
        cloned_dir = wt.bzrdir.clone('target')
343
        cloned = cloned_dir.open_workingtree()
344
        cloned_transport = cloned.bzrdir.transport.clone('..')
345
        self.assertFalse(cloned_transport.has('deleted'))
346
        self.assertTrue(cloned_transport.has('added'))
347
        self.assertFalse(cloned_transport.has('notadded'))
348
        self.assertEqual('added', cloned.path2id('added'))
349
        self.assertEqual(None, cloned.path2id('deleted'))
350
        self.assertEqual(None, cloned.path2id('notadded'))
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
351
        
352
    def test_basis_tree_returns_last_revision(self):
353
        wt = self.make_branch_and_tree('.')
354
        self.build_tree(['foo'])
355
        wt.add('foo', 'foo-id')
356
        wt.commit('A', rev_id='A')
357
        wt.rename_one('foo', 'bar')
358
        wt.commit('B', rev_id='B')
1908.6.3 by Robert Collins
Tidy up the last_revision_id and add_pending_merge conversion to use cleaner apis.
359
        wt.set_parent_ids(['B'])
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
360
        tree = wt.basis_tree()
361
        self.failUnless(tree.has_filename('bar'))
1908.6.3 by Robert Collins
Tidy up the last_revision_id and add_pending_merge conversion to use cleaner apis.
362
        wt.set_parent_ids(['A'])
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
363
        tree = wt.basis_tree()
364
        self.failUnless(tree.has_filename('foo'))
365
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
366
    def test_clone_tree_revision(self):
367
        # make a tree with a last-revision,
368
        # and clone it with a different last-revision, this should switch
369
        # do it.
370
        #
371
        # also test that the content is merged
372
        # and conflicts recorded.
373
        # This should merge between the trees - local edits should be preserved
374
        # but other changes occured.
375
        # we test this by having one file that does
376
        # not change between two revisions, and another that does -
377
        # if the changed one is not changed, fail,
378
        # if the one that did not change has lost a local change, fail.
379
        # 
380
        raise TestSkipped('revision limiting is not implemented yet.')
1508.1.21 by Robert Collins
Implement -r limit for checkout command.
381
382
    def test_initialize_with_revision_id(self):
383
        # a bzrdir can construct a working tree for itself @ a specific revision.
384
        source = self.make_branch_and_tree('source')
385
        source.commit('a', rev_id='a', allow_pointless=True)
386
        source.commit('b', rev_id='b', allow_pointless=True)
387
        self.build_tree(['new/'])
388
        made_control = self.bzrdir_format.initialize('new')
389
        source.branch.repository.clone(made_control)
390
        source.branch.clone(made_control)
391
        made_tree = self.workingtree_format.initialize(made_control, revision_id='a')
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
392
        self.assertEqual(['a'], made_tree.get_parent_ids())
1508.1.23 by Robert Collins
Test that the working tree last revision is indeed set during commit.
393
1508.1.24 by Robert Collins
Add update command for use with checkouts.
394
    def test_update_sets_last_revision(self):
395
        # working tree formats from the meta-dir format and newer support
396
        # setting the last revision on a tree independently of that on the 
397
        # branch. Its concievable that some future formats may want to 
398
        # couple them again (i.e. because its really a smart server and
399
        # the working tree will always match the branch). So we test
400
        # that formats where initialising a branch does not initialise a 
401
        # tree - and thus have separable entities - support skewing the 
402
        # two things.
403
        main_branch = self.make_branch('tree')
404
        try:
405
            # if there is a working tree now, this is not supported.
406
            main_branch.bzrdir.open_workingtree()
407
            return
408
        except errors.NoWorkingTree:
409
            pass
410
        wt = main_branch.bzrdir.create_workingtree()
411
        # create an out of date working tree by making a checkout in this
412
        # current format
413
        self.build_tree(['checkout/', 'tree/file'])
414
        checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
415
        branch.BranchReferenceFormat().initialize(checkout, main_branch)
1508.1.24 by Robert Collins
Add update command for use with checkouts.
416
        old_tree = self.workingtree_format.initialize(checkout)
417
        # now commit to 'tree'
418
        wt.add('file')
419
        wt.commit('A', rev_id='A')
420
        # and update old_tree
421
        self.assertEqual(0, old_tree.update())
422
        self.failUnlessExists('checkout/file')
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
423
        self.assertEqual(['A'], old_tree.get_parent_ids())
1508.1.24 by Robert Collins
Add update command for use with checkouts.
424
1731.1.33 by Aaron Bentley
Revert no-special-root changes
425
    def test_update_sets_root_id(self):
426
        """Ensure tree root is set properly by update.
427
        
428
        Since empty trees don't have root_ids, but workingtrees do,
429
        an update of a checkout of revision 0 to a new revision,  should set
430
        the root id.
431
        """
432
        wt = self.make_branch_and_tree('tree')
433
        main_branch = wt.branch
434
        # create an out of date working tree by making a checkout in this
435
        # current format
436
        self.build_tree(['checkout/', 'tree/file'])
1731.1.43 by Aaron Bentley
Merge more checkout changes
437
        checkout = main_branch.create_checkout('checkout')
1731.1.33 by Aaron Bentley
Revert no-special-root changes
438
        # now commit to 'tree'
439
        wt.add('file')
440
        wt.commit('A', rev_id='A')
441
        # and update checkout 
442
        self.assertEqual(0, checkout.update())
443
        self.failUnlessExists('checkout/file')
444
        self.assertEqual(wt.get_root_id(), checkout.get_root_id())
445
        self.assertNotEqual(None, wt.get_root_id())
446
1508.1.24 by Robert Collins
Add update command for use with checkouts.
447
    def test_update_returns_conflict_count(self):
448
        # working tree formats from the meta-dir format and newer support
449
        # setting the last revision on a tree independently of that on the 
450
        # branch. Its concievable that some future formats may want to 
451
        # couple them again (i.e. because its really a smart server and
452
        # the working tree will always match the branch). So we test
453
        # that formats where initialising a branch does not initialise a 
454
        # tree - and thus have separable entities - support skewing the 
455
        # two things.
456
        main_branch = self.make_branch('tree')
457
        try:
458
            # if there is a working tree now, this is not supported.
459
            main_branch.bzrdir.open_workingtree()
460
            return
461
        except errors.NoWorkingTree:
462
            pass
463
        wt = main_branch.bzrdir.create_workingtree()
464
        # create an out of date working tree by making a checkout in this
465
        # current format
466
        self.build_tree(['checkout/', 'tree/file'])
467
        checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
468
        branch.BranchReferenceFormat().initialize(checkout, main_branch)
1508.1.24 by Robert Collins
Add update command for use with checkouts.
469
        old_tree = self.workingtree_format.initialize(checkout)
470
        # now commit to 'tree'
471
        wt.add('file')
472
        wt.commit('A', rev_id='A')
473
        # and add a file file to the checkout
474
        self.build_tree(['checkout/file'])
475
        old_tree.add('file')
476
        # and update old_tree
477
        self.assertEqual(1, old_tree.update())
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
478
        self.assertEqual(['A'], old_tree.get_parent_ids())
1508.1.24 by Robert Collins
Add update command for use with checkouts.
479
1534.7.199 by Aaron Bentley
Moved merge/revert tests into test_workingtree.py
480
    def test_merge_revert(self):
481
        from bzrlib.merge import merge_inner
482
        this = self.make_branch_and_tree('b1')
483
        open('b1/a', 'wb').write('a test\n')
484
        this.add('a')
485
        open('b1/b', 'wb').write('b test\n')
486
        this.add('b')
487
        this.commit(message='')
488
        base = this.bzrdir.clone('b2').open_workingtree()
489
        open('b2/a', 'wb').write('b test\n')
490
        other = this.bzrdir.clone('b3').open_workingtree()
491
        open('b3/a', 'wb').write('c test\n')
492
        open('b3/c', 'wb').write('c test\n')
493
        other.add('c')
494
495
        open('b1/b', 'wb').write('q test\n')
496
        open('b1/d', 'wb').write('d test\n')
497
        merge_inner(this.branch, other, base, this_tree=this)
498
        self.assertNotEqual(open('b1/a', 'rb').read(), 'a test\n')
499
        this.revert([])
500
        self.assertEqual(open('b1/a', 'rb').read(), 'a test\n')
1534.10.29 by Aaron Bentley
Fixed backup numbering to match GNU standard better
501
        self.assertIs(os.path.exists('b1/b.~1~'), True)
1534.7.199 by Aaron Bentley
Moved merge/revert tests into test_workingtree.py
502
        self.assertIs(os.path.exists('b1/c'), False)
1534.10.29 by Aaron Bentley
Fixed backup numbering to match GNU standard better
503
        self.assertIs(os.path.exists('b1/a.~1~'), False)
1534.7.199 by Aaron Bentley
Moved merge/revert tests into test_workingtree.py
504
        self.assertIs(os.path.exists('b1/d'), True)
1534.7.200 by Aaron Bentley
Merge from mainline
505
1587.1.10 by Robert Collins
update updates working tree and branch together.
506
    def test_update_updates_bound_branch_no_local_commits(self):
507
        # doing an update in a tree updates the branch its bound to too.
508
        master_tree = self.make_branch_and_tree('master')
509
        tree = self.make_branch_and_tree('tree')
510
        try:
511
            tree.branch.bind(master_tree.branch)
512
        except errors.UpgradeRequired:
513
            # legacy branches cannot bind
514
            return
515
        master_tree.commit('foo', rev_id='foo', allow_pointless=True)
516
        tree.update()
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
517
        self.assertEqual(['foo'], tree.get_parent_ids())
1587.1.10 by Robert Collins
update updates working tree and branch together.
518
        self.assertEqual('foo', tree.branch.last_revision())
1587.1.11 by Robert Collins
Local commits appear to be working properly.
519
520
    def test_update_turns_local_commit_into_merge(self):
521
        # doing an update with a few local commits and no master commits
1587.1.13 by Robert Collins
Explain why update pivots more clearly in the relevant test.
522
        # makes pending-merges. 
523
        # this is done so that 'bzr update; bzr revert' will always produce
524
        # an exact copy of the 'logical branch' - the referenced branch for
525
        # a checkout, and the master for a bound branch.
526
        # its possible that we should instead have 'bzr update' when there
527
        # is nothing new on the master leave the current commits intact and
528
        # alter 'revert' to revert to the master always. But for now, its
529
        # good.
1587.1.11 by Robert Collins
Local commits appear to be working properly.
530
        master_tree = self.make_branch_and_tree('master')
1927.2.1 by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.
531
        master_tip = master_tree.commit('first master commit')
1587.1.11 by Robert Collins
Local commits appear to be working properly.
532
        tree = self.make_branch_and_tree('tree')
533
        try:
534
            tree.branch.bind(master_tree.branch)
535
        except errors.UpgradeRequired:
536
            # legacy branches cannot bind
537
            return
1927.2.1 by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.
538
        # sync with master
539
        tree.update()
540
        # work locally
1587.1.11 by Robert Collins
Local commits appear to be working properly.
541
        tree.commit('foo', rev_id='foo', allow_pointless=True, local=True)
542
        tree.commit('bar', rev_id='bar', allow_pointless=True, local=True)
1927.2.1 by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.
543
        # sync with master prepatory to committing
1587.1.11 by Robert Collins
Local commits appear to be working properly.
544
        tree.update()
1927.2.1 by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge.
545
        # which should have pivoted the local tip into a merge
546
        self.assertEqual([master_tip, 'bar'], tree.get_parent_ids())
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
547
        # and the local branch history should match the masters now.
548
        self.assertEqual(master_tree.branch.revision_history(),
549
            tree.branch.revision_history())
1587.1.11 by Robert Collins
Local commits appear to be working properly.
550
2298.1.1 by Martin Pool
Add test for merge_modified
551
    def test_merge_modified_detects_corruption(self):
552
        # FIXME: This doesn't really test that it works; also this is not
553
        # implementation-independent. mbp 20070226
1558.3.3 by Aaron Bentley
Fix error handling for merge_modified
554
        tree = self.make_branch_and_tree('master')
1955.3.14 by John Arbash Meinel
Correctly fix the workingtree put() test fixes
555
        tree._control_files.put('merge-hashes', StringIO('asdfasdf'))
1558.3.3 by Aaron Bentley
Fix error handling for merge_modified
556
        self.assertRaises(errors.MergeModifiedFormatError, tree.merge_modified)
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
557
2298.1.1 by Martin Pool
Add test for merge_modified
558
    def test_merge_modified(self):
559
        # merge_modified stores a map from file id to hash
560
        tree = self.make_branch_and_tree('tree')
561
        d = {'file-id': osutils.sha_string('hello')}
562
        self.build_tree_contents([('tree/somefile', 'hello')])
563
        tree.lock_write()
564
        try:
565
            tree.add(['somefile'], ['file-id'])
566
            tree.set_merge_modified(d)
567
            mm = tree.merge_modified()
568
            self.assertEquals(mm, d)
569
        finally:
570
            tree.unlock()
571
        mm = tree.merge_modified()
572
        self.assertEquals(mm, d)
573
1534.10.22 by Aaron Bentley
Got ConflictList implemented
574
    def test_conflicts(self):
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
575
        from bzrlib.tests.test_conflicts import example_conflicts
576
        tree = self.make_branch_and_tree('master')
577
        try:
1534.10.22 by Aaron Bentley
Got ConflictList implemented
578
            tree.set_conflicts(example_conflicts)
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
579
        except UnsupportedOperation:
1534.10.22 by Aaron Bentley
Got ConflictList implemented
580
            raise TestSkipped('set_conflicts not supported')
1534.10.8 by Aaron Bentley
Implemented conflict_lines in terms of old system on WorkingTree
581
            
582
        tree2 = WorkingTree.open('master')
1534.10.22 by Aaron Bentley
Got ConflictList implemented
583
        self.assertEqual(tree2.conflicts(), example_conflicts)
1955.3.14 by John Arbash Meinel
Correctly fix the workingtree put() test fixes
584
        tree2._control_files.put('conflicts', StringIO(''))
585
        self.assertRaises(errors.ConflictFormatError, 
586
                          tree2.conflicts)
587
        tree2._control_files.put('conflicts', StringIO('a'))
588
        self.assertRaises(errors.ConflictFormatError, 
589
                          tree2.conflicts)
1534.10.12 by Aaron Bentley
Merge produces new conflicts
590
591
    def make_merge_conflicts(self):
592
        from bzrlib.merge import merge_inner 
593
        tree = self.make_branch_and_tree('mine')
594
        file('mine/bloo', 'wb').write('one')
595
        tree.add('bloo')
1534.10.14 by Aaron Bentley
Made revert clear conflicts
596
        file('mine/blo', 'wb').write('on')
597
        tree.add('blo')
1534.10.12 by Aaron Bentley
Merge produces new conflicts
598
        tree.commit("blah", allow_pointless=False)
599
        base = tree.basis_tree()
1773.4.1 by Martin Pool
Add pyflakes makefile target; fix many warnings
600
        bzrdir.BzrDir.open("mine").sprout("other")
1534.10.12 by Aaron Bentley
Merge produces new conflicts
601
        file('other/bloo', 'wb').write('two')
602
        othertree = WorkingTree.open('other')
603
        othertree.commit('blah', allow_pointless=False)
604
        file('mine/bloo', 'wb').write('three')
605
        tree.commit("blah", allow_pointless=False)
606
        merge_inner(tree.branch, othertree, base, this_tree=tree)
607
        return tree
608
609
    def test_merge_conflicts(self):
610
        tree = self.make_merge_conflicts()
1534.10.22 by Aaron Bentley
Got ConflictList implemented
611
        self.assertEqual(len(tree.conflicts()), 1)
1534.10.12 by Aaron Bentley
Merge produces new conflicts
612
613
    def test_clear_merge_conflicts(self):
614
        tree = self.make_merge_conflicts()
1534.10.22 by Aaron Bentley
Got ConflictList implemented
615
        self.assertEqual(len(tree.conflicts()), 1)
1534.10.12 by Aaron Bentley
Merge produces new conflicts
616
        try:
1534.10.22 by Aaron Bentley
Got ConflictList implemented
617
            tree.set_conflicts(ConflictList())
1534.10.12 by Aaron Bentley
Merge produces new conflicts
618
        except UnsupportedOperation:
619
            raise TestSkipped
1534.10.22 by Aaron Bentley
Got ConflictList implemented
620
        self.assertEqual(tree.conflicts(), ConflictList())
1534.10.14 by Aaron Bentley
Made revert clear conflicts
621
1551.7.11 by Aaron Bentley
Add WorkingTree.add_conflicts
622
    def test_add_conflicts(self):
623
        tree = self.make_branch_and_tree('tree')
624
        try:
625
            tree.add_conflicts([TextConflict('path_a')])
626
        except UnsupportedOperation:
627
            raise TestSkipped()
1551.7.13 by Aaron Bentley
Switched from actual, expected to expected, actual, for John.
628
        self.assertEqual(ConflictList([TextConflict('path_a')]),
629
                         tree.conflicts())
1551.7.11 by Aaron Bentley
Add WorkingTree.add_conflicts
630
        tree.add_conflicts([TextConflict('path_a')])
1551.7.13 by Aaron Bentley
Switched from actual, expected to expected, actual, for John.
631
        self.assertEqual(ConflictList([TextConflict('path_a')]), 
632
                         tree.conflicts())
1551.7.11 by Aaron Bentley
Add WorkingTree.add_conflicts
633
        tree.add_conflicts([ContentsConflict('path_a')])
1551.7.13 by Aaron Bentley
Switched from actual, expected to expected, actual, for John.
634
        self.assertEqual(ConflictList([ContentsConflict('path_a'), 
635
                                       TextConflict('path_a')]),
636
                         tree.conflicts())
1551.7.11 by Aaron Bentley
Add WorkingTree.add_conflicts
637
        tree.add_conflicts([TextConflict('path_b')])
1551.7.13 by Aaron Bentley
Switched from actual, expected to expected, actual, for John.
638
        self.assertEqual(ConflictList([ContentsConflict('path_a'), 
1551.7.11 by Aaron Bentley
Add WorkingTree.add_conflicts
639
                                       TextConflict('path_a'),
1551.7.13 by Aaron Bentley
Switched from actual, expected to expected, actual, for John.
640
                                       TextConflict('path_b')]),
641
                         tree.conflicts())
1551.7.11 by Aaron Bentley
Add WorkingTree.add_conflicts
642
1534.10.14 by Aaron Bentley
Made revert clear conflicts
643
    def test_revert_clear_conflicts(self):
644
        tree = self.make_merge_conflicts()
1534.10.22 by Aaron Bentley
Got ConflictList implemented
645
        self.assertEqual(len(tree.conflicts()), 1)
1534.10.14 by Aaron Bentley
Made revert clear conflicts
646
        tree.revert(["blo"])
1534.10.22 by Aaron Bentley
Got ConflictList implemented
647
        self.assertEqual(len(tree.conflicts()), 1)
1534.10.14 by Aaron Bentley
Made revert clear conflicts
648
        tree.revert(["bloo"])
1534.10.22 by Aaron Bentley
Got ConflictList implemented
649
        self.assertEqual(len(tree.conflicts()), 0)
1534.10.14 by Aaron Bentley
Made revert clear conflicts
650
651
    def test_revert_clear_conflicts2(self):
652
        tree = self.make_merge_conflicts()
1534.10.22 by Aaron Bentley
Got ConflictList implemented
653
        self.assertEqual(len(tree.conflicts()), 1)
1534.10.14 by Aaron Bentley
Made revert clear conflicts
654
        tree.revert([])
1534.10.22 by Aaron Bentley
Got ConflictList implemented
655
        self.assertEqual(len(tree.conflicts()), 0)
1624.3.22 by Olaf Conradi
Merge bzr.dev
656
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
657
    def test_format_description(self):
658
        tree = self.make_branch_and_tree('tree')
659
        text = tree._format.get_format_description()
660
        self.failUnless(len(text))
1681.1.1 by Robert Collins
Make WorkingTree.branch a read only property. (Robert Collins)
661
662
    def test_branch_attribute_is_not_settable(self):
663
        # the branch attribute is an aspect of the working tree, not a
664
        # configurable attribute
665
        tree = self.make_branch_and_tree('tree')
666
        def set_branch():
667
            tree.branch = tree.branch
668
        self.assertRaises(AttributeError, set_branch)
669
1713.3.1 by Robert Collins
Smoke tests for tree.list_files and bzr ignored when a versioned file matches an ignore rule.
670
    def test_list_files_versioned_before_ignored(self):
671
        """A versioned file matching an ignore rule should not be ignored."""
672
        tree = self.make_branch_and_tree('.')
673
        self.build_tree(['foo.pyc'])
674
        # ensure that foo.pyc is ignored
675
        self.build_tree_contents([('.bzrignore', 'foo.pyc')])
676
        tree.add('foo.pyc', 'anid')
677
        files = sorted(list(tree.list_files()))
678
        self.assertEqual((u'.bzrignore', '?', 'file', None), files[0][:-1])
679
        self.assertEqual((u'foo.pyc', 'V', 'file', 'anid'), files[1][:-1])
680
        self.assertEqual(2, len(files))
1711.8.2 by John Arbash Meinel
Test that WorkingTree locks Branch before self, and unlocks self before Branch
681
1830.3.7 by John Arbash Meinel
Check that WorkingTree.add does the right thing.
682
    def test_non_normalized_add_accessible(self):
683
        try:
684
            self.build_tree([u'a\u030a'])
685
        except UnicodeError:
686
            raise TestSkipped('Filesystem does not support unicode filenames')
687
        tree = self.make_branch_and_tree('.')
688
        orig = osutils.normalized_filename
689
        osutils.normalized_filename = osutils._accessible_normalized_filename
690
        try:
691
            tree.add([u'a\u030a'])
1907.1.3 by Aaron Bentley
Fixed unicode test cases
692
            self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
1830.3.17 by John Arbash Meinel
list_files() with wrong normalized_filename code raises exceptions. Fix this
693
                    [(path, ie.kind) for path,ie in 
694
                                tree.inventory.iter_entries()])
1830.3.7 by John Arbash Meinel
Check that WorkingTree.add does the right thing.
695
        finally:
696
            osutils.normalized_filename = orig
697
698
    def test_non_normalized_add_inaccessible(self):
699
        try:
700
            self.build_tree([u'a\u030a'])
701
        except UnicodeError:
702
            raise TestSkipped('Filesystem does not support unicode filenames')
703
        tree = self.make_branch_and_tree('.')
704
        orig = osutils.normalized_filename
705
        osutils.normalized_filename = osutils._inaccessible_normalized_filename
706
        try:
707
            self.assertRaises(errors.InvalidNormalization,
708
                tree.add, [u'a\u030a'])
709
        finally:
710
            osutils.normalized_filename = orig
2123.3.9 by Steffen Eichenberg
added tests for deprecated API workingtree.move
711
712
    def test_move_deprecated_correct_call_named(self):
713
        """tree.move has the deprecated parameter 'to_name'.
714
        It has been replaced by 'to_dir' for consistency.
715
        Test the new API using named parameter"""
716
        self.build_tree(['a1', 'sub1/'])
717
        tree = self.make_branch_and_tree('.')
718
        tree.add(['a1', 'sub1'])
719
        tree.commit('initial commit')
720
        tree.move(['a1'], to_dir='sub1', after=False)
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
721
2123.3.9 by Steffen Eichenberg
added tests for deprecated API workingtree.move
722
    def test_move_deprecated_correct_call_unnamed(self):
723
        """tree.move has the deprecated parameter 'to_name'.
724
        It has been replaced by 'to_dir' for consistency.
725
        Test the new API using unnamed parameter"""
726
        self.build_tree(['a1', 'sub1/'])
727
        tree = self.make_branch_and_tree('.')
728
        tree.add(['a1', 'sub1'])
729
        tree.commit('initial commit')
730
        tree.move(['a1'], 'sub1', after=False)
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
731
2123.3.9 by Steffen Eichenberg
added tests for deprecated API workingtree.move
732
    def test_move_deprecated_wrong_call(self):
733
        """tree.move has the deprecated parameter 'to_name'.
734
        It has been replaced by 'to_dir' for consistency.
735
        Test the new API using wrong parameter"""
736
        self.build_tree(['a1', 'sub1/'])
737
        tree = self.make_branch_and_tree('.')
738
        tree.add(['a1', 'sub1'])
739
        tree.commit('initial commit')
2220.1.9 by Marius Kruger
Remove all trailing white space this bundle would have
740
        self.assertRaises(TypeError, tree.move, ['a1'],
2123.3.9 by Steffen Eichenberg
added tests for deprecated API workingtree.move
741
                          to_this_parameter_does_not_exist='sub1',
742
                          after=False)
743
744
    def test_move_deprecated_deprecated_call(self):
745
        """tree.move has the deprecated parameter 'to_name'.
746
        It has been replaced by 'to_dir' for consistency.
747
        Test the new API using deprecated parameter"""
748
        self.build_tree(['a1', 'sub1/'])
749
        tree = self.make_branch_and_tree('.')
750
        tree.add(['a1', 'sub1'])
751
        tree.commit('initial commit')
752
753
        #tree.move(['a1'], to_name='sub1', after=False)
754
        self.callDeprecated(['The parameter to_name was deprecated'
755
                             ' in version 0.13. Use to_dir instead'],
756
                            tree.move, ['a1'], to_name='sub1',
757
                            after=False)