410
410
state = dirstate.DirState.on_file('dirstate')
411
411
self.assertEqual(expected_rows, list(state._iter_rows()))
413
def test_add_symlink_to_root_no_parents_all_data(self):
414
# The most trivial addition of a symlink when there are no parents and
415
# its in the root and all data about the file is supplied
416
state = dirstate.DirState.initialize('dirstate')
417
## TODO: windows: dont fail this test. Also, how are symlinks meant to
418
# be represented on windows.
419
os.symlink('target', 'a link')
420
stat = os.lstat('a link')
421
state.add('a link', 'a link id', 'symlink', stat, 'target')
422
# having added it, it should be in the output of iter_rows.
424
(('', '', 'directory', 'TREE_ROOT', 0, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', ''), []),
425
(('', 'a link', 'symlink', 'a link id', 6, dirstate.pack_stat(stat), 'target'), []),
427
self.assertEqual(expected_rows, list(state._iter_rows()))
428
# saving and reloading should not affect this.
430
state = dirstate.DirState.on_file('dirstate')
431
self.assertEqual(expected_rows, list(state._iter_rows()))
433
def test_add_directory_and_child_no_parents_all_data(self):
434
# after adding a directory, we should be able to add children to it.
435
state = dirstate.DirState.initialize('dirstate')
436
self.build_tree(['a dir/', 'a dir/a file'])
437
stat = os.lstat('a dir')
438
state.add('a dir', 'a dir id', 'directory', stat, None)
439
filestat = os.lstat('a dir/a file')
440
state.add('a dir/a file', 'a file id', 'file', filestat, '1'*20)
441
# having added it, it should be in the output of iter_rows.
443
(('', '', 'directory', 'TREE_ROOT', 0, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', ''), []),
444
(('', 'a dir', 'directory', 'a dir id', 0, dirstate.pack_stat(stat), ''), []),
445
(('a dir', 'a file', 'file', 'a file id', 25, dirstate.pack_stat(filestat), '1'*20), []),
447
self.assertEqual(expected_rows, list(state._iter_rows()))
448
# saving and reloading should not affect this.
450
state = dirstate.DirState.on_file('dirstate')
451
self.assertEqual(expected_rows, list(state._iter_rows()))
414
454
class TestGetLines(TestCaseWithTransport):