137
136
transform.finalize()
138
137
transform.finalize()
140
def test_create_files_same_timestamp(self):
141
transform, root = self.get_transform()
142
self.wt.lock_tree_write()
143
self.addCleanup(self.wt.unlock)
144
# Roll back the clock, so that we know everything is being set to the
146
transform._creation_mtime = creation_mtime = time.time() - 20.0
147
transform.create_file('content-one',
148
transform.create_path('one', root))
149
time.sleep(1) # *ugly*
150
transform.create_file('content-two',
151
transform.create_path('two', root))
153
fo, st1 = self.wt.get_file_with_stat(None, path='one', filtered=False)
155
fo, st2 = self.wt.get_file_with_stat(None, path='two', filtered=False)
157
# We only guarantee 2s resolution
158
self.assertTrue(abs(creation_mtime - st1.st_mtime) < 2.0,
159
"%s != %s within 2 seconds" % (creation_mtime, st1.st_mtime))
160
# But if we have more than that, all files should get the same result
161
self.assertEqual(st1.st_mtime, st2.st_mtime)
163
def test_change_root_id(self):
164
transform, root = self.get_transform()
165
self.assertNotEqual('new-root-id', self.wt.get_root_id())
166
transform.new_directory('', ROOT_PARENT, 'new-root-id')
167
transform.delete_contents(root)
168
transform.unversion_file(root)
169
transform.fixup_new_roots()
171
self.assertEqual('new-root-id', self.wt.get_root_id())
173
def test_change_root_id_add_files(self):
174
transform, root = self.get_transform()
175
self.assertNotEqual('new-root-id', self.wt.get_root_id())
176
new_trans_id = transform.new_directory('', ROOT_PARENT, 'new-root-id')
177
transform.new_file('file', new_trans_id, ['new-contents\n'],
179
transform.delete_contents(root)
180
transform.unversion_file(root)
181
transform.fixup_new_roots()
183
self.assertEqual('new-root-id', self.wt.get_root_id())
184
self.assertEqual('new-file-id', self.wt.path2id('file'))
185
self.assertFileEqual('new-contents\n', self.wt.abspath('file'))
187
def test_add_two_roots(self):
188
transform, root = self.get_transform()
189
new_trans_id = transform.new_directory('', ROOT_PARENT, 'new-root-id')
190
new_trans_id = transform.new_directory('', ROOT_PARENT, 'alt-root-id')
191
self.assertRaises(ValueError, transform.fixup_new_roots)
193
139
def test_hardlink(self):
194
140
self.requireFeature(HardlinkFeature)
195
141
transform, root = self.get_transform()
2735
2681
preview = self.get_empty_preview()
2736
2682
root = preview.new_directory('', ROOT_PARENT, 'tree-root')
2737
2683
# FIXME: new_directory should mark root.
2738
preview.fixup_new_roots()
2684
preview.adjust_path('', ROOT_PARENT, root)
2739
2685
preview_tree = preview.get_preview_tree()
2740
2686
file_trans_id = preview.new_file('a', preview.root, 'contents',