/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

  • Committer: Martin Pool
  • Date: 2007-04-01 06:19:16 UTC
  • mfrom: (2323.5.20 0.15-integration)
  • mto: This revision was merged to the branch mainline in revision 2390.
  • Revision ID: mbp@sourcefrog.net-20070401061916-plpgsxdf8g7gll9o
Merge 0.15 final release back to trunk, including: recommend upgrades of old workingtrees, handle multiple http redirections, some dirstate fixes, 

Show diffs side-by-side

added added

removed removed

Lines of Context:
143
143
        """
144
144
        raise NotImplementedError(self._add)
145
145
 
146
 
    @needs_tree_write_lock
147
 
    def apply_inventory_delta(self, changes):
148
 
        """Apply changes to the inventory as an atomic operation.
149
 
 
150
 
        The argument is a set of changes to apply.  It must describe a
151
 
        valid result, but the order is not important.  Specifically,
152
 
        intermediate stages *may* be invalid, such as when two files
153
 
        swap names.
154
 
 
155
 
        The changes should be structured as a list of tuples, of the form
156
 
        (old_path, new_path, file_id, new_entry).  For creation, old_path
157
 
        must be None.  For deletion, new_path and new_entry must be None.
158
 
        file_id is always non-None.  For renames and other mutations, all
159
 
        values must be non-None.
160
 
 
161
 
        If the new_entry is a directory, its children should be an empty
162
 
        dict.  Children are handled by apply_inventory_delta itself.
163
 
 
164
 
        :param changes: A list of tuples for the change to apply:
165
 
            [(old_path, new_path, file_id, new_inventory_entry), ...]
166
 
        """
167
 
        self.flush()
168
 
        inv = self.inventory
169
 
        children = {}
170
 
        for old_path, file_id in sorted(((op, f) for op, np, f, e in changes
171
 
                                        if op is not None), reverse=True):
172
 
            if file_id not in inv:
173
 
                continue
174
 
            children[file_id] = getattr(inv[file_id], 'children', {})
175
 
            inv.remove_recursive_id(file_id)
176
 
        for new_path, new_entry in sorted((np, e) for op, np, f, e in
177
 
                                          changes if np is not None):
178
 
            if getattr(new_entry, 'children', None) is not None:
179
 
                new_entry.children = children.get(new_entry.file_id, {})
180
 
            inv.add(new_entry)
181
 
        self._write_inventory(inv)
182
 
 
183
146
    @needs_write_lock
184
147
    def commit(self, message=None, revprops=None, *args,
185
148
               **kwargs):