/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 bzrlib/mutabletree.py

(broken) merge aaron's workingtree format changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
 
23
23
from bzrlib import (
 
24
    errors,
24
25
    osutils,
25
26
    tree,
26
27
    )
110
111
        self._gather_kinds(files, kinds)
111
112
        self._add(files, ids, kinds)
112
113
 
 
114
    def add_reference(self, sub_tree):
 
115
        """Add a TreeReference to the tree, pointing at sub_tree"""
 
116
        raise errors.UnsupportedOperation(self.add_reference, self)
 
117
 
 
118
    def _add_reference(self, sub_tree):
 
119
        """Standard add_reference implementation, for use by subclasses"""
 
120
        try:
 
121
            sub_tree_path = self.relpath(sub_tree.basedir)
 
122
        except errors.PathNotChild:
 
123
            raise errors.BadReferenceTarget(self, sub_tree,
 
124
                                            'Target not inside tree.')
 
125
        sub_tree_id = sub_tree.get_root_id()
 
126
        if sub_tree_id == self.get_root_id():
 
127
            raise errors.BadReferenceTarget(self, sub_tree,
 
128
                                     'Trees have the same root id.')
 
129
        if sub_tree_id in self.inventory:
 
130
            raise errors.BadReferenceTarget(self, sub_tree,
 
131
                                            'Root id already present in tree')
 
132
        self._add([sub_tree_path], [sub_tree_id], ['tree-reference'])
 
133
 
113
134
    def _add(self, files, ids, kinds):
114
 
        """Helper function for add - updates the inventory."""
 
135
        """Helper function for add - updates the inventory.
 
136
 
 
137
        :param files: sequence of pathnames, relative to the tree root
 
138
        :param ids: sequence of suggested ids for the files (may be None)
 
139
        :param kinds: sequence of  inventory kinds of the files (i.e. may
 
140
            contain "tree-reference")
 
141
        """
115
142
        raise NotImplementedError(self._add)
116
143
 
117
144
    @needs_write_lock
118
 
    def commit(self, message=None, revprops=None, *args, **kwargs):
 
145
    def commit(self, message=None, revprops=None, recursive='down', *args,
 
146
               **kwargs):
 
147
        if recursive == 'down':
 
148
            for tree in self.iter_nested_trees():
 
149
                try:
 
150
                    tree.commit(message, revprops, recursive, *args, **kwargs)
 
151
                except errors.PointlessCommit:
 
152
                    pass
119
153
        # avoid circular imports
120
154
        from bzrlib import commit
121
155
        if revprops is None:
188
222
            parent tree - i.e. a ghost.
189
223
        """
190
224
        raise NotImplementedError(self.set_parent_trees)
 
225
 
 
226
    def iter_nested_trees(self):
 
227
        for path, entry in self.iter_reference_entries():
 
228
            yield self.get_nested_tree(entry, path)