84
84
wt.add(['a', 'b', 'b/c'])
86
86
self.build_tree(['target/', 'target/foo'])
87
self.assertRaises(errors.BzrError,
88
export.export, wt, 'target', format="dir")
87
self.assertRaises(errors.BzrError, export.export, wt, 'target', format="dir")
90
89
def test_existing_single_file(self):
92
'dir1/', 'dir1/dir2/', 'dir1/first', 'dir1/dir2/second'])
90
self.build_tree(['dir1/', 'dir1/dir2/', 'dir1/first', 'dir1/dir2/second'])
93
91
wtree = self.make_branch_and_tree('dir1')
94
92
wtree.add(['dir2', 'first', 'dir2/second'])
112
110
self.addCleanup(b.unlock)
113
111
tree = b.basis_tree()
114
112
orig_iter_files_bytes = tree.iter_files_bytes
116
113
# Make iter_files_bytes slower, so we provoke mtime skew
117
114
def iter_files_bytes(to_fetch):
118
115
for thing in orig_iter_files_bytes(to_fetch):
149
146
self.assertEqual(a_time, t.stat('a').st_mtime)
150
147
self.assertEqual(b_time, t.stat('b').st_mtime)
152
def test_subdir_files_per_timestamps(self):
153
builder = self.make_branch_builder('source')
154
builder.start_series()
155
foo_time = time.mktime((1999, 12, 12, 0, 0, 0, 0, 0, 0))
156
builder.build_snapshot(None, None, [
157
('add', ('', 'root-id', 'directory', '')),
158
('add', ('subdir', 'subdir-id', 'directory', '')),
159
('add', ('subdir/foo.txt', 'foo-id', 'file', 'content\n'))],
161
builder.finish_series()
162
b = builder.get_branch()
164
self.addCleanup(b.unlock)
165
tree = b.basis_tree()
166
export.export(tree, 'target', format='dir', subdir='subdir',
167
per_file_timestamps=True)
168
t = self.get_transport('target')
169
self.assertEquals(foo_time, t.stat('foo.txt').st_mtime)
172
150
class TarExporterTests(tests.TestCaseWithTransport):
242
220
self.assertRaises(errors.BzrError, export.export, wt, '-',
245
def test_export_tarball_generator(self):
223
def test_export_tarball(self):
246
224
wt = self.make_branch_and_tree('.')
247
225
self.build_tree(['a'])
251
229
ball = tarfile.open(None, "w|", target)
254
for _ in export_tarball_generator(wt, ball, "bar"):
232
export_tarball(wt, ball, "bar")
258
# Ball should now be closed.
260
ball2 = tarfile.open(None, "r", target)
261
self.addCleanup(ball2.close)
262
self.assertEquals(["bar/a"], ball2.getnames())
235
self.assertEquals(["bar/a"], ball.getnames())
265
239
class ZipExporterTests(tests.TestCaseWithTransport):