63
63
A mutable tree always has an associated Branch and ControlDir object - the
64
64
branch and bzrdir attributes.
66
67
def __init__(self, *args, **kw):
67
68
super(MutableTree, self).__init__(*args, **kw)
68
69
# Is this tree on a case-insensitive or case-preserving file-system?
156
157
def commit(self, message=None, revprops=None, *args, **kwargs):
157
158
# avoid circular imports
158
159
from breezy import commit
159
possible_master_transports=[]
160
possible_master_transports = []
160
161
with self.lock_write():
161
162
revprops = commit.Commit.update_revprops(
164
kwargs.pop('authors', None),
165
kwargs.get('local', False),
166
possible_master_transports)
165
kwargs.pop('authors', None),
166
kwargs.get('local', False),
167
possible_master_transports)
167
168
# args for wt.commit start at message from the Commit.commit method,
168
169
args = (message, ) + args
169
170
for hook in MutableTree.hooks['start_commit']:
171
172
committed_id = commit.Commit().commit(working_tree=self,
173
possible_master_transports=possible_master_transports,
174
possible_master_transports=possible_master_transports,
175
176
post_hook_params = PostCommitHookParams(self)
176
177
for hook in MutableTree.hooks['post_commit']:
177
178
hook(post_hook_params)
399
400
hooks.Hooks.__init__(self, "breezy.mutabletree", "MutableTree.hooks")
400
401
self.add_hook('start_commit',
401
"Called before a commit is performed on a tree. The start commit "
402
"hook is able to change the tree before the commit takes place. "
403
"start_commit is called with the breezy.mutabletree.MutableTree "
404
"that the commit is being performed on.", (1, 4))
402
"Called before a commit is performed on a tree. The start commit "
403
"hook is able to change the tree before the commit takes place. "
404
"start_commit is called with the breezy.mutabletree.MutableTree "
405
"that the commit is being performed on.", (1, 4))
405
406
self.add_hook('post_commit',
406
"Called after a commit is performed on a tree. The hook is "
407
"called with a breezy.mutabletree.PostCommitHookParams object. "
408
"The mutable tree the commit was performed on is available via "
409
"the mutable_tree attribute of that object.", (2, 0))
407
"Called after a commit is performed on a tree. The hook is "
408
"called with a breezy.mutabletree.PostCommitHookParams object. "
409
"The mutable tree the commit was performed on is available via "
410
"the mutable_tree attribute of that object.", (2, 0))
410
411
self.add_hook('pre_transform',
411
"Called before a tree transform on this tree. The hook is called "
412
"with the tree that is being transformed and the transform.",
412
"Called before a tree transform on this tree. The hook is called "
413
"with the tree that is being transformed and the transform.",
414
415
self.add_hook('post_build_tree',
415
"Called after a completely new tree is built. The hook is "
416
"called with the tree as its only argument.", (2, 5))
416
"Called after a completely new tree is built. The hook is "
417
"called with the tree as its only argument.", (2, 5))
417
418
self.add_hook('post_transform',
418
"Called after a tree transform has been performed on a tree. "
419
"The hook is called with the tree that is being transformed and "
419
"Called after a tree transform has been performed on a tree. "
420
"The hook is called with the tree that is being transformed and "
423
425
# install the default hooks into the MutableTree class.
424
426
MutableTree.hooks = MutableTreeHooks()