/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

More work on roundtrip push support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
        self._cache.add(tree.get_revision_id(), tree)
109
109
 
110
110
 
111
 
def _find_missing_bzr_revids(graph, want, have):
 
111
def _find_missing_bzr_revids(get_parent_map, want, have):
112
112
    """Find the revisions that have to be pushed.
113
113
 
114
114
    :param get_parent_map: Function that returns the parents for a sequence
117
117
    :param have: Revisions the target already has
118
118
    :return: Set of revisions to fetch
119
119
    """
 
120
    pending = want - have
 
121
    processed = set()
120
122
    todo = set()
121
 
    for rev in want:
122
 
        todo.update(graph.find_unique_ancestors(rev, have))
 
123
    while pending:
 
124
        processed.update(pending)
 
125
        next_map = get_parent_map(pending)
 
126
        next_pending = set()
 
127
        for item in next_map.iteritems():
 
128
            if item[0] in have:
 
129
                continue
 
130
            todo.add(item[0])
 
131
            next_pending.update(p for p in item[1] if p not in processed)
 
132
        pending = next_pending
123
133
    if NULL_REVISION in todo:
124
134
        todo.remove(NULL_REVISION)
125
135
    return todo
612
622
        ret = self.lookup_git_shas(have + want)
613
623
        for commit_sha in have:
614
624
            try:
615
 
                (type, (revid, tree_sha, verifiers)) = ret[commit_sha]
 
625
                (type, (revid, tree_sha)) = ret[commit_sha]
616
626
            except KeyError:
617
627
                pass
618
628
            else:
623
633
            if commit_sha in have:
624
634
                continue
625
635
            try:
626
 
                (type, (revid, tree_sha, verifiers)) = ret[commit_sha]
 
636
                (type, (revid, tree_sha)) = ret[commit_sha]
627
637
            except KeyError:
628
638
                pass
629
639
            else:
630
640
                assert type == "commit"
631
641
                pending.add(revid)
632
642
 
633
 
        graph = self.repository.get_graph()
634
 
        todo = _find_missing_bzr_revids(graph, pending, processed)
 
643
        todo = _find_missing_bzr_revids(self.repository.get_parent_map, 
 
644
                                        pending, processed)
635
645
        trace.mutter('sending revisions %r', todo)
636
646
        ret = []
637
647
        pb = ui.ui_factory.nested_progress_bar()
638
648
        try:
639
649
            for i, revid in enumerate(todo):
640
650
                pb.update("generating git objects", i, len(todo))
641
 
                try:
642
 
                    rev = self.repository.get_revision(revid)
643
 
                except errors.NoSuchRevision:
644
 
                    continue
 
651
                rev = self.repository.get_revision(revid)
645
652
                tree = self.tree_cache.revision_tree(revid)
646
653
                for path, obj, ie in self._revision_to_objects(rev, tree,
647
654
                    roundtrip=not lossy):