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
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
505
505
(('', 'a file', 'a-file-id'), # common
506
506
[('f', '', 0, False, dirstate.DirState.NULLSTAT), # current
831
830
def test_set_state_from_inventory_mixed_paths(self):
832
831
tree1 = self.make_branch_and_tree('tree1')
833
832
self.build_tree(['tree1/a/', 'tree1/a/b/', 'tree1/a-b/',
1002
1000
[(('', '', root_id), [
1003
1001
('d', '', 0, False, dirstate.DirState.NULLSTAT),
1004
1002
('d', '', 0, False, revid1),
1005
('d', '', 0, False, revid2)
1003
('d', '', 0, False, revid1)
1007
1005
list(state._iter_entries()))
1036
1034
(('', '', root_id), [
1037
1035
('d', '', 0, False, dirstate.DirState.NULLSTAT),
1038
1036
('d', '', 0, False, revid1.encode('utf8')),
1039
('d', '', 0, False, revid2.encode('utf8'))
1037
('d', '', 0, False, revid1.encode('utf8'))
1041
1039
(('', 'a file', 'file-id'), [
1042
1040
('a', '', 0, False, ''),
1238
1236
self.assertRaises(errors.BzrError,
1239
1237
state.add, '..', 'ass-id', 'directory', None, None)
1239
def test_set_state_with_rename_b_a_bug_395556(self):
1240
# bug 395556 uncovered a bug where the dirstate ends up with a false
1241
# relocation record - in a tree with no parents there should be no
1242
# absent or relocated records. This then leads to further corruption
1243
# when a commit occurs, as the incorrect relocation gathers an
1244
# incorrect absent in tree 1, and future changes go to pot.
1245
tree1 = self.make_branch_and_tree('tree1')
1246
self.build_tree(['tree1/b'])
1249
tree1.add(['b'], ['b-id'])
1250
root_id = tree1.get_root_id()
1251
inv = tree1.inventory
1252
state = dirstate.DirState.initialize('dirstate')
1254
# Set the initial state with 'b'
1255
state.set_state_from_inventory(inv)
1256
inv.rename('b-id', root_id, 'a')
1257
# Set the new state with 'a', which currently corrupts.
1258
state.set_state_from_inventory(inv)
1259
expected_result1 = [('', '', root_id, 'd'),
1260
('', 'a', 'b-id', 'f'),
1263
for entry in state._iter_entries():
1264
values.append(entry[0] + entry[1][0][:1])
1265
self.assertEqual(expected_result1, values)
1242
1272
class TestGetLines(TestCaseWithDirState):