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

Use BazaarObjectStore to find matching SHA1s for bzr revisions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    Repository,
33
33
    )
34
34
 
 
35
from bzrlib.plugins.git.converter import (
 
36
    BazaarObjectStore,
 
37
    )
35
38
from bzrlib.plugins.git.fetch import (
36
39
    import_git_objects,
37
40
    )
76
79
        for branch in repo.find_branches(using=True):
77
80
            #FIXME: Look for 'master' or 'trunk' in here, and set HEAD accordingly...
78
81
            #FIXME: Need to get branch path relative to its repository and use this instead of nick
79
 
            rev = self.mapping.revision_id_bzr_to_foreign(branch.last_revision())
80
 
            if type(rev) == tuple:
81
 
                ret["refs/heads/"+branch.nick] = rev[0]
82
 
            else:
83
 
                ret["refs/heads/"+branch.nick] = rev
 
82
            rev, mapping = self.mapping.revision_id_bzr_to_foreign(branch.last_revision())
 
83
            ret["refs/heads/"+branch.nick] = rev
84
84
        if 'HEAD' not in ret and branch:
85
 
            rev = self.mapping.revision_id_bzr_to_foreign(branch.last_revision())
86
 
            if type(rev) == tuple:
87
 
                ret['HEAD'] = rev[0]
88
 
            else:
89
 
                ret['HEAD'] = rev
 
85
            rev, mapping = self.mapping.revision_id_bzr_to_foreign(branch.last_revision())
 
86
            ret['HEAD'] = rev
90
87
        return ret
91
88
 
92
89
    def apply_pack(self, refs, read):
142
139
        # If this is a Git repository, just use the existing fetch_objects implementation.
143
140
        if getattr(repo, "fetch_objects", None) is not None:
144
141
            return repo.fetch_objects(determine_wants, graph_walker, None, progress)
 
142
        store = BazaarObjectStore(repo)
145
143
 
146
144
        wants = determine_wants(self.get_refs())
147
145
        commits_to_send = set([self.mapping.revision_id_foreign_to_bzr(w) for w in wants])
174
172
                        obj_sent.add(sha)
175
173
                        objects.add((obj, path))
176
174
 
177
 
                objects.add((revision_to_commit(rev, sha, self.mapping.revision_id_bzr_to_foreign), None))
 
175
                objects.add((revision_to_commit(rev, sha, store._lookup_revision_sha1), None))
178
176
 
179
177
        finally:
180
178
            repo.unlock()