Rev 6436: (jelmer) Add post_build_tree hook to MutableTree. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Jan 6 20:14:36 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6436 [merge]
revision-id: pqm at pqm.ubuntu.com-20120106201436-ko6esavn69wt1lwt
parent: pqm at pqm.ubuntu.com-20120106110523-qli0nvcwczglhfyk
parent: jelmer at samba.org-20120106194641-pzxbo7yopp1rdcz7
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2012-01-06 20:14:36 +0000
message:
(jelmer) Add post_build_tree hook to MutableTree. (Jelmer Vernooij)
modified:
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
bzrlib/plugins/weave_fmt/workingtree.py workingtree_2.py-20110303111903-b6uksp28mf3oo3vp-1
bzrlib/tests/per_workingtree/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
bzrlib/workingtree_3.py workingtree_3.py-20110503234428-nwa1nw7zfdd0hrw8-1
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/mutabletree.py 2012-01-06 14:09:04 +0000
@@ -520,6 +520,9 @@
"called with a bzrlib.mutabletree.PostCommitHookParams object. "
"The mutable tree the commit was performed on is available via "
"the mutable_tree attribute of that object.", (2, 0))
+ self.add_hook('post_build_tree',
+ "Called after a completely new tree is built. The hook is "
+ "called with the tree as its only argument.", (2, 5))
# install the default hooks into the MutableTree class.
=== modified file 'bzrlib/plugins/weave_fmt/workingtree.py'
--- a/bzrlib/plugins/weave_fmt/workingtree.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/plugins/weave_fmt/workingtree.py 2012-01-06 14:09:04 +0000
@@ -30,6 +30,7 @@
xml5,
)
from bzrlib.decorators import needs_read_lock
+from bzrlib.mutabletree import MutableTree
from bzrlib.transport.local import LocalTransport
from bzrlib.workingtree import (
WorkingTreeFormat,
@@ -113,6 +114,8 @@
parent_trees = [(revision_id, basis_tree)]
wt.set_parent_trees(parent_trees)
transform.build_tree(basis_tree, wt)
+ for hook in MutableTree.hooks['post_build_tree']:
+ hook(wt)
return wt
def __init__(self):
=== modified file 'bzrlib/tests/per_workingtree/test_workingtree.py'
--- a/bzrlib/tests/per_workingtree/test_workingtree.py 2011-12-16 17:34:46 +0000
+++ b/bzrlib/tests/per_workingtree/test_workingtree.py 2012-01-06 19:46:41 +0000
@@ -37,6 +37,7 @@
PathsNotVersionedError,
)
from bzrlib.inventory import Inventory
+from bzrlib.mutabletree import MutableTree
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
from bzrlib.tests import (
features,
@@ -451,6 +452,23 @@
revision_id='a')
self.assertEqual(['a'], made_tree.get_parent_ids())
+ def test_post_build_tree_hook(self):
+ calls = []
+ def track_post_build_tree(tree):
+ calls.append(tree.last_revision())
+ source = self.make_branch_and_tree('source')
+ source.commit('a', rev_id='a', allow_pointless=True)
+ source.commit('b', rev_id='b', allow_pointless=True)
+ self.build_tree(['new/'])
+ made_control = self.bzrdir_format.initialize('new')
+ source.branch.repository.clone(made_control)
+ source.branch.clone(made_control)
+ MutableTree.hooks.install_named_hook("post_build_tree",
+ track_post_build_tree, "Test")
+ made_tree = self.workingtree_format.initialize(made_control,
+ revision_id='a')
+ self.assertEqual(['a'], calls)
+
def test_update_sets_last_revision(self):
# working tree formats from the meta-dir format and newer support
# setting the last revision on a tree independently of that on the
=== modified file 'bzrlib/workingtree_3.py'
--- a/bzrlib/workingtree_3.py 2011-12-19 19:15:58 +0000
+++ b/bzrlib/workingtree_3.py 2012-01-06 14:09:04 +0000
@@ -36,6 +36,7 @@
)
from bzrlib.lockable_files import LockableFiles
from bzrlib.lockdir import LockDir
+from bzrlib.mutabletree import MutableTree
from bzrlib.transport.local import LocalTransport
from bzrlib.workingtree import (
InventoryWorkingTree,
@@ -227,6 +228,8 @@
else:
wt.set_parent_trees([(revision_id, basis_tree)])
transform.build_tree(basis_tree, wt)
+ for hook in MutableTree.hooks['post_build_tree']:
+ hook(wt)
finally:
# Unlock in this order so that the unlock-triggers-flush in
# WorkingTree is given a chance to fire.
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2011-12-19 19:15:58 +0000
+++ b/bzrlib/workingtree_4.py 2012-01-06 14:09:04 +0000
@@ -57,7 +57,10 @@
from bzrlib.lock import LogicalLockResult
from bzrlib.lockable_files import LockableFiles
from bzrlib.lockdir import LockDir
-from bzrlib.mutabletree import needs_tree_write_lock
+from bzrlib.mutabletree import (
+ MutableTree,
+ needs_tree_write_lock,
+ )
from bzrlib.osutils import (
file_kind,
isdir,
@@ -1544,6 +1547,8 @@
transform.build_tree(basis, wt, accelerator_tree,
hardlink=hardlink,
delta_from_tree=delta_from_tree)
+ for hook in MutableTree.hooks['post_build_tree']:
+ hook(wt)
finally:
basis.unlock()
finally:
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2012-01-05 16:03:11 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2012-01-06 14:09:04 +0000
@@ -178,6 +178,9 @@
which contains the branch from which the ``other_tree``
was obtained, if any. (Jelmer Vernooij)
+* MutableTree now has a hook ``post_build_tree`` which is called after
+ a new mutable tree has been created. (Jelmer Vernooij, #912765)
+
* New HPSS call ``BzrDir.checkout_metadir``. (Jelmer Vernooij, #894459)
* New HPSS call ``VersionedFileRepository.get_inventories``,
More information about the bazaar-commits
mailing list