/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

Import ZERO_SHA from dulwich.objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    Commit,
22
22
    Tree,
23
23
    sha_to_hex,
 
24
    ZERO_SHA,
24
25
    )
25
26
from dulwich.object_store import (
26
27
    BaseObjectStore,
108
109
        self._cache.add(tree.get_revision_id(), tree)
109
110
 
110
111
 
111
 
def _find_missing_bzr_revids(get_parent_map, want, have):
 
112
def _find_missing_bzr_revids(graph, want, have):
112
113
    """Find the revisions that have to be pushed.
113
114
 
114
115
    :param get_parent_map: Function that returns the parents for a sequence
117
118
    :param have: Revisions the target already has
118
119
    :return: Set of revisions to fetch
119
120
    """
120
 
    pending = want - have
121
 
    processed = set()
122
121
    todo = set()
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
 
122
    for rev in want:
 
123
        todo.update(graph.find_unique_ancestors(rev, have))
133
124
    if NULL_REVISION in todo:
134
125
        todo.remove(NULL_REVISION)
135
126
    return todo
503
494
 
504
495
    def _lookup_revision_sha1(self, revid):
505
496
        """Return the SHA1 matching a Bazaar revision."""
506
 
        from dulwich.protocol import ZERO_SHA
507
497
        if revid == NULL_REVISION:
508
498
            return ZERO_SHA
509
499
        try:
543
533
            return False
544
534
 
545
535
    def lookup_git_shas(self, shas, update_map=True):
546
 
        from dulwich.protocol import ZERO_SHA
547
536
        ret = {}
548
537
        for sha in shas:
549
538
            if sha == ZERO_SHA:
622
611
        ret = self.lookup_git_shas(have + want)
623
612
        for commit_sha in have:
624
613
            try:
625
 
                (type, (revid, tree_sha)) = ret[commit_sha]
 
614
                (type, (revid, tree_sha, verifiers)) = ret[commit_sha]
626
615
            except KeyError:
627
616
                pass
628
617
            else:
633
622
            if commit_sha in have:
634
623
                continue
635
624
            try:
636
 
                (type, (revid, tree_sha)) = ret[commit_sha]
 
625
                (type, (revid, tree_sha, verifiers)) = ret[commit_sha]
637
626
            except KeyError:
638
627
                pass
639
628
            else:
640
629
                assert type == "commit"
641
630
                pending.add(revid)
642
631
 
643
 
        todo = _find_missing_bzr_revids(self.repository.get_parent_map, 
644
 
                                        pending, processed)
 
632
        graph = self.repository.get_graph()
 
633
        todo = _find_missing_bzr_revids(graph, pending, processed)
645
634
        trace.mutter('sending revisions %r', todo)
646
635
        ret = []
647
636
        pb = ui.ui_factory.nested_progress_bar()
648
637
        try:
649
638
            for i, revid in enumerate(todo):
650
639
                pb.update("generating git objects", i, len(todo))
651
 
                rev = self.repository.get_revision(revid)
 
640
                try:
 
641
                    rev = self.repository.get_revision(revid)
 
642
                except errors.NoSuchRevision:
 
643
                    continue
652
644
                tree = self.tree_cache.revision_tree(revid)
653
645
                for path, obj, ie in self._revision_to_objects(rev, tree,
654
646
                    roundtrip=not lossy):