Rev 2555: Show hook names during commit. in sftp://rookery/~/public_html/baz2.0/commit-hook-names
Robert Collins
robertc at robertcollins.net
Thu Jun 28 04:22:02 BST 2007
At sftp://rookery/~/public_html/baz2.0/commit-hook-names
------------------------------------------------------------
revno: 2555
revision-id: robertc at robertcollins.net-20070628032159-ru3ztg712ns2dpip
parent: robertc at robertcollins.net-20070628030853-fjeb7ii5euyvi7c1
committer: Robert Collins <robertc at robertcollins.net>
branch nick: commit-hook-names
timestamp: Thu 2007-06-28 13:21:59 +1000
message:
Show hook names during commit.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/tests/workingtree_implementations/test_commit.py test_commit.py-20060421013633-1610ec2331c8190f
=== modified file 'NEWS'
--- a/NEWS 2007-06-28 03:08:53 +0000
+++ b/NEWS 2007-06-28 03:21:59 +0000
@@ -38,7 +38,10 @@
If there is no master branch, the 3rd stage is omitted and the total
number of stages is adjusted accordingly.
- (Ian Clatworthy)
+
+ Each hook that is run after commit is listed with a name (as hooks
+ can be slow it is useful feedback).
+ (Ian Clatworthy, Robert Collins)
* Various operations that are now faster due to avoiding unnecessary
topological sorts. (Aaron Bentley)
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py 2007-06-21 00:16:13 +0000
+++ b/bzrlib/commit.py 2007-06-28 03:21:59 +0000
@@ -338,9 +338,6 @@
rev_tree = self.builder.revision_tree()
self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
self.reporter.completed(new_revno, self.rev_id)
-
- # Process the post commit hooks, if any
- self._emit_progress_set_stage("Running post commit hooks")
self._process_hooks(old_revno, new_revno)
finally:
self._cleanup()
@@ -469,6 +466,8 @@
def _process_hooks(self, old_revno, new_revno):
"""Process any registered commit hooks."""
+ # Process the post commit hooks, if any
+ self._emit_progress_set_stage("Running post commit hooks")
# old style commit hooks - should be deprecated ? (obsoleted in
# 0.15)
if self.config.post_commit() is not None:
@@ -494,6 +493,9 @@
else:
old_revid = bzrlib.revision.NULL_REVISION
for hook in Branch.hooks['post_commit']:
+ self.pb_stage_name = "Running post commit hooks [%s]" % \
+ Branch.hooks.get_hook_name(hook)
+ self._emit_progress()
hook(hook_local, hook_master, old_revno, old_revid, new_revno,
self.rev_id)
=== modified file 'bzrlib/tests/workingtree_implementations/test_commit.py'
--- a/bzrlib/tests/workingtree_implementations/test_commit.py 2007-06-20 03:32:32 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_commit.py 2007-06-28 03:21:59 +0000
@@ -359,3 +359,27 @@
('update', 4, 4, 'Running post commit hooks - Stage')],
factory._calls
)
+
+ def test_commit_progress_shows_hook_names(self):
+ tree = self.make_branch_and_tree('.')
+ # set a progress bar that captures the calls so we can see what is
+ # emitted
+ self.old_ui_factory = ui.ui_factory
+ self.addCleanup(self.restoreDefaults)
+ factory = CapturingUIFactory()
+ ui.ui_factory = factory
+ def a_hook(_, _2, _3, _4, _5, _6):
+ pass
+ branch.Branch.hooks.install_hook('post_commit', a_hook)
+ branch.Branch.hooks.name_hook(a_hook, 'hook name')
+ tree.commit('first post')
+ self.assertEqual(
+ [('update', 1, 4, 'Collecting changes [Entry 0/?] - Stage'),
+ ('update', 1, 4, 'Collecting changes [Entry 1/1] - Stage'),
+ ('update', 2, 4, 'Saving data locally - Stage'),
+ ('update', 3, 4, 'Updating the working tree - Stage'),
+ ('update', 4, 4, 'Running post commit hooks - Stage'),
+ ('update', 4, 4, 'Running post commit hooks [hook name] - Stage'),
+ ],
+ factory._calls
+ )
More information about the bazaar-commits
mailing list