~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Ian Clatworthy
  • Date: 2010-02-19 03:02:07 UTC
  • mto: (4797.23.1 integration-2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: ian.clatworthy@canonical.com-20100219030207-zpbzx021zavx4sqt
What's New in 2.1 - a summary of changes since 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
419
419
            (('', '', tree.get_root_id()), # common details
420
420
             [('d', '', 0, False, dirstate.DirState.NULLSTAT), # current tree
421
421
              ('d', '', 0, False, rev_id), # first parent details
422
 
              ('d', '', 0, False, rev_id2), # second parent details
 
422
              ('d', '', 0, False, rev_id), # second parent details
423
423
             ])])
424
424
        state = dirstate.DirState.from_tree(tree, 'dirstate')
425
425
        self.check_state_with_reopen(expected_result, state)
500
500
            (('', '', tree.get_root_id()), # common details
501
501
             [('d', '', 0, False, dirstate.DirState.NULLSTAT), # current tree
502
502
              ('d', '', 0, False, rev_id), # first parent details
503
 
              ('d', '', 0, False, rev_id2), # second parent details
 
503
              ('d', '', 0, False, rev_id), # second parent details
504
504
             ]),
505
505
            (('', 'a file', 'a-file-id'), # common
506
506
             [('f', '', 0, False, dirstate.DirState.NULLSTAT), # current
873
873
        state = dirstate.DirState.initialize('dirstate')
874
874
        try:
875
875
            # check precondition to be sure the state does change appropriately.
876
 
            self.assertEqual(
877
 
                [(('', '', 'TREE_ROOT'), [('d', '', 0, False,
878
 
                   'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')])],
879
 
                list(state._iter_entries()))
880
 
            state.set_path_id('', 'foobarbaz')
881
 
            expected_rows = [
882
 
                (('', '', 'foobarbaz'), [('d', '', 0, False,
883
 
                   'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')])]
 
876
            root_entry = (('', '', 'TREE_ROOT'), [('d', '', 0, False, 'x'*32)])
 
877
            self.assertEqual([root_entry], list(state._iter_entries()))
 
878
            self.assertEqual(root_entry, state._get_entry(0, path_utf8=''))
 
879
            self.assertEqual(root_entry,
 
880
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
 
881
            self.assertEqual((None, None),
 
882
                             state._get_entry(0, fileid_utf8='second-root-id'))
 
883
            state.set_path_id('', 'second-root-id')
 
884
            new_root_entry = (('', '', 'second-root-id'),
 
885
                              [('d', '', 0, False, 'x'*32)])
 
886
            expected_rows = [new_root_entry]
884
887
            self.assertEqual(expected_rows, list(state._iter_entries()))
 
888
            self.assertEqual(new_root_entry, state._get_entry(0, path_utf8=''))
 
889
            self.assertEqual(new_root_entry, 
 
890
                             state._get_entry(0, fileid_utf8='second-root-id'))
 
891
            self.assertEqual((None, None),
 
892
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
885
893
            # should work across save too
886
894
            state.save()
887
895
        finally:
905
913
        state._validate()
906
914
        try:
907
915
            state.set_parent_trees([('parent-revid', rt)], ghosts=[])
908
 
            state.set_path_id('', 'foobarbaz')
 
916
            root_entry = (('', '', 'TREE_ROOT'),
 
917
                          [('d', '', 0, False, 'x'*32),
 
918
                           ('d', '', 0, False, 'parent-revid')])
 
919
            self.assertEqual(root_entry, state._get_entry(0, path_utf8=''))
 
920
            self.assertEqual(root_entry,
 
921
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
 
922
            self.assertEqual((None, None),
 
923
                             state._get_entry(0, fileid_utf8='Asecond-root-id'))
 
924
            state.set_path_id('', 'Asecond-root-id')
909
925
            state._validate()
910
926
            # now see that it is what we expected
911
 
            expected_rows = [
912
 
                (('', '', 'TREE_ROOT'),
913
 
                    [('a', '', 0, False, ''),
914
 
                     ('d', '', 0, False, 'parent-revid'),
915
 
                     ]),
916
 
                (('', '', 'foobarbaz'),
917
 
                    [('d', '', 0, False, ''),
918
 
                     ('a', '', 0, False, ''),
919
 
                     ]),
920
 
                ]
 
927
            old_root_entry = (('', '', 'TREE_ROOT'),
 
928
                              [('a', '', 0, False, ''),
 
929
                               ('d', '', 0, False, 'parent-revid')])
 
930
            new_root_entry = (('', '', 'Asecond-root-id'),
 
931
                              [('d', '', 0, False, ''),
 
932
                               ('a', '', 0, False, '')])
 
933
            expected_rows = [new_root_entry, old_root_entry]
921
934
            state._validate()
922
935
            self.assertEqual(expected_rows, list(state._iter_entries()))
 
936
            self.assertEqual(new_root_entry, state._get_entry(0, path_utf8=''))
 
937
            self.assertEqual(old_root_entry, state._get_entry(1, path_utf8=''))
 
938
            self.assertEqual((None, None),
 
939
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
 
940
            self.assertEqual(old_root_entry,
 
941
                             state._get_entry(1, fileid_utf8='TREE_ROOT'))
 
942
            self.assertEqual(new_root_entry,
 
943
                             state._get_entry(0, fileid_utf8='Asecond-root-id'))
 
944
            self.assertEqual((None, None),
 
945
                             state._get_entry(1, fileid_utf8='Asecond-root-id'))
923
946
            # should work across save too
924
947
            state.save()
925
948
        finally:
1000
1023
                [(('', '', root_id), [
1001
1024
                  ('d', '', 0, False, dirstate.DirState.NULLSTAT),
1002
1025
                  ('d', '', 0, False, revid1),
1003
 
                  ('d', '', 0, False, revid2)
 
1026
                  ('d', '', 0, False, revid1)
1004
1027
                  ])],
1005
1028
                list(state._iter_entries()))
1006
1029
        finally:
1034
1057
            (('', '', root_id), [
1035
1058
             ('d', '', 0, False, dirstate.DirState.NULLSTAT),
1036
1059
             ('d', '', 0, False, revid1.encode('utf8')),
1037
 
             ('d', '', 0, False, revid2.encode('utf8'))
 
1060
             ('d', '', 0, False, revid1.encode('utf8'))
1038
1061
             ]),
1039
1062
            (('', 'a file', 'file-id'), [
1040
1063
             ('a', '', 0, False, ''),