18
18
from cStringIO import StringIO
21
from bzrlib import branch, bzrdir, errors, ui, workingtree
25
revision as _mod_revision,
22
30
from bzrlib.errors import (NotBranchError, NotVersionedError,
23
31
UnsupportedOperation)
24
32
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
60
68
def update(self, message, count=None, total=None):
61
69
"""See progress.ProgressBar.update()."""
62
70
if self.depth == 1:
63
self._calls.append(("update", count, total))
71
self._calls.append(("update", count, total, message))
66
74
class TestCapturingUI(TestCase):
153
161
tree.commit('foo', rev_id='foo', local=True)
154
162
self.failIf(master.repository.has_revision('foo'))
155
self.assertEqual(None, master.last_revision())
163
self.assertEqual(_mod_revision.NULL_REVISION,
164
(_mod_revision.ensure_null(master.last_revision())))
157
166
def test_record_initial_ghost(self):
158
167
"""The working tree needs to record ghosts during commit."""
345
354
# into the factory for this test - just make the test ui factory
346
355
# pun as a reporter. Then we can check the ordering is right.
347
356
tree.commit('second post', specific_files=['b'])
348
# 9 steps: 1 for rev, 2 for inventory, 1 for finishing. 2 for root
349
# and 6 for inventory files.
350
# 2 steps don't trigger an update, as 'a' and 'c' are not
357
# 4 steps, the first of which is reported 2 times, once per dir
359
[('update', 1, 4, 'Collecting changes [Directory 0] - Stage'),
360
('update', 1, 4, 'Collecting changes [Directory 1] - Stage'),
361
('update', 2, 4, 'Saving data locally - Stage'),
362
('update', 3, 4, 'Updating the working tree - Stage'),
363
('update', 4, 4, 'Running post commit hooks - Stage')],
367
def test_commit_progress_shows_hook_names(self):
368
tree = self.make_branch_and_tree('.')
369
# set a progress bar that captures the calls so we can see what is
371
self.old_ui_factory = ui.ui_factory
372
self.addCleanup(self.restoreDefaults)
373
factory = CapturingUIFactory()
374
ui.ui_factory = factory
375
def a_hook(_, _2, _3, _4, _5, _6):
377
branch.Branch.hooks.install_hook('post_commit', a_hook)
378
branch.Branch.hooks.name_hook(a_hook, 'hook name')
379
tree.commit('first post')
381
[('update', 1, 4, 'Collecting changes [Directory 0] - Stage'),
382
('update', 1, 4, 'Collecting changes [Directory 1] - Stage'),
383
('update', 2, 4, 'Saving data locally - Stage'),
384
('update', 3, 4, 'Updating the working tree - Stage'),
385
('update', 4, 4, 'Running post commit hooks - Stage'),
386
('update', 4, 4, 'Running post commit hooks [hook name] - Stage'),