36
34
self.failUnlessExists('target/a/b')
37
35
self.failIfExists('target/a/c')
39
def test_dir_export_symlink(self):
40
self.requireFeature(tests.SymlinkFeature)
41
wt = self.make_branch_and_tree('.')
42
os.symlink('source', 'link')
44
export.export(wt, 'target', format="dir")
45
self.failUnlessExists('target/link')
47
def test_dir_export_to_existing_empty_dir_success(self):
48
self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
49
wt = self.make_branch_and_tree('source')
50
wt.add(['a', 'b', 'b/c'])
52
self.build_tree(['target/'])
53
export.export(wt, 'target', format="dir")
54
self.failUnlessExists('target/a')
55
self.failUnlessExists('target/b')
56
self.failUnlessExists('target/b/c')
58
def test_dir_export_to_existing_nonempty_dir_fail(self):
59
self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
60
wt = self.make_branch_and_tree('source')
61
wt.add(['a', 'b', 'b/c'])
63
self.build_tree(['target/', 'target/foo'])
64
self.assertRaises(errors.BzrError, export.export, wt, 'target', format="dir")
66
def test_dir_export_existing_single_file(self):
67
self.build_tree(['dir1/', 'dir1/dir2/', 'dir1/first', 'dir1/dir2/second'])
68
wtree = self.make_branch_and_tree('dir1')
69
wtree.add(['dir2', 'first', 'dir2/second'])
71
export.export(wtree, 'target1', format='dir', subdir='first')
72
self.failUnlessExists('target1/first')
73
export.export(wtree, 'target2', format='dir', subdir='dir2/second')
74
self.failUnlessExists('target2/second')
76
def test_dir_export_files_same_timestamp(self):
77
builder = self.make_branch_builder('source')
78
builder.start_series()
79
builder.build_snapshot(None, None, [
80
('add', ('', 'root-id', 'directory', '')),
81
('add', ('a', 'a-id', 'file', 'content\n'))])
82
builder.build_snapshot(None, None, [
83
('add', ('b', 'b-id', 'file', 'content\n'))])
84
builder.finish_series()
85
b = builder.get_branch()
87
self.addCleanup(b.unlock)
89
orig_iter_files_bytes = tree.iter_files_bytes
90
# Make iter_files_bytes slower, so we provoke mtime skew
91
def iter_files_bytes(to_fetch):
92
for thing in orig_iter_files_bytes(to_fetch):
95
tree.iter_files_bytes = iter_files_bytes
96
export.export(tree, 'target', format='dir')
97
t = self.get_transport('target')
100
# All files must be given the same mtime.
101
self.assertEqual(st_a.st_mtime, st_b.st_mtime)