/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 object_store.py

Update docstring, deal with kind changes appropriately in _tree_to_objects

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
            expected_sha))
143
143
 
144
144
 
145
 
def _tree_to_objects(tree, parent_trees, idmap, unusual_modes, dummy_file_name=None):
 
145
def _tree_to_objects(tree, parent_trees, idmap, unusual_modes,
 
146
                     dummy_file_name=None):
146
147
    """Iterate over the objects that were introduced in a revision.
147
148
 
148
149
    :param idmap: id map
149
 
    :param unusual_modes: Unusual file modes
 
150
    :param parent_trees: Parent revision trees
 
151
    :param unusual_modes: Unusual file modes dictionary
150
152
    :param dummy_file_name: File name to use for dummy files
151
153
        in empty directories. None to skip empty directories
152
154
    :return: Yields (path, object, ie) entries
173
175
                    pie.symlink_target == ie.symlink_target):
174
176
                    return pie
175
177
        raise KeyError
 
178
    
 
179
    # Find all the changed blobs
176
180
    for (file_id, path, changed_content, versioned, parent, name, kind,
177
181
         executable) in tree.iter_changes(base_tree):
178
182
        if kind[1] == "file":
206
210
            new_trees[posixpath.dirname(path[1])] = parent[1]
207
211
        elif kind[1] not in (None, "directory"):
208
212
            raise AssertionError(kind[1])
209
 
        if path[0] is not None:
 
213
        if path[0] is not None and parent[0] in tree.inventory and tree.inventory[parent[0]].kind == "directory":
 
214
            # Removal
210
215
            new_trees[posixpath.dirname(path[0])] = parent[0]
211
216
    
 
217
    # Fetch contents of the blobs that were changed
212
218
    for (path, ie), chunks in tree.iter_files_bytes(
213
219
        [(ie.file_id, (path, ie)) for (path, ie) in new_blobs]):
214
220
        obj = Blob()
225
231
        items = new_trees.items()
226
232
        new_trees = {}
227
233
        for path, file_id in items:
228
 
            try:
229
 
                parent_id = tree.inventory[file_id].parent_id
230
 
            except errors.NoSuchId:
231
 
                # Directory was removed recursively perhaps ?
232
 
                continue
 
234
            parent_id = tree.inventory[file_id].parent_id
233
235
            if parent_id is not None:
234
236
                parent_path = urlutils.dirname(path)
235
237
                new_trees[parent_path] = parent_id