/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

  • Committer: Jelmer Vernooij
  • Date: 2010-05-04 19:39:04 UTC
  • mto: (0.200.912 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20100504193904-m2wac46pz3xcyr10
Support creating dummy files for empty directories.

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):
 
145
def _tree_to_objects(tree, parent_trees, idmap, unusual_modes, dummy_file_name=None):
146
146
    """Iterate over the objects that were introduced in a revision.
147
147
 
148
148
    :param idmap: id map
149
149
    :param unusual_modes: Unusual file modes
 
150
    :param dummy_file_name: File name to use for dummy files
 
151
        in empty directories. None to skip empty directories
150
152
    :return: Yields (path, object, ie) entries
151
153
    """
152
154
    new_trees = {}
244
246
            elif ie.kind == "directory":
245
247
                # Not all cache backends store the tree information, 
246
248
                # calculate again from scratch
247
 
                ret = directory_to_tree(ie, ie_to_hexsha, unusual_modes)
 
249
                ret = directory_to_tree(ie, ie_to_hexsha, unusual_modes,
 
250
                    dummy_file_name)
248
251
                if ret is None:
249
252
                    return ret
250
253
                return ret.id
254
257
    for path in sorted(trees.keys(), reverse=True):
255
258
        ie = tree.inventory[trees[path]]
256
259
        assert ie.kind == "directory"
257
 
        obj = directory_to_tree(ie, ie_to_hexsha, unusual_modes)
 
260
        obj = directory_to_tree(ie, ie_to_hexsha, unusual_modes,
 
261
            dummy_file_name)
258
262
        if obj is not None:
259
263
            yield path, obj, ie
260
264
            shamap[ie.file_id] = obj.id
338
342
            [p for p in rev.parent_ids if p in present_parents])
339
343
        root_tree = None
340
344
        for path, obj, ie in _tree_to_objects(tree, parent_trees,
341
 
                self._cache.idmap, unusual_modes):
 
345
                self._cache.idmap, unusual_modes, self.mapping.BZR_DUMMY_FILE):
342
346
            yield path, obj, ie
343
347
            if path == "":
344
348
                root_tree = obj
426
430
                        [(entry.file_id, entry.revision, None)]).next().id
427
431
            else:
428
432
                raise AssertionError("unknown entry kind '%s'" % entry.kind)
429
 
        tree = directory_to_tree(inv[fileid], get_ie_sha1, unusual_modes)
 
433
        tree = directory_to_tree(inv[fileid], get_ie_sha1, unusual_modes,
 
434
            self.mapping.BZR_DUMMY_FILE)
430
435
        _check_expected_sha(expected_sha, tree)
431
436
        return tree
432
437