/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

  • Committer: Robey Pointer
  • Date: 2006-09-08 18:52:17 UTC
  • mfrom: (1993 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1996.
  • Revision ID: robey@lag.net-20060908185217-6a4406e1d41753f5
merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
import sys
21
21
 
22
 
from bzrlib import ignores
23
22
import bzrlib
24
23
from bzrlib import branch, bzrdir, errors, osutils, urlutils, workingtree
25
24
from bzrlib.errors import (NotBranchError, NotVersionedError,
49
48
 
50
49
    def test_list_files_sorted(self):
51
50
        tree = self.make_branch_and_tree('.')
52
 
        ignores._set_user_ignores(['./.bazaar'])
53
51
        self.build_tree(['dir/', 'file', 'dir/file', 'dir/b',
54
52
                         'dir/subdir/', 'a', 'dir/subfile',
55
53
                         'zz_dir/', 'zz_dir/subfile'])
56
54
        files = [(path, kind) for (path, v, kind, file_id, entry)
57
55
                               in tree.list_files()]
58
56
        self.assertEqual([
59
 
            ('.bazaar', 'directory'),
60
57
            ('a', 'file'),
61
58
            ('dir', 'directory'),
62
59
            ('file', 'file'),
67
64
        files = [(path, kind) for (path, v, kind, file_id, entry)
68
65
                               in tree.list_files()]
69
66
        self.assertEqual([
70
 
            ('.bazaar', 'directory'),
71
67
            ('a', 'file'),
72
68
            ('dir', 'directory'),
73
69
            ('dir/b', 'file'),
267
263
        wt = self.make_branch_and_tree('source')
268
264
        cloned_dir = wt.bzrdir.clone('target')
269
265
        cloned = cloned_dir.open_workingtree()
270
 
        self.assertEqual(cloned.last_revision(), wt.last_revision())
 
266
        self.assertEqual(cloned.get_parent_ids(), wt.get_parent_ids())
271
267
 
272
268
    def test_last_revision(self):
273
269
        wt = self.make_branch_and_tree('source')
274
 
        self.assertEqual(None, wt.last_revision())
 
270
        self.assertEqual([], wt.get_parent_ids())
275
271
        wt.commit('A', allow_pointless=True, rev_id='A')
276
 
        self.assertEqual('A', wt.last_revision())
 
272
        self.assertEqual(['A'], wt.get_parent_ids())
277
273
 
278
274
    def test_set_last_revision(self):
279
275
        wt = self.make_branch_and_tree('source')
280
 
        self.assertEqual(None, wt.last_revision())
281
276
        # set last-revision to one not in the history
282
277
        wt.set_last_revision('A')
283
278
        # set it back to None for an empty tree.
284
279
        wt.set_last_revision(None)
285
280
        wt.commit('A', allow_pointless=True, rev_id='A')
286
 
        self.assertEqual('A', wt.last_revision())
 
281
        self.assertEqual(['A'], wt.get_parent_ids())
287
282
        # None is aways in the branch
288
283
        wt.set_last_revision(None)
289
 
        self.assertEqual(None, wt.last_revision())
 
284
        self.assertEqual([], wt.get_parent_ids())
290
285
        # and now we can set it to 'A'
291
286
        # because some formats mutate the branch to set it on the tree
292
287
        # we need to alter the branch to let this pass.
293
288
        wt.branch.set_revision_history(['A', 'B'])
294
289
        wt.set_last_revision('A')
295
 
        self.assertEqual('A', wt.last_revision())
 
290
        self.assertEqual(['A'], wt.get_parent_ids())
296
291
 
297
292
    def test_set_last_revision_different_to_branch(self):
298
293
        # working tree formats from the meta-dir format and newer support
313
308
        wt = branch.bzrdir.create_workingtree()
314
309
        wt.commit('A', allow_pointless=True, rev_id='A')
315
310
        wt.set_last_revision(None)
316
 
        self.assertEqual(None, wt.last_revision())
 
311
        self.assertEqual([], wt.get_parent_ids())
317
312
        self.assertEqual('A', wt.branch.last_revision())
318
313
        # and now we can set it back to 'A'
319
314
        wt.set_last_revision('A')
320
 
        self.assertEqual('A', wt.last_revision())
 
315
        self.assertEqual(['A'], wt.get_parent_ids())
321
316
        self.assertEqual('A', wt.branch.last_revision())
322
317
 
323
318
    def test_clone_and_commit_preserves_last_revision(self):
 
319
        """Doing a commit into a clone tree does not affect the source."""
324
320
        wt = self.make_branch_and_tree('source')
325
321
        cloned_dir = wt.bzrdir.clone('target')
326
322
        wt.commit('A', allow_pointless=True, rev_id='A')
327
 
        self.assertNotEqual(cloned_dir.open_workingtree().last_revision(),
328
 
                            wt.last_revision())
 
323
        self.assertNotEqual(cloned_dir.open_workingtree().get_parent_ids(),
 
324
                            wt.get_parent_ids())
329
325
 
330
326
    def test_clone_preserves_content(self):
331
327
        wt = self.make_branch_and_tree('source')
384
380
        source.branch.repository.clone(made_control)
385
381
        source.branch.clone(made_control)
386
382
        made_tree = self.workingtree_format.initialize(made_control, revision_id='a')
387
 
        self.assertEqual('a', made_tree.last_revision())
 
383
        self.assertEqual(['a'], made_tree.get_parent_ids())
388
384
 
389
385
    def test_update_sets_last_revision(self):
390
386
        # working tree formats from the meta-dir format and newer support
415
411
        # and update old_tree
416
412
        self.assertEqual(0, old_tree.update())
417
413
        self.failUnlessExists('checkout/file')
418
 
        self.assertEqual('A', old_tree.last_revision())
 
414
        self.assertEqual(['A'], old_tree.get_parent_ids())
419
415
 
420
416
    def test_update_returns_conflict_count(self):
421
417
        # working tree formats from the meta-dir format and newer support
448
444
        old_tree.add('file')
449
445
        # and update old_tree
450
446
        self.assertEqual(1, old_tree.update())
451
 
        self.assertEqual('A', old_tree.last_revision())
 
447
        self.assertEqual(['A'], old_tree.get_parent_ids())
452
448
 
453
449
    def test_merge_revert(self):
454
450
        from bzrlib.merge import merge_inner
487
483
            return
488
484
        master_tree.commit('foo', rev_id='foo', allow_pointless=True)
489
485
        tree.update()
490
 
        self.assertEqual('foo', tree.last_revision())
 
486
        self.assertEqual(['foo'], tree.get_parent_ids())
491
487
        self.assertEqual('foo', tree.branch.last_revision())
492
488
 
493
489
    def test_update_turns_local_commit_into_merge(self):
516
512
        # sync with master prepatory to committing
517
513
        tree.update()
518
514
        # which should have pivoted the local tip into a merge
519
 
        self.assertEqual(master_tip, tree.last_revision())
520
 
        self.assertEqual([master_tip], tree.branch.revision_history())
521
515
        self.assertEqual([master_tip, 'bar'], tree.get_parent_ids())
 
516
        # and the local branch history should match the masters now.
 
517
        self.assertEqual(master_tree.branch.revision_history(),
 
518
            tree.branch.revision_history())
522
519
 
523
520
    def test_merge_modified(self):
524
521
        tree = self.make_branch_and_tree('master')