/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-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
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)
197
197
            if _from_tree is None:
198
198
                _from_tree = self.basis_tree()
199
199
            changes = self.iter_changes(_from_tree)
200
 
            if osutils.has_symlinks():
 
200
            if self.supports_symlinks():
201
201
                # Fast path for has_changes.
202
202
                try:
203
203
                    change = next(changes)
307
307
        """
308
308
        raise NotImplementedError(self.mkdir)
309
309
 
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.
312
312
 
313
313
        The intent of this function is to allow trees that have a hashcache to
317
317
 
318
318
        The default implementation does nothing.
319
319
 
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.
323
322
        :return: None
324
323
        """
325
324
 
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.
328
327
 
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().
359
358
 
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
363
362
            paths.)
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
369
 
            the inventory.
 
368
            the changes.
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.
417
416
        """
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.",
432
 
            (2, 5))
 
429
                      "Called before a tree transform on this tree. The hook is called "
 
430
                      "with the tree that is being transformed and the transform.",
 
431
                      (2, 5))
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 "
439
 
            "the transform.",
440
 
            (2, 5))
 
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 "
 
438
                      "the transform.",
 
439
                      (2, 5))
 
440
 
441
441
 
442
442
# install the default hooks into the MutableTree class.
443
443
MutableTree.hooks = MutableTreeHooks()