/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

Add convenience method for getting missing objects iterator.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
        self._cache = lru_cache.LRUSizeCache(max_size=MAX_TREE_CACHE_SIZE,
72
72
            after_cleanup_size=None, compute_size=approx_tree_size)
73
73
 
74
 
    def revision_tree(self, revid):
 
74
    def revision_tree(self, revid):            
75
75
        try:
76
 
            tree = self._cache[revid]
 
76
            return self._cache[revid] 
77
77
        except KeyError:
78
78
            tree = self.repository.revision_tree(revid)
79
79
            self.add(tree)
80
 
        assert tree.get_revision_id() == tree.inventory.revision_id
81
 
        return tree
 
80
            return tree
82
81
 
83
82
    def iter_revision_trees(self, revids):
84
 
        trees = {}
85
 
        todo = []
86
 
        for revid in revids:
87
 
            try:
88
 
                tree = self._cache[revid]
89
 
            except KeyError:
90
 
                todo.append(revid)
91
 
            else:
92
 
                assert tree.get_revision_id() == revid
93
 
                assert tree.inventory.revision_id == revid
94
 
                trees[revid] = tree
95
 
        for tree in self.repository.revision_trees(todo):
 
83
        trees = dict([(k, self._cache.get(k)) for k in revids]) 
 
84
        for tree in self.repository.revision_trees(
 
85
                [r for r, v in trees.iteritems() if v is None]):
96
86
            trees[tree.get_revision_id()] = tree
97
87
            self.add(tree)
98
88
        return (trees[r] for r in revids)
185
175
                    pie.symlink_target == ie.symlink_target):
186
176
                    return pie
187
177
        raise KeyError
188
 
 
 
178
    
189
179
    # Find all the changed blobs
190
180
    for (file_id, path, changed_content, versioned, parent, name, kind,
191
181
         executable) in tree.iter_changes(base_tree):
235
225
    for path in unusual_modes:
236
226
        parent_path = posixpath.dirname(path)
237
227
        new_trees[parent_path] = tree.path2id(parent_path)
238
 
 
 
228
    
239
229
    trees = {}
240
230
    while new_trees:
241
231
        items = new_trees.items()
408
398
        updater = self._get_updater(rev)
409
399
        for path, obj, ie in self._revision_to_objects(rev, tree,
410
400
            roundtrip=True):
411
 
            updater.add_object(obj, ie, path)
 
401
            updater.add_object(obj, ie)
412
402
        commit_obj = updater.finish()
413
403
        return commit_obj.id
414
404
 
512
502
            if type == "commit":
513
503
                return self.repository.has_revision(type_data[0])
514
504
            elif type == "blob":
515
 
                return self.repository.texts.has_key(type_data)
 
505
                return self.repository.texts.has_version(type_data)
516
506
            elif type == "tree":
517
507
                return self.repository.has_revision(type_data[1])
518
508
            else:
521
511
            return False
522
512
 
523
513
    def lookup_git_shas(self, shas, update_map=True):
524
 
        from dulwich.protocol import ZERO_SHA
525
514
        ret = {}
526
515
        for sha in shas:
527
 
            if sha == ZERO_SHA:
528
 
                ret[sha] = ("commit", (NULL_REVISION, None))
529
 
                continue
530
516
            try:
531
517
                ret[sha] = self._cache.idmap.lookup_git_sha(sha)
532
518
            except KeyError: