66
67
tree_a = self.make_branch_and_tree('a')
67
68
self.build_tree(['a/dir/', 'a/dir/f1', 'a/dir/f2', 'a/dir2/'])
68
69
tree_a.add(['dir', 'dir/f1', 'dir/f2', 'dir2'])
69
dir2_id = tree_a.path2id('dir2')
70
f1_id = tree_a.path2id('dir/f1')
71
70
rev_id1 = tree_a.commit('init')
71
revtree = tree_a.branch.repository.revision_tree(rev_id1)
72
72
# Rename one entry out of this directory
73
73
tree_a.rename_one('dir/f1', 'dir2/a')
74
74
osutils.rmtree('a/dir')
75
75
tree_a.commit('autoremoved')
77
with tree_a.lock_read():
78
root_id = tree_a.get_root_id()
79
paths = [(path, ie.file_id)
80
for path, ie in tree_a.iter_entries_by_dir()]
81
77
# The only paths left should be the root
82
self.assertEqual([('', root_id),
79
tree_a, HasPathRelations(
81
[('', ''), ('dir2/', 'dir2/'), ('dir2/a', 'dir/f1')]))
87
83
def test_no_autodelete_alternate_renamed(self):
88
84
# Test for bug #114615
89
85
tree_a = self.make_branch_and_tree('A')
90
86
self.build_tree(['A/a/', 'A/a/m', 'A/a/n'])
91
87
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')
95
88
tree_a.commit('init')
97
with tree_a.lock_read():
98
root_id = tree_a.get_root_id()
100
90
tree_b = tree_a.controldir.sprout('B').open_workingtree()
101
91
self.build_tree(['B/xyz/'])
102
92
tree_b.add(['xyz'])
103
xyz_id = tree_b.path2id('xyz')
104
93
tree_b.rename_one('a/m', 'xyz/m')
105
94
osutils.rmtree('B/a')
106
95
tree_b.commit('delete in B')
108
paths = [(path, ie.file_id)
109
for path, ie in tree_b.iter_entries_by_dir()]
110
self.assertEqual([('', root_id),
100
tree_a, [('', ''), ('xyz/', None), ('xyz/m', 'a/m')]))
115
102
self.build_tree_contents([('A/a/n', b'new contents for n\n')])
116
103
tree_a.commit('change n in A')
119
106
# (in A) and removed (in B), so 'a' needs to be restored.
120
107
num_conflicts = tree_b.merge_from_branch(tree_a.branch)
121
108
self.assertEqual(3, num_conflicts)
122
paths = [(path, ie.file_id)
123
for path, ie in tree_b.iter_entries_by_dir()]
124
self.assertEqual([('', root_id),
111
tree_b, HasPathRelations(
113
[('', ''), ('a/', 'a/'), ('xyz/', None),
114
('a/n.OTHER', 'a/n'), ('xyz/m', 'a/m')]))
130
116
osutils.rmtree('B/a')
132
118
# bzr resolve --all
138
124
tree_b.commit('autoremove a, without touching xyz/m')
139
paths = [(path, ie.file_id)
140
for path, ie in tree_b.iter_entries_by_dir()]
141
self.assertEqual([('', root_id),
127
tree_b, HasPathRelations(
129
[('', ''), ('xyz/', None), ('xyz/m', 'a/m')]))
146
131
def test_commit_exclude_pending_merge_fails(self):
147
132
"""Excludes are a form of partial commit."""
174
159
self.addCleanup(tree.unlock)
175
160
changes = list(tree.iter_changes(tree.basis_tree()))
176
self.assertEqual(2, len(changes))
177
self.assertEqual((None, 'b'), changes[0][1])
178
self.assertEqual((None, 'c'), changes[1][1])
161
self.assertEqual([(None, 'b'), (None, 'c')], [c[1] for c in changes])
180
163
def test_commit_exclude_subtree_of_selected(self):
181
164
tree = self.make_branch_and_tree('.')
182
self.build_tree(['a/', 'a/b'])
165
self.build_tree(['a/', 'a/b', 'a/c'])
183
166
tree.smart_add(['.'])
184
tree.commit('test', specific_files=['a'], exclude=['a/b'])
167
tree.commit('test', specific_files=['a', 'a/c'], exclude=['a/b'])
185
168
# If a/b was excluded it will still be 'added' in status.
187
170
self.addCleanup(tree.unlock)
235
218
wt = self.make_branch_and_tree('.')
236
219
wt.add(['a'], None, ['file'])
237
220
a_id = wt.path2id('a')
221
self.assertEqual('a', wt.id2path(a_id))
238
222
def fail_message(obj):
239
223
raise errors.BzrCommandError("empty commit message")
240
224
self.assertRaises(errors.BzrCommandError, wt.commit,
362
346
this_dir.delete_tree('b')
364
348
wt.commit('commit deleted rename')
365
self.assertTrue(wt.has_id(a_id))
349
self.assertTrue(wt.is_versioned('a'))
366
350
self.assertFalse(wt.has_or_had_id(b_id))
367
351
self.assertFalse(wt.has_or_had_id(c_id))
368
352
self.assertTrue(wt.has_filename('a'))