354
354
# into the factory for this test - just make the test ui factory
355
355
# pun as a reporter. Then we can check the ordering is right.
356
356
tree.commit('second post', specific_files=['b'])
357
# 4 steps, the first of which is reported 5 times, once per file
358
# 2 files don't trigger an update, as 'a' and 'c' are not
357
# 5 steps, the first of which is reported 2 times, once per dir
360
358
self.assertEqual(
361
[('update', 1, 4, 'Collecting changes [Entry 0/?] - Stage'),
362
('update', 1, 4, 'Collecting changes [Entry 1/4] - Stage'),
363
('update', 1, 4, 'Collecting changes [Entry 2/4] - Stage'),
364
('update', 1, 4, 'Collecting changes [Entry 3/4] - Stage'),
365
('update', 1, 4, 'Collecting changes [Entry 4/4] - Stage'),
366
('update', 2, 4, 'Saving data locally - Stage'),
367
('update', 3, 4, 'Updating the working tree - Stage'),
368
('update', 4, 4, 'Running post commit hooks - Stage')],
359
[('update', 1, 5, 'Collecting changes [Directory 0] - Stage'),
360
('update', 1, 5, 'Collecting changes [Directory 1] - Stage'),
361
('update', 2, 5, 'Saving data locally - Stage'),
362
('update', 3, 5, 'Running pre_commit hooks - Stage'),
363
('update', 4, 5, 'Updating the working tree - Stage'),
364
('update', 5, 5, 'Running post_commit hooks - Stage')],
372
def test_commit_progress_shows_hook_names(self):
368
def test_commit_progress_shows_post_hook_names(self):
373
369
tree = self.make_branch_and_tree('.')
374
370
# set a progress bar that captures the calls so we can see what is
383
379
branch.Branch.hooks.name_hook(a_hook, 'hook name')
384
380
tree.commit('first post')
385
381
self.assertEqual(
386
[('update', 1, 4, 'Collecting changes [Entry 0/?] - Stage'),
387
('update', 1, 4, 'Collecting changes [Entry 1/1] - Stage'),
388
('update', 2, 4, 'Saving data locally - Stage'),
389
('update', 3, 4, 'Updating the working tree - Stage'),
390
('update', 4, 4, 'Running post commit hooks - Stage'),
391
('update', 4, 4, 'Running post commit hooks [hook name] - Stage'),
382
[('update', 1, 5, 'Collecting changes [Directory 0] - Stage'),
383
('update', 1, 5, 'Collecting changes [Directory 1] - Stage'),
384
('update', 2, 5, 'Saving data locally - Stage'),
385
('update', 3, 5, 'Running pre_commit hooks - Stage'),
386
('update', 4, 5, 'Updating the working tree - Stage'),
387
('update', 5, 5, 'Running post_commit hooks - Stage'),
388
('update', 5, 5, 'Running post_commit hooks [hook name] - Stage'),
393
def test_commit_progress_shows_pre_hook_names(self):
394
tree = self.make_branch_and_tree('.')
395
# set a progress bar that captures the calls so we can see what is
397
self.old_ui_factory = ui.ui_factory
398
self.addCleanup(self.restoreDefaults)
399
factory = CapturingUIFactory()
400
ui.ui_factory = factory
401
def a_hook(_, _2, _3, _4, _5, _6, _7, _8):
403
branch.Branch.hooks.install_hook('pre_commit', a_hook)
404
branch.Branch.hooks.name_hook(a_hook, 'hook name')
405
tree.commit('first post')
407
[('update', 1, 5, 'Collecting changes [Directory 0] - Stage'),
408
('update', 1, 5, 'Collecting changes [Directory 1] - Stage'),
409
('update', 2, 5, 'Saving data locally - Stage'),
410
('update', 3, 5, 'Running pre_commit hooks - Stage'),
411
('update', 3, 5, 'Running pre_commit hooks [hook name] - Stage'),
412
('update', 4, 5, 'Updating the working tree - Stage'),
413
('update', 5, 5, 'Running post_commit hooks - Stage'),