Пример #1
0
 def test_commit_progress_steps(self):
     # during commit we one progress update for every entry in the
     # inventory, and then one for the inventory, and one for the
     # inventory, and one for the revision insertions.
     # first we need a test commit to do. Lets setup a branch with
     # 3 files, and alter one in a selected-file commit. This exercises
     # a number of cases quickly. We should also test things like
     # selective commits which excludes newly added files.
     tree = self.make_branch_and_tree('.')
     self.build_tree(['a', 'b', 'c'])
     tree.add(['a', 'b', 'c'])
     tree.commit('first post')
     with open('b', 'wt') as f:
         f.write('new content')
     # set a progress bar that captures the calls so we can see what is
     # emitted
     factory = ProgressRecordingUIFactory()
     ui.ui_factory = factory
     # TODO RBC 20060421 it would be nice to merge the reporter output
     # into the factory for this test - just make the test ui factory
     # pun as a reporter. Then we can check the ordering is right.
     tree.commit('second post', specific_files=['b'])
     # 5 steps, the first of which is reported 2 times, once per dir
     self.assertEqual(
         [('update', 1, 5, 'Collecting changes [0] - Stage'),
          ('update', 1, 5, 'Collecting changes [1] - Stage'),
          ('update', 2, 5, 'Saving data locally - Stage'),
          ('update', 3, 5, 'Running pre_commit hooks - Stage'),
          ('update', 4, 5, 'Updating the working tree - Stage'),
          ('update', 5, 5, 'Running post_commit hooks - Stage')],
         factory._calls)
Пример #2
0
    def test_commit_progress_shows_pre_hook_names(self):
        tree = self.make_branch_and_tree('.')
        # set a progress bar that captures the calls so we can see what is
        # emitted
        factory = ProgressRecordingUIFactory()
        ui.ui_factory = factory

        def a_hook(_, _2, _3, _4, _5, _6, _7, _8):
            pass

        branch.Branch.hooks.install_named_hook('pre_commit', a_hook,
                                               'hook name')
        tree.commit('first post')
        self.assertEqual([
            ('update', 1, 5, 'Collecting changes [0] - Stage'),
            ('update', 1, 5, 'Collecting changes [1] - Stage'),
            ('update', 2, 5, 'Saving data locally - Stage'),
            ('update', 3, 5, 'Running pre_commit hooks - Stage'),
            ('update', 3, 5, 'Running pre_commit hooks [hook name] - Stage'),
            ('update', 4, 5, 'Updating the working tree - Stage'),
            ('update', 5, 5, 'Running post_commit hooks - Stage'),
        ], factory._calls)
Пример #3
0
 def setUp(self):
     super(TestCommitProgress, self).setUp()
     ui.ui_factory = ProgressRecordingUIFactory()