/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/mutabletree.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-02 02:35:46 UTC
  • mfrom: (7309 work)
  • mto: This revision was merged to the branch mainline in revision 7319.
  • Revision ID: jelmer@jelmer.uk-20190602023546-lqco868tnv26d8ow
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
from .sixish import (
33
33
    text_type,
34
 
    viewvalues,
35
34
    )
36
35
 
37
36
 
64
63
    A mutable tree always has an associated Branch and ControlDir object - the
65
64
    branch and bzrdir attributes.
66
65
    """
 
66
 
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.
91
91
 
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.
94
94
 
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(
163
 
                    revprops,
164
 
                    self.branch,
165
 
                    kwargs.pop('authors', None),
166
 
                    kwargs.get('local', False),
167
 
                    possible_master_transports)
 
163
                revprops,
 
164
                self.branch,
 
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']:
171
171
                hook(self)
172
172
            committed_id = commit.Commit().commit(working_tree=self,
173
 
                revprops=revprops,
174
 
                possible_master_transports=possible_master_transports,
175
 
                *args, **kwargs)
 
173
                                                  revprops=revprops,
 
174
                                                  possible_master_transports=possible_master_transports,
 
175
                                                  *args, **kwargs)
176
176
            post_hook_params = PostCommitHookParams(self)
177
177
            for hook in MutableTree.hooks['post_commit']:
178
178
                hook(post_hook_params)
289
289
        """
290
290
        raise NotImplementedError(self.mkdir)
291
291
 
292
 
    def _observed_sha1(self, file_id, path, sha_and_stat):
 
292
    def _observed_sha1(self, path, sha_and_stat):
293
293
        """Tell the tree we have observed a paths sha1.
294
294
 
295
295
        The intent of this function is to allow trees that have a hashcache to
299
299
 
300
300
        The default implementation does nothing.
301
301
 
302
 
        :param file_id: The file id
303
302
        :param path: The file path
304
303
        :param sha_and_stat: The sha 1 and stat result observed.
305
304
        :return: None
306
305
        """
307
306
 
308
 
    def put_file_bytes_non_atomic(self, path, bytes, file_id=None):
 
307
    def put_file_bytes_non_atomic(self, path, bytes):
309
308
        """Update the content of a file in the tree.
310
309
 
311
310
        Note that the file is written in-place rather than being
339
338
        This is designed more towards DWIM for humans than API clarity.
340
339
        For the specific behaviour see the help for cmd_add().
341
340
 
342
 
        :param file_list: List of zero or more paths.  *NB: these are 
343
 
            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
344
343
            tree.*  (Add and most other tree methods use tree-relative
345
344
            paths.)
346
 
        :param action: A reporter to be called with the inventory, parent_ie,
 
345
        :param action: A reporter to be called with the working tree, parent_ie,
347
346
            path and kind of the path being added. It may return a file_id if
348
347
            a specific one should be used.
349
 
        :param save: Save the inventory after completing the adds. If False
 
348
        :param save: Save the changes after completing the adds. If False
350
349
            this provides dry-run functionality by doing the add and not saving
351
 
            the inventory.
 
350
            the changes.
352
351
        :return: A tuple - files_added, ignored_files. files_added is the count
353
352
            of added files, and ignored_files is a dict mapping files that were
354
353
            ignored to the rule that caused them to be ignored.
399
398
        """
400
399
        hooks.Hooks.__init__(self, "breezy.mutabletree", "MutableTree.hooks")
401
400
        self.add_hook('start_commit',
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))
 
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))
406
405
        self.add_hook('post_commit',
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))
 
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))
411
410
        self.add_hook('pre_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
 
            (2, 5))
 
411
                      "Called before a tree transform on this tree. The hook is called "
 
412
                      "with the tree that is being transformed and the transform.",
 
413
                      (2, 5))
415
414
        self.add_hook('post_build_tree',
416
 
            "Called after a completely new tree is built. The hook is "
417
 
            "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))
418
417
        self.add_hook('post_transform',
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 "
421
 
            "the transform.",
422
 
            (2, 5))
 
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 "
 
420
                      "the transform.",
 
421
                      (2, 5))
 
422
 
423
423
 
424
424
# install the default hooks into the MutableTree class.
425
425
MutableTree.hooks = MutableTreeHooks()