~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-07-12 09:49:37 UTC
  • mfrom: (2598.5.9 nullrevision)
  • Revision ID: pqm@pqm.ubuntu.com-20070712094937-rw5qbi81enh0pvhw
Make most functions prefer NULL_REVISION

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    errors,
25
25
    inventory,
26
26
    repository,
 
27
    revision as _mod_revision,
27
28
    treebuilder,
28
29
    )
29
30
from bzrlib.builtins import _merge_helper
336
337
        source.commit('one', rev_id='one-id')
337
338
        source.commit('two', rev_id='two-id')
338
339
        text = StringIO()
339
 
        write_bundle(source.branch.repository, 'two-id', None, text, 
 
340
        write_bundle(source.branch.repository, 'two-id', 'null:', text,
340
341
                     format='0.9')
341
342
        text.seek(0)
342
343
 
456
457
                os.mkdir(checkout_dir)
457
458
        tree = self.make_branch_and_tree(checkout_dir)
458
459
        s = StringIO()
459
 
        ancestors = write_bundle(self.b1.repository, rev_id, None, s,
 
460
        ancestors = write_bundle(self.b1.repository, rev_id, 'null:', s,
460
461
                                 format=self.format)
461
462
        s.seek(0)
462
463
        assert isinstance(s.getvalue(), str), (
482
483
                    continue
483
484
                self.assertEqual(old_file.read(),
484
485
                                 new.get_file(inventory_id).read())
485
 
        if rev_id is not None:
 
486
        if not _mod_revision.is_null(rev_id):
486
487
            rh = self.b1.revision_history()
487
488
            tree.branch.set_revision_history(rh[:rh.index(rev_id)+1])
488
489
            tree.update()
549
550
        self.tree1.add('one')
550
551
        self.tree1.commit('add one', rev_id='a@cset-0-1')
551
552
 
552
 
        bundle = self.get_valid_bundle(None, 'a@cset-0-1')
 
553
        bundle = self.get_valid_bundle('null:', 'a@cset-0-1')
553
554
        # FIXME: The current write_bundle api no longer supports
554
555
        #        setting a custom summary message
555
556
        #        We should re-introduce the ability, and update
591
592
        bundle = self.get_valid_bundle('a@cset-0-1', 'a@cset-0-2')
592
593
 
593
594
        # Check a rollup bundle 
594
 
        bundle = self.get_valid_bundle(None, 'a@cset-0-2')
 
595
        bundle = self.get_valid_bundle('null:', 'a@cset-0-2')
595
596
 
596
597
        # Now delete entries
597
598
        self.tree1.remove(
609
610
        self.assertRaises(TestamentMismatch, self.get_invalid_bundle, 
610
611
                          'a@cset-0-2', 'a@cset-0-3')
611
612
        # Check a rollup bundle 
612
 
        bundle = self.get_valid_bundle(None, 'a@cset-0-3')
 
613
        bundle = self.get_valid_bundle('null:', 'a@cset-0-3')
613
614
 
614
615
        # Now move the directory
615
616
        self.tree1.rename_one('dir', 'sub/dir')
617
618
 
618
619
        bundle = self.get_valid_bundle('a@cset-0-3', 'a@cset-0-4')
619
620
        # Check a rollup bundle 
620
 
        bundle = self.get_valid_bundle(None, 'a@cset-0-4')
 
621
        bundle = self.get_valid_bundle('null:', 'a@cset-0-4')
621
622
 
622
623
        # Modified files
623
624
        open('b1/sub/dir/WithCaps.txt', 'ab').write('\nAdding some text\n')
656
657
        tt.new_symlink('link', tt.root, 'bar/foo', 'link-1')
657
658
        tt.apply()
658
659
        self.tree1.commit('add symlink', rev_id='l@cset-0-1')
659
 
        self.get_valid_bundle(None, 'l@cset-0-1')
 
660
        self.get_valid_bundle('null:', 'l@cset-0-1')
660
661
        tt = TreeTransform(self.tree1)
661
662
        trans_id = tt.trans_id_tree_file_id('link-1')
662
663
        tt.adjust_path('link2', tt.root, trans_id)
689
690
        tt.new_file('file2', tt.root, '\x01\n\x02\r\x03\n\x04\r\xff', 'binary-2')
690
691
        tt.apply()
691
692
        self.tree1.commit('add binary', rev_id='b@cset-0-1')
692
 
        self.get_valid_bundle(None, 'b@cset-0-1')
 
693
        self.get_valid_bundle('null:', 'b@cset-0-1')
693
694
 
694
695
        # Delete
695
696
        tt = TreeTransform(self.tree1)
719
720
        self.get_valid_bundle('b@cset-0-3', 'b@cset-0-4')
720
721
 
721
722
        # Rollup
722
 
        self.get_valid_bundle(None, 'b@cset-0-4')
 
723
        self.get_valid_bundle('null:', 'b@cset-0-4')
723
724
 
724
725
    def test_last_modified(self):
725
726
        self.tree1 = self.make_branch_and_tree('b1')
799
800
                              " combining characters.")
800
801
 
801
802
        # Add
802
 
        bundle = self.get_valid_bundle(None, 'i18n-1')
 
803
        bundle = self.get_valid_bundle('null:', 'i18n-1')
803
804
 
804
805
        # Modified
805
806
        f = open(u'b1/with Dod\xe9', 'wb')
823
824
        bundle = self.get_valid_bundle('i18n-3', 'i18n-4')
824
825
 
825
826
        # Rollup
826
 
        bundle = self.get_valid_bundle(None, 'i18n-4')
 
827
        bundle = self.get_valid_bundle('null:', 'i18n-4')
827
828
 
828
829
 
829
830
    def test_whitespace_bundle(self):
841
842
        # Added
842
843
        self.tree1.commit('funky whitespace', rev_id='white-1')
843
844
 
844
 
        bundle = self.get_valid_bundle(None, 'white-1')
 
845
        bundle = self.get_valid_bundle('null:', 'white-1')
845
846
 
846
847
        # Modified
847
848
        open('b1/trailing space ', 'ab').write('add some text\n')
862
863
        bundle = self.get_valid_bundle('white-3', 'white-4')
863
864
        
864
865
        # Now test a complet roll-up
865
 
        bundle = self.get_valid_bundle(None, 'white-4')
 
866
        bundle = self.get_valid_bundle('null:', 'white-4')
866
867
 
867
868
    def test_alt_timezone_bundle(self):
868
869
        self.tree1 = self.make_branch_and_memory_tree('b1')
878
879
        self.tree1.commit('non-hour offset timezone', rev_id='tz-1',
879
880
                          timezone=19800, timestamp=1152544886.0)
880
881
 
881
 
        bundle = self.get_valid_bundle(None, 'tz-1')
 
882
        bundle = self.get_valid_bundle('null:', 'tz-1')
882
883
        
883
884
        rev = bundle.revisions[0]
884
885
        self.assertEqual('Mon 2006-07-10 20:51:26.000000000 +0530', rev.date)
890
891
        self.tree1 = self.make_branch_and_tree('b1')
891
892
        self.b1 = self.tree1.branch
892
893
        self.tree1.commit('message', rev_id='revid1')
893
 
        bundle = self.get_valid_bundle(None, 'revid1')
 
894
        bundle = self.get_valid_bundle('null:', 'revid1')
894
895
        tree = bundle.revision_tree(self.b1.repository, 'revid1')
895
896
        self.assertEqual('revid1', tree.inventory.root.revision)
896
897
 
898
899
        self.tree1 = self.make_branch_and_tree('b1')
899
900
        self.b1 = self.tree1.branch
900
901
        self.tree1.commit('message', rev_id='rev2a')
901
 
        bundle = self.get_valid_bundle(None, 'rev2a')
 
902
        bundle = self.get_valid_bundle('null:', 'rev2a')
902
903
        branch2 = self.make_branch('b2')
903
904
        self.assertFalse(branch2.repository.has_revision('rev2a'))
904
905
        target_revision = bundle.install_revisions(branch2.repository)
913
914
        tree.add([''], ['TREE_ROOT'])
914
915
        tree.commit('One', revprops={'one':'two', 'empty':''}, rev_id='rev1')
915
916
        self.b1 = tree.branch
916
 
        bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
 
917
        bundle_sio, revision_ids = self.create_bundle_text('null:', 'rev1')
917
918
        self.assertContainsRe(bundle_sio.getvalue(),
918
919
                              '# properties:\n'
919
920
                              '#   branch-nick: tree\n'
941
942
        tree.add([''], ['TREE_ROOT'])
942
943
        tree.commit('One', revprops={'one':'two', 'empty':''}, rev_id='rev1')
943
944
        self.b1 = tree.branch
944
 
        bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
 
945
        bundle_sio, revision_ids = self.create_bundle_text('null:', 'rev1')
945
946
        txt = bundle_sio.getvalue()
946
947
        loc = txt.find('#   empty: ') + len('#   empty:')
947
948
        # Create a new bundle, which strips the trailing space after empty
970
971
        tree.commit('One', rev_id='rev1',
971
972
                    revprops={'a':'4', 'b':'3', 'c':'2', 'd':'1'})
972
973
        self.b1 = tree.branch
973
 
        bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
 
974
        bundle_sio, revision_ids = self.create_bundle_text('null:', 'rev1')
974
975
        self.assertContainsRe(bundle_sio.getvalue(),
975
976
                              '# properties:\n'
976
977
                              '#   a: 4\n'
1001
1002
        tree.commit('One', rev_id='rev1',
1002
1003
                    revprops={'omega':u'\u03a9', 'alpha':u'\u03b1'})
1003
1004
        self.b1 = tree.branch
1004
 
        bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
 
1005
        bundle_sio, revision_ids = self.create_bundle_text('null:', 'rev1')
1005
1006
        self.assertContainsRe(bundle_sio.getvalue(),
1006
1007
                              '# properties:\n'
1007
1008
                              '#   alpha: \xce\xb1\n'