114
113
self.addCleanup(tree.unlock)
115
114
output = StringIO()
116
115
show_pending_merges(tree, output, verbose=True)
117
self.assertEqualDiff('pending merges:\n'
118
' Joe Foo 2007-12-04 another non-ghost\n'
119
' Joe Foo 2007-12-04 [merge] commit with ghost\n'
120
' (ghost) a-ghost-revision\n'
121
' Joe Foo 2007-12-04 a non-ghost\n',
116
self.assertEqualDiff(
118
' Joe Foo 2007-12-04 another non-ghost\n'
119
' Joe Foo 2007-12-04 [merge] commit with ghost\n'
120
' (ghost) a-ghost-revision\n'
121
' Joe Foo 2007-12-04 a non-ghost\n',
124
124
def tests_revision_to_revision(self):
125
125
"""doing a status between two revision trees should work."""
126
126
tree = self.make_branch_and_tree('.')
127
127
r1_id = tree.commit('one', allow_pointless=True)
128
128
r2_id = tree.commit('two', allow_pointless=True)
129
r2_tree = tree.branch.repository.revision_tree(r2_id)
130
129
output = StringIO()
131
show_tree_status(tree, to_file=output,
132
revision=[RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
133
RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
130
show_tree_status(tree, to_file=output, revision=[
131
RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
132
RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
134
133
# return does not matter as long as it did not raise.
140
139
"""Check that creating a StatusHooks instance has the right defaults.
142
141
hooks = _mod_status.StatusHooks()
143
self.assertTrue("post_status" in hooks, "post_status not in %s" % hooks)
142
self.assertTrue("post_status" in hooks,
143
"post_status not in %s" % hooks)
144
144
self.assertTrue("pre_status" in hooks, "pre_status not in %s" % hooks)
146
146
def test_installed_hooks_are_StatusHooks(self):
149
149
# the installed hooks are saved in self._preserved_hooks.
150
150
self.assertIsInstance(self._preserved_hooks[_mod_status][1],
151
_mod_status.StatusHooks)
151
_mod_status.StatusHooks)
153
153
def test_post_status_hook(self):
154
154
"""Ensure that post_status hook is invoked with the right args.
159
159
tree = self.make_branch_and_tree('.')
160
160
r1_id = tree.commit('one', allow_pointless=True)
161
161
r2_id = tree.commit('two', allow_pointless=True)
162
r2_tree = tree.branch.repository.revision_tree(r2_id)
163
162
output = StringIO()
164
show_tree_status(tree, to_file=output,
165
revision=[RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
166
RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
163
show_tree_status(tree, to_file=output, revision=[
164
RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
165
RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
167
166
self.assertLength(1, calls)
168
167
params = calls[0]
169
168
self.assertIsInstance(params, _mod_status.StatusHookParams)
170
169
attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',
171
'show_ids', 'short', 'verbose', 'specific_files']
170
'show_ids', 'short', 'verbose', 'specific_files']
173
172
self.assertTrue(hasattr(params, a),
174
'Attribute "%s" not found in StatusHookParam' % a)
173
'Attribute "%s" not found in StatusHookParam' % a)
176
175
def test_pre_status_hook(self):
177
176
"""Ensure that pre_status hook is invoked with the right args.
182
181
tree = self.make_branch_and_tree('.')
183
182
r1_id = tree.commit('one', allow_pointless=True)
184
183
r2_id = tree.commit('two', allow_pointless=True)
185
r2_tree = tree.branch.repository.revision_tree(r2_id)
186
184
output = StringIO()
187
show_tree_status(tree, to_file=output,
188
revision=[RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
186
tree, to_file=output,
188
RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
189
189
RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
190
190
self.assertLength(1, calls)
191
191
params = calls[0]
192
192
self.assertIsInstance(params, _mod_status.StatusHookParams)
193
193
attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',
194
'show_ids', 'short', 'verbose', 'specific_files']
194
'show_ids', 'short', 'verbose', 'specific_files']
196
196
self.assertTrue(hasattr(params, a),
197
'Attribute "%s" not found in StatusHookParam' % a)
197
'Attribute "%s" not found in StatusHookParam' % a)