63
62
self.build_tree(['target/', 'target/foo'])
64
63
self.assertRaises(errors.BzrError, export.export, wt, 'target', format="dir")
65
def test_dir_export_existing_single_file(self):
66
self.build_tree(['dir1/', 'dir1/dir2/', 'dir1/first', 'dir1/dir2/second'])
67
wtree = self.make_branch_and_tree('dir1')
68
wtree.add(['dir2', 'first', 'dir2/second'])
70
export.export(wtree, 'target1', format='dir', subdir='first')
71
self.failUnlessExists('target1/first')
72
export.export(wtree, 'target2', format='dir', subdir='dir2/second')
73
self.failUnlessExists('target2/second')
75
def test_dir_export_files_same_timestamp(self):
76
builder = self.make_branch_builder('source')
77
builder.start_series()
78
builder.build_snapshot(None, None, [
79
('add', ('', 'root-id', 'directory', '')),
80
('add', ('a', 'a-id', 'file', 'content\n'))])
81
builder.build_snapshot(None, None, [
82
('add', ('b', 'b-id', 'file', 'content\n'))])
83
builder.finish_series()
84
b = builder.get_branch()
86
self.addCleanup(b.unlock)
88
orig_iter_files_bytes = tree.iter_files_bytes
89
# Make iter_files_bytes slower, so we provoke mtime skew
90
def iter_files_bytes(to_fetch):
91
for thing in orig_iter_files_bytes(to_fetch):
94
tree.iter_files_bytes = iter_files_bytes
95
export.export(tree, 'target', format='dir')
96
t = self.get_transport('target')
99
# All files must be given the same mtime.
100
self.assertEqual(st_a.st_mtime, st_b.st_mtime)
102
def test_dir_export_files_per_file_timestamps(self):
103
builder = self.make_branch_builder('source')
104
builder.start_series()
105
builder.build_snapshot(None, None, [
106
('add', ('', 'root-id', 'directory', '')),
107
('add', ('a', 'a-id', 'file', 'content\n'))],
109
builder.build_snapshot(None, None, [
110
('add', ('b', 'b-id', 'file', 'content\n'))],
112
builder.finish_series()
113
b = builder.get_branch()
115
self.addCleanup(b.unlock)
116
tree = b.basis_tree()
117
export.export(tree, 'target', format='dir', per_file_timestamps=True)
118
t = self.get_transport('target')
121
self.assertEqual(42.0, st_b.st_mtime)
122
self.assertEqual(3423.0, st_a.st_mtime)