65
65
def test_no_autodelete_renamed_away(self):
66
66
tree_a = self.make_branch_and_tree('a')
67
67
self.build_tree(['a/dir/', 'a/dir/f1', 'a/dir/f2', 'a/dir2/'])
68
tree_a.add(['dir', 'dir/f1', 'dir/f2', 'dir2'],
69
['dir-id', 'f1-id', 'f2-id', 'dir2-id'])
68
tree_a.add(['dir', 'dir/f1', 'dir/f2', 'dir2'])
69
dir2_id = tree_a.path2id('dir2')
70
f1_id = tree_a.path2id('dir/f1')
70
71
rev_id1 = tree_a.commit('init')
71
72
# Rename one entry out of this directory
72
73
tree_a.rename_one('dir/f1', 'dir2/a')
73
74
osutils.rmtree('a/dir')
74
75
tree_a.commit('autoremoved')
77
with tree_a.lock_read():
78
78
root_id = tree_a.get_root_id()
79
79
paths = [(path, ie.file_id)
80
80
for path, ie in tree_a.iter_entries_by_dir()]
83
81
# The only paths left should be the root
84
self.assertEqual([('', root_id), ('dir2', 'dir2-id'),
82
self.assertEqual([('', root_id),
88
87
def test_no_autodelete_alternate_renamed(self):
89
88
# Test for bug #114615
90
89
tree_a = self.make_branch_and_tree('A')
91
90
self.build_tree(['A/a/', 'A/a/m', 'A/a/n'])
92
tree_a.add(['a', 'a/m', 'a/n'], ['a-id', 'm-id', 'n-id'])
91
tree_a.add(['a', 'a/m', 'a/n'])
92
a_id = tree_a.path2id('a')
93
m_id = tree_a.path2id('a/m')
94
n_id = tree_a.path2id('a/n')
93
95
tree_a.commit('init')
97
with tree_a.lock_read():
97
98
root_id = tree_a.get_root_id()
101
100
tree_b = tree_a.controldir.sprout('B').open_workingtree()
102
101
self.build_tree(['B/xyz/'])
103
tree_b.add(['xyz'], ['xyz-id'])
103
xyz_id = tree_b.path2id('xyz')
104
104
tree_b.rename_one('a/m', 'xyz/m')
105
105
osutils.rmtree('B/a')
106
106
tree_b.commit('delete in B')
108
108
paths = [(path, ie.file_id)
109
109
for path, ie in tree_b.iter_entries_by_dir()]
110
110
self.assertEqual([('', root_id),
115
115
self.build_tree_contents([('A/a/n', 'new contents for n\n')])
234
234
def test_commit_aborted_does_not_apply_automatic_changes_bug_282402(self):
235
235
wt = self.make_branch_and_tree('.')
236
wt.add(['a'], ['a-id'], ['file'])
236
wt.add(['a'], None, ['file'])
237
a_id = wt.path2id('a')
237
238
def fail_message(obj):
238
239
raise errors.BzrCommandError("empty commit message")
239
240
self.assertRaises(errors.BzrCommandError, wt.commit,
240
241
message_callback=fail_message)
241
self.assertEqual('a', wt.id2path('a-id'))
242
self.assertEqual('a', wt.id2path(a_id))
243
244
def test_local_commit_ignores_master(self):
244
245
# a --local commit does not require access to the master branch
279
280
def test_record_initial_ghost(self):
280
281
"""The working tree needs to record ghosts during commit."""
281
282
wt = self.make_branch_and_tree('.')
283
if not wt.branch.repository._format.supports_ghosts:
284
raise tests.TestNotApplicable(
285
'format does not support ghosts')
282
286
wt.set_parent_ids(['non:existent@rev--ision--0--2'],
283
287
allow_leftmost_as_ghost=True)
284
288
rev_id = wt.commit('commit against a ghost first parent.')
290
294
def test_record_two_ghosts(self):
291
295
"""The working tree should preserve all the parents during commit."""
292
296
wt = self.make_branch_and_tree('.')
297
if not wt.branch.repository._format.supports_ghosts:
298
raise tests.TestNotApplicable(
299
'format does not support ghosts')
293
300
wt.set_parent_ids([
294
301
'foo@azkhazan-123123-abcabc',
295
302
'wibble@fofof--20050401--1928390812',
307
314
wt = self.make_branch_and_tree('.')
309
316
self.build_tree(['a', 'b/', 'b/c', 'd'])
310
wt.add(['a', 'b', 'b/c', 'd'], ['a-id', 'b-id', 'c-id', 'd-id'])
317
wt.add(['a', 'b', 'b/c', 'd'])
318
a_id = wt.path2id('a')
319
b_id = wt.path2id('b')
320
c_id = wt.path2id('b/c')
321
d_id = wt.path2id('d')
311
322
this_dir = wt.controldir.root_transport
312
323
this_dir.delete_tree('b')
313
324
this_dir.delete('d')
315
326
# a present on disk. After commit b-id, c-id and d-id should be
316
327
# missing from the inventory, within the same tree transaction.
317
328
wt.commit('commit stuff')
318
self.assertTrue(wt.has_id('a-id'))
319
self.assertFalse(wt.has_or_had_id('b-id'))
320
self.assertFalse(wt.has_or_had_id('c-id'))
321
self.assertFalse(wt.has_or_had_id('d-id'))
329
self.assertTrue(wt.has_id(a_id))
330
self.assertFalse(wt.has_or_had_id(b_id))
331
self.assertFalse(wt.has_or_had_id(c_id))
332
self.assertFalse(wt.has_or_had_id(d_id))
322
333
self.assertTrue(wt.has_filename('a'))
323
334
self.assertFalse(wt.has_filename('b'))
324
335
self.assertFalse(wt.has_filename('b/c'))
329
340
wt = wt.controldir.open_workingtree()
331
self.assertTrue(wt.has_id('a-id'))
332
self.assertFalse(wt.has_or_had_id('b-id'))
333
self.assertFalse(wt.has_or_had_id('c-id'))
334
self.assertFalse(wt.has_or_had_id('d-id'))
342
self.assertTrue(wt.has_id(a_id))
343
self.assertFalse(wt.has_or_had_id(b_id))
344
self.assertFalse(wt.has_or_had_id(c_id))
345
self.assertFalse(wt.has_or_had_id(d_id))
335
346
self.assertTrue(wt.has_filename('a'))
336
347
self.assertFalse(wt.has_filename('b'))
337
348
self.assertFalse(wt.has_filename('b/c'))
341
352
def test_commit_deleted_subtree_with_removed(self):
342
353
wt = self.make_branch_and_tree('.')
343
354
self.build_tree(['a', 'b/', 'b/c', 'd'])
344
wt.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
355
wt.add(['a', 'b', 'b/c'])
356
a_id = wt.path2id('a')
357
b_id = wt.path2id('b')
358
c_id = wt.path2id('b/c')
345
359
wt.commit('first')
347
361
this_dir = wt.controldir.root_transport
348
362
this_dir.delete_tree('b')
350
364
wt.commit('commit deleted rename')
351
self.assertTrue(wt.has_id('a-id'))
352
self.assertFalse(wt.has_or_had_id('b-id'))
353
self.assertFalse(wt.has_or_had_id('c-id'))
365
self.assertTrue(wt.has_id(a_id))
366
self.assertFalse(wt.has_or_had_id(b_id))
367
self.assertFalse(wt.has_or_had_id(c_id))
354
368
self.assertTrue(wt.has_filename('a'))
355
369
self.assertFalse(wt.has_filename('b'))
356
370
self.assertFalse(wt.has_filename('b/c'))