~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/bzrdir_implementations/test_bzrdir.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
                           NotBranchError,
34
34
                           )
35
35
import bzrlib.repository as repository
 
36
import bzrlib.revision
36
37
from bzrlib.tests import (
37
38
                          ChrootedTestCase,
38
39
                          TestCase,
142
143
            raise TestSkipped('Cannot sprout to remote bzrdirs.')
143
144
        return target
144
145
 
 
146
    def test_create_null_workingtree(self):
 
147
        dir = self.make_bzrdir('dir1')
 
148
        dir.create_repository()
 
149
        dir.create_branch()
 
150
        wt = dir.create_workingtree(revision_id=bzrlib.revision.NULL_REVISION)
 
151
        self.assertEqual([], wt.get_parent_ids())
 
152
 
145
153
    def test_clone_bzrdir_empty(self):
146
154
        dir = self.make_bzrdir('source')
147
155
        target = dir.clone(self.get_url('target'))
199
207
        tree.add('foo')
200
208
        tree.commit('revision 1', rev_id='1')
201
209
        tree.bzrdir.open_branch().set_revision_history([])
202
 
        tree.set_last_revision(None)
 
210
        tree.set_parent_trees([])
203
211
        tree.commit('revision 2', rev_id='2')
204
212
        tree.bzrdir.open_repository().copy_content_into(shared_repo)
205
213
        dir = self.make_bzrdir('shared/source')
219
227
        tree.add('foo')
220
228
        tree.commit('revision 1', rev_id='1')
221
229
        tree.bzrdir.open_branch().set_revision_history([])
222
 
        tree.set_last_revision(None)
 
230
        tree.set_parent_trees([])
223
231
        tree.commit('revision 2', rev_id='2')
224
232
        tree.bzrdir.open_repository().copy_content_into(shared_repo)
225
233
        shared_repo.set_make_working_trees(False)
264
272
        tree.add('foo')
265
273
        tree.commit('revision 1', rev_id='1')
266
274
        tree.bzrdir.open_branch().set_revision_history([])
267
 
        tree.set_last_revision(None)
 
275
        tree.set_parent_trees([])
268
276
        tree.commit('revision 2', rev_id='2')
269
277
        source = self.make_repository('source')
270
278
        tree.bzrdir.open_repository().copy_content_into(source)
437
445
        dir = tree.bzrdir
438
446
        target = dir.clone(self.get_url('target'), revision_id='1')
439
447
        self.skipIfNoWorkingTree(target)
440
 
        self.assertEqual('1', target.open_workingtree().last_revision())
 
448
        self.assertEqual(['1'], target.open_workingtree().get_parent_ids())
441
449
 
442
450
    def test_clone_bzrdir_incomplete_source_with_basis(self):
443
451
        # ensure that basis really does grab from the basis by having incomplete source
456
464
        target = dir.clone(self.get_url('target'), basis=tree.bzrdir)
457
465
        self.assertEqual('2', target.open_branch().last_revision())
458
466
        try:
459
 
            self.assertEqual('2', target.open_workingtree().last_revision())
 
467
            self.assertEqual(['2'], target.open_workingtree().get_parent_ids())
460
468
        except errors.NoWorkingTree:
461
469
            # It should have a working tree if it's able to have one, so if
462
470
            # we're here make sure it really can't have one.
519
527
        tree.add('foo')
520
528
        tree.commit('revision 1', rev_id='1')
521
529
        tree.bzrdir.open_branch().set_revision_history([])
522
 
        tree.set_last_revision(None)
 
530
        tree.set_parent_trees([])
523
531
        tree.commit('revision 2', rev_id='2')
524
532
        source = self.make_repository('source')
525
533
        tree.bzrdir.open_repository().copy_content_into(source)
542
550
        tree.add('foo')
543
551
        tree.commit('revision 1', rev_id='1')
544
552
        tree.bzrdir.open_branch().set_revision_history([])
545
 
        tree.set_last_revision(None)
 
553
        tree.set_parent_trees([])
546
554
        tree.commit('revision 2', rev_id='2')
547
555
        tree.bzrdir.open_repository().copy_content_into(shared_repo)
548
556
        dir = self.make_bzrdir('shared/source')
562
570
        tree.add('foo')
563
571
        tree.commit('revision 1', rev_id='1')
564
572
        tree.bzrdir.open_branch().set_revision_history([])
565
 
        tree.set_last_revision(None)
 
573
        tree.set_parent_trees([])
566
574
        tree.commit('revision 2', rev_id='2')
567
575
        tree.bzrdir.open_repository().copy_content_into(shared_repo)
568
576
        shared_repo.set_make_working_trees(False)
584
592
        tree.add('foo')
585
593
        tree.commit('revision 1', rev_id='1')
586
594
        tree.bzrdir.open_branch().set_revision_history([])
587
 
        tree.set_last_revision(None)
 
595
        tree.set_parent_trees([])
588
596
        tree.commit('revision 2', rev_id='2')
589
597
        source = self.make_repository('source')
590
598
        tree.bzrdir.open_repository().copy_content_into(source)
608
616
        tree.add('foo')
609
617
        tree.commit('revision 1', rev_id='1')
610
618
        tree.bzrdir.open_branch().set_revision_history([])
611
 
        tree.set_last_revision(None)
 
619
        tree.set_parent_trees([])
612
620
        tree.commit('revision 2', rev_id='2')
613
621
        source = self.make_repository('source')
614
622
        tree.bzrdir.open_repository().copy_content_into(source)
829
837
        # place
830
838
        target.open_repository()
831
839
        # we trust that the working tree sprouting works via the other tests.
832
 
        self.assertEqual('1', target.open_workingtree().last_revision())
 
840
        self.assertEqual(['1'], target.open_workingtree().get_parent_ids())
833
841
        self.assertEqual('1', target.open_branch().last_revision())
834
842
 
835
843
    def test_sprout_bzrdir_tree_revision(self):
845
853
        tree.commit('revision 2', rev_id='2', allow_pointless=True)
846
854
        dir = tree.bzrdir
847
855
        target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1')
848
 
        self.assertEqual('1', target.open_workingtree().last_revision())
 
856
        self.assertEqual(['1'], target.open_workingtree().get_parent_ids())
849
857
 
850
858
    def test_sprout_bzrdir_incomplete_source_with_basis(self):
851
859
        # ensure that basis really does grab from the basis by having incomplete source
864
872
        target = self.sproutOrSkip(dir, self.get_url('target'),
865
873
                                   basis=tree.bzrdir)
866
874
        self.assertEqual('2', target.open_branch().last_revision())
867
 
        self.assertEqual('2', target.open_workingtree().last_revision())
 
875
        self.assertEqual(['2'], target.open_workingtree().get_parent_ids())
868
876
        self.assertTrue(target.open_branch().repository.has_revision('2'))
869
877
 
870
878
    def test_format_initialize_find_open(self):
1011
1019
            made_tree = made_control.create_workingtree(revision_id='a')
1012
1020
        except errors.NotLocalUrl:
1013
1021
            raise TestSkipped("Can't make working tree on transport %r" % t)
1014
 
        self.assertEqual('a', made_tree.last_revision())
 
1022
        self.assertEqual(['a'], made_tree.get_parent_ids())
1015
1023
        
1016
1024
    def test_open_workingtree(self):
1017
1025
        if not self.bzrdir_format.is_supported():