413
419
(('', '', tree.get_root_id()), # common details
414
420
[('d', '', 0, False, dirstate.DirState.NULLSTAT), # current tree
415
421
('d', '', 0, False, rev_id), # first parent details
416
('d', '', 0, False, rev_id), # second parent details
422
('d', '', 0, False, rev_id2), # second parent details
418
424
state = dirstate.DirState.from_tree(tree, 'dirstate')
419
425
self.check_state_with_reopen(expected_result, state)
494
500
(('', '', tree.get_root_id()), # common details
495
501
[('d', '', 0, False, dirstate.DirState.NULLSTAT), # current tree
496
502
('d', '', 0, False, rev_id), # first parent details
497
('d', '', 0, False, rev_id), # second parent details
503
('d', '', 0, False, rev_id2), # second parent details
499
505
(('', 'a file', 'a-file-id'), # common
500
506
[('f', '', 0, False, dirstate.DirState.NULLSTAT), # current
867
873
state = dirstate.DirState.initialize('dirstate')
869
875
# check precondition to be sure the state does change appropriately.
870
root_entry = (('', '', 'TREE_ROOT'), [('d', '', 0, False, 'x'*32)])
871
self.assertEqual([root_entry], list(state._iter_entries()))
872
self.assertEqual(root_entry, state._get_entry(0, path_utf8=''))
873
self.assertEqual(root_entry,
874
state._get_entry(0, fileid_utf8='TREE_ROOT'))
875
self.assertEqual((None, None),
876
state._get_entry(0, fileid_utf8='second-root-id'))
877
state.set_path_id('', 'second-root-id')
878
new_root_entry = (('', '', 'second-root-id'),
879
[('d', '', 0, False, 'x'*32)])
880
expected_rows = [new_root_entry]
877
[(('', '', 'TREE_ROOT'), [('d', '', 0, False,
878
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')])],
879
list(state._iter_entries()))
880
state.set_path_id('', 'foobarbaz')
882
(('', '', 'foobarbaz'), [('d', '', 0, False,
883
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')])]
881
884
self.assertEqual(expected_rows, list(state._iter_entries()))
882
self.assertEqual(new_root_entry, state._get_entry(0, path_utf8=''))
883
self.assertEqual(new_root_entry,
884
state._get_entry(0, fileid_utf8='second-root-id'))
885
self.assertEqual((None, None),
886
state._get_entry(0, fileid_utf8='TREE_ROOT'))
887
885
# should work across save too
907
905
state._validate()
909
907
state.set_parent_trees([('parent-revid', rt)], ghosts=[])
910
root_entry = (('', '', 'TREE_ROOT'),
911
[('d', '', 0, False, 'x'*32),
912
('d', '', 0, False, 'parent-revid')])
913
self.assertEqual(root_entry, state._get_entry(0, path_utf8=''))
914
self.assertEqual(root_entry,
915
state._get_entry(0, fileid_utf8='TREE_ROOT'))
916
self.assertEqual((None, None),
917
state._get_entry(0, fileid_utf8='Asecond-root-id'))
918
state.set_path_id('', 'Asecond-root-id')
908
state.set_path_id('', 'foobarbaz')
919
909
state._validate()
920
910
# now see that it is what we expected
921
old_root_entry = (('', '', 'TREE_ROOT'),
922
[('a', '', 0, False, ''),
923
('d', '', 0, False, 'parent-revid')])
924
new_root_entry = (('', '', 'Asecond-root-id'),
925
[('d', '', 0, False, ''),
926
('a', '', 0, False, '')])
927
expected_rows = [new_root_entry, old_root_entry]
912
(('', '', 'TREE_ROOT'),
913
[('a', '', 0, False, ''),
914
('d', '', 0, False, 'parent-revid'),
916
(('', '', 'foobarbaz'),
917
[('d', '', 0, False, ''),
918
('a', '', 0, False, ''),
928
921
state._validate()
929
922
self.assertEqual(expected_rows, list(state._iter_entries()))
930
self.assertEqual(new_root_entry, state._get_entry(0, path_utf8=''))
931
self.assertEqual(old_root_entry, state._get_entry(1, path_utf8=''))
932
self.assertEqual((None, None),
933
state._get_entry(0, fileid_utf8='TREE_ROOT'))
934
self.assertEqual(old_root_entry,
935
state._get_entry(1, fileid_utf8='TREE_ROOT'))
936
self.assertEqual(new_root_entry,
937
state._get_entry(0, fileid_utf8='Asecond-root-id'))
938
self.assertEqual((None, None),
939
state._get_entry(1, fileid_utf8='Asecond-root-id'))
940
923
# should work across save too
1017
1000
[(('', '', root_id), [
1018
1001
('d', '', 0, False, dirstate.DirState.NULLSTAT),
1019
1002
('d', '', 0, False, revid1),
1020
('d', '', 0, False, revid1)
1003
('d', '', 0, False, revid2)
1022
1005
list(state._iter_entries()))
1051
1034
(('', '', root_id), [
1052
1035
('d', '', 0, False, dirstate.DirState.NULLSTAT),
1053
1036
('d', '', 0, False, revid1.encode('utf8')),
1054
('d', '', 0, False, revid1.encode('utf8'))
1037
('d', '', 0, False, revid2.encode('utf8'))
1056
1039
(('', 'a file', 'file-id'), [
1057
1040
('a', '', 0, False, ''),