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)
289
290
raise NotImplementedError(self.mkdir)
291
def _observed_sha1(self, file_id, path, sha_and_stat):
292
def _observed_sha1(self, path, sha_and_stat):
292
293
"""Tell the tree we have observed a paths sha1.
294
295
The intent of this function is to allow trees that have a hashcache to
338
338
This is designed more towards DWIM for humans than API clarity.
339
339
For the specific behaviour see the help for cmd_add().
341
:param file_list: List of zero or more paths. *NB: these are
342
interpreted relative to the process cwd, not relative to the
341
:param file_list: List of zero or more paths. *NB: these are
342
interpreted relative to the process cwd, not relative to the
343
343
tree.* (Add and most other tree methods use tree-relative
345
345
:param action: A reporter to be called with the working tree, parent_ie,
399
399
hooks.Hooks.__init__(self, "breezy.mutabletree", "MutableTree.hooks")
400
400
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))
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))
405
405
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))
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))
410
410
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.",
411
"Called before a tree transform on this tree. The hook is called "
412
"with the tree that is being transformed and the transform.",
414
414
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))
415
"Called after a completely new tree is built. The hook is "
416
"called with the tree as its only argument.", (2, 5))
417
417
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 "
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 "
423
424
# install the default hooks into the MutableTree class.
424
425
MutableTree.hooks = MutableTreeHooks()