56
56
the inventory is empty, just that the tree doesn't have them
59
if not ignore_inv and getattr(tree, 'root_inventory', None):
61
61
[('', tree.root_inventory.root)],
62
62
list(tree.root_inventory.iter_entries()))
69
69
def commit_and_branch(self):
70
70
"""Commit the current tree, and create a second tree"""
71
self.wt.commit('adding a,b', rev_id='r1')
71
r1 = self.wt.commit('adding a,b')
72
72
# Now make sure that 'bzr branch' also preserves the
74
dir2 = self.wt.branch.controldir.sprout('b2', revision_id='r1')
74
dir2 = self.wt.branch.controldir.sprout('b2', revision_id=r1)
75
75
wt2 = dir2.open_workingtree()
76
self.assertEqual(['r1'], wt2.get_parent_ids())
77
self.assertEqual('r1', wt2.branch.last_revision())
76
self.assertEqual([r1], wt2.get_parent_ids())
77
self.assertEqual(r1, wt2.branch.last_revision())
80
80
def test_01_is_executable(self):
81
81
"""Make sure that the tree was created and has the executable bit set"""
89
89
def test_03_after_commit(self):
90
90
"""Commit the change, and check the history"""
91
self.wt.commit('adding a,b', rev_id='r1')
91
r1 = self.wt.commit('adding a,b')
93
rev_tree = self.wt.branch.repository.revision_tree('r1')
93
rev_tree = self.wt.branch.repository.revision_tree(r1)
94
94
self.check_exist(rev_tree)
96
96
def test_04_after_removed(self):
97
97
"""Make sure reverting removed files brings them back correctly"""
98
self.wt.commit('adding a,b', rev_id='r1')
98
r1 = self.wt.commit('adding a,b')
100
100
# Make sure the entries are gone
101
101
os.remove('b1/a')
105
105
# Make sure that revert is able to bring them back,
106
106
# and sets 'a' back to being executable
108
rev_tree = self.wt.branch.repository.revision_tree('r1')
108
rev_tree = self.wt.branch.repository.revision_tree(r1)
110
110
self.wt.revert(['a', 'b'], rev_tree, backups=False)
111
111
self.check_exist(self.wt)
113
113
def test_05_removed_and_committed(self):
114
114
"""Check that reverting to an earlier commit restores them"""
115
self.wt.commit('adding a,b', rev_id='r1')
115
r1 = self.wt.commit('adding a,b')
117
117
# Now remove them again, and make sure that after a
118
118
# commit, they are still marked correctly
119
119
os.remove('b1/a')
120
120
os.remove('b1/b')
121
self.wt.commit('removed', rev_id='r2')
121
r2 = self.wt.commit('removed')
123
123
self.check_empty(self.wt)
125
rev_tree = self.wt.branch.repository.revision_tree('r1')
125
rev_tree = self.wt.branch.repository.revision_tree(r1)
126
126
# Now revert back to the previous commit
127
127
self.wt.revert(old_tree=rev_tree, backups=False)
131
131
def test_06_branch(self):
132
132
"""branch b1=>b2 should preserve the executable bits"""
133
133
# TODO: Maybe this should be a blackbox test
134
wt2 = self.commit_and_branch()
134
wt2, r1 = self.commit_and_branch()
136
136
self.check_exist(wt2)
138
138
def test_07_pull(self):
139
139
"""Test that pull will handle bits correctly"""
140
wt2 = self.commit_and_branch()
140
wt2, r1 = self.commit_and_branch()
142
142
os.remove('b1/a')
143
143
os.remove('b1/b')
144
self.wt.commit('removed', rev_id='r2')
144
r2 = self.wt.commit('removed')
146
146
# now wt2 can pull and the files should be removed
148
148
# Make sure pull will delete the files
149
149
wt2.pull(self.wt.branch)
150
self.assertEqual(['r2'], wt2.get_parent_ids())
151
self.assertEqual('r2', wt2.branch.last_revision())
150
self.assertEqual([r2], wt2.get_parent_ids())
151
self.assertEqual(r2, wt2.branch.last_revision())
152
152
self.check_empty(wt2)
154
154
# Now restore the files on the first branch and commit
155
155
# so that the second branch can pull the changes
156
156
# and make sure that the executable bit has been copied
157
rev_tree = self.wt.branch.repository.revision_tree('r1')
157
rev_tree = self.wt.branch.repository.revision_tree(r1)
158
158
self.wt.revert(old_tree=rev_tree, backups=False)
159
self.wt.commit('resurrected', rev_id='r3')
159
r3 = self.wt.commit('resurrected')
161
161
self.check_exist(self.wt)
163
163
wt2.pull(self.wt.branch)
164
self.assertEqual(['r3'], wt2.get_parent_ids())
165
self.assertEqual('r3', wt2.branch.last_revision())
164
self.assertEqual([r3], wt2.get_parent_ids())
165
self.assertEqual(r3, wt2.branch.last_revision())
166
166
self.check_exist(wt2)
168
168
def test_08_no_op_revert(self):
171
171
The bits shouldn't swap.
173
self.wt.commit('adding a,b', rev_id='r1')
174
rev_tree = self.wt.branch.repository.revision_tree('r1')
173
r1 = self.wt.commit('adding a,b')
174
rev_tree = self.wt.branch.repository.revision_tree(r1)
175
175
self.wt.revert(old_tree=rev_tree, backups=False)
176
176
self.check_exist(self.wt)
180
180
self.wt._is_executable_from_path_and_stat_from_basis
181
181
rev_id1 = self.wt.commit('one')
182
182
rev_tree1 = self.wt.branch.repository.revision_tree(rev_id1)
183
a_executable = rev_tree1.root_inventory[self.a_id].executable
184
b_executable = rev_tree1.root_inventory[self.b_id].executable
183
a_executable = rev_tree1.is_executable('a')
184
b_executable = rev_tree1.is_executable('b')
185
185
self.assertIsNot(None, a_executable)
186
186
self.assertTrue(a_executable)
187
187
self.assertIsNot(None, b_executable)