64
63
A mutable tree always has an associated Branch and ControlDir object - the
65
64
branch and bzrdir attributes.
67
67
def __init__(self, *args, **kw):
68
68
super(MutableTree, self).__init__(*args, **kw)
69
69
# Is this tree on a case-insensitive or case-preserving file-system?
89
89
Note that the command line normally calls smart_add instead,
90
90
which can automatically recurse.
92
This adds the files to the inventory, so that they will be
92
This adds the files to the tree, so that they will be
93
93
recorded by the next commit.
95
95
:param files: List of paths to add, relative to the base of the tree.
157
157
def commit(self, message=None, revprops=None, *args, **kwargs):
158
158
# avoid circular imports
159
159
from breezy import commit
160
possible_master_transports=[]
160
possible_master_transports = []
161
161
with self.lock_write():
162
162
revprops = commit.Commit.update_revprops(
165
kwargs.pop('authors', None),
166
kwargs.get('local', False),
167
possible_master_transports)
165
kwargs.pop('authors', None),
166
kwargs.get('local', False),
167
possible_master_transports)
168
168
# args for wt.commit start at message from the Commit.commit method,
169
169
args = (message, ) + args
170
170
for hook in MutableTree.hooks['start_commit']:
172
172
committed_id = commit.Commit().commit(working_tree=self,
174
possible_master_transports=possible_master_transports,
174
possible_master_transports=possible_master_transports,
176
176
post_hook_params = PostCommitHookParams(self)
177
177
for hook in MutableTree.hooks['post_commit']:
178
178
hook(post_hook_params)
308
308
raise NotImplementedError(self.mkdir)
310
def _observed_sha1(self, file_id, path, sha_and_stat):
310
def _observed_sha1(self, path, sha_and_stat):
311
311
"""Tell the tree we have observed a paths sha1.
313
313
The intent of this function is to allow trees that have a hashcache to
318
318
The default implementation does nothing.
320
:param file_id: The file id
321
320
:param path: The file path
322
321
:param sha_and_stat: The sha 1 and stat result observed.
326
def put_file_bytes_non_atomic(self, path, bytes, file_id=None):
325
def put_file_bytes_non_atomic(self, path, bytes):
327
326
"""Update the content of a file in the tree.
329
328
Note that the file is written in-place rather than being
357
356
This is designed more towards DWIM for humans than API clarity.
358
357
For the specific behaviour see the help for cmd_add().
360
:param file_list: List of zero or more paths. *NB: these are
361
interpreted relative to the process cwd, not relative to the
359
:param file_list: List of zero or more paths. *NB: these are
360
interpreted relative to the process cwd, not relative to the
362
361
tree.* (Add and most other tree methods use tree-relative
364
:param action: A reporter to be called with the inventory, parent_ie,
363
:param action: A reporter to be called with the working tree, parent_ie,
365
364
path and kind of the path being added. It may return a file_id if
366
365
a specific one should be used.
367
:param save: Save the inventory after completing the adds. If False
366
:param save: Save the changes after completing the adds. If False
368
367
this provides dry-run functionality by doing the add and not saving
370
369
:return: A tuple - files_added, ignored_files. files_added is the count
371
370
of added files, and ignored_files is a dict mapping files that were
372
371
ignored to the rule that caused them to be ignored.
418
417
hooks.Hooks.__init__(self, "breezy.mutabletree", "MutableTree.hooks")
419
418
self.add_hook('start_commit',
420
"Called before a commit is performed on a tree. The start commit "
421
"hook is able to change the tree before the commit takes place. "
422
"start_commit is called with the breezy.mutabletree.MutableTree "
423
"that the commit is being performed on.", (1, 4))
419
"Called before a commit is performed on a tree. The start commit "
420
"hook is able to change the tree before the commit takes place. "
421
"start_commit is called with the breezy.mutabletree.MutableTree "
422
"that the commit is being performed on.", (1, 4))
424
423
self.add_hook('post_commit',
425
"Called after a commit is performed on a tree. The hook is "
426
"called with a breezy.mutabletree.PostCommitHookParams object. "
427
"The mutable tree the commit was performed on is available via "
428
"the mutable_tree attribute of that object.", (2, 0))
424
"Called after a commit is performed on a tree. The hook is "
425
"called with a breezy.mutabletree.PostCommitHookParams object. "
426
"The mutable tree the commit was performed on is available via "
427
"the mutable_tree attribute of that object.", (2, 0))
429
428
self.add_hook('pre_transform',
430
"Called before a tree transform on this tree. The hook is called "
431
"with the tree that is being transformed and the transform.",
429
"Called before a tree transform on this tree. The hook is called "
430
"with the tree that is being transformed and the transform.",
433
432
self.add_hook('post_build_tree',
434
"Called after a completely new tree is built. The hook is "
435
"called with the tree as its only argument.", (2, 5))
433
"Called after a completely new tree is built. The hook is "
434
"called with the tree as its only argument.", (2, 5))
436
435
self.add_hook('post_transform',
437
"Called after a tree transform has been performed on a tree. "
438
"The hook is called with the tree that is being transformed and "
436
"Called after a tree transform has been performed on a tree. "
437
"The hook is called with the tree that is being transformed and "
442
442
# install the default hooks into the MutableTree class.
443
443
MutableTree.hooks = MutableTreeHooks()