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

Special-case NULL_REVISION when looking for Git shas.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
        return default_mapping
83
83
 
84
84
    def make_working_trees(self):
85
 
        return not self._git.bare
 
85
        return True
86
86
 
87
87
    def revision_graph_can_have_wrong_parents(self):
88
88
        return False
105
105
        self.texts = GitTexts(self)
106
106
 
107
107
    def _iter_revision_ids(self):
108
 
        mapping = self.get_mapping()
109
108
        for sha in self._git.object_store:
110
109
            o = self._git.object_store[sha]
111
110
            if not isinstance(o, Commit):
112
111
                continue
113
 
            rev, roundtrip_revid, verifiers = mapping.import_commit(o,
 
112
            rev = self.get_mapping().import_commit(o,
114
113
                self.lookup_foreign_revision_id)
115
 
            yield o.id, rev.revision_id, roundtrip_revid
 
114
            yield o.id, rev.revision_id
116
115
 
117
116
    def all_revision_ids(self):
118
117
        ret = set([])
119
 
        for git_sha, revid, roundtrip_revid in self._iter_revision_ids():
 
118
        for git_sha, revid in self._iter_revision_ids():
120
119
            ret.add(revid)
121
 
            if roundtrip_revid:
122
 
                ret.add(roundtrip_revid)
123
120
        return ret
124
121
 
125
122
    def get_parent_map(self, revids):
134
131
                commit = self._git[hexsha]
135
132
            except KeyError:
136
133
                continue
137
 
            parent_map[revision_id] = [
138
 
                self.lookup_foreign_revision_id(p, mapping)
139
 
                for p in commit.parents]
 
134
            parent_map[revision_id] = [self.lookup_foreign_revision_id(p, mapping) for p in commit.parents]
140
135
        return parent_map
141
136
 
142
137
    def get_ancestry(self, revision_id, topo_sorted=True):
162
157
        """Lookup a revision id.
163
158
 
164
159
        """
165
 
        assert type(foreign_revid) is str
166
160
        if mapping is None:
167
161
            mapping = self.get_mapping()
168
162
        from dulwich.protocol import (
171
165
        if foreign_revid == ZERO_SHA:
172
166
            return revision.NULL_REVISION
173
167
        commit = self._git[foreign_revid]
174
 
        rev, roundtrip_revid, verifiers = mapping.import_commit(commit,
175
 
            lambda x: None)
176
 
        # FIXME: check testament before doing this?
177
 
        if roundtrip_revid:
178
 
            return roundtrip_revid
179
 
        else:
180
 
            return rev.revision_id
 
168
        rev = mapping.import_commit(commit, lambda x: None)
 
169
        return rev.revision_id
181
170
 
182
171
    def has_signature_for_revision_id(self, revision_id):
183
172
        return False
189
178
            if mapping is None:
190
179
                mapping = self.get_mapping()
191
180
            try:
192
 
                return (self._git.refs[mapping.revid_as_refname(bzr_revid)],
193
 
                        mapping)
 
181
                return self._git.refs[mapping.revid_as_refname(bzr_revid)], mapping
194
182
            except KeyError:
195
183
                # Update refs from Git commit objects
196
184
                # FIXME: Hitting this a lot will be very inefficient...
197
 
                for git_sha, revid, roundtrip_revid in self._iter_revision_ids():
198
 
                    if not roundtrip_revid:
199
 
                        continue
200
 
                    refname = mapping.revid_as_refname(roundtrip_revid)
201
 
                    self._git.refs[refname] = git_sha
202
 
                    if roundtrip_revid == bzr_revid:
 
185
                for git_sha, revid in self._iter_revision_ids():
 
186
                    self._git.refs[mapping.revid_as_refname(revid)] = git_sha
 
187
                    if revid == bzr_revid:
203
188
                        return git_sha, mapping
204
189
                raise errors.NoSuchRevision(self, bzr_revid)
205
190
 
209
194
            commit = self._git[git_commit_id]
210
195
        except KeyError:
211
196
            raise errors.NoSuchRevision(self, revision_id)
212
 
        revision, roundtrip_revid, verifiers = mapping.import_commit(
213
 
            commit, self.lookup_foreign_revision_id)
 
197
        # print "fetched revision:", git_commit_id
 
198
        revision = mapping.import_commit(commit,
 
199
            self.lookup_foreign_revision_id)
214
200
        assert revision is not None
215
 
        # FIXME: check verifiers ?
216
 
        if roundtrip_revid:
217
 
            revision.revision_id = roundtrip_revid
218
201
        return revision
219
202
 
220
203
    def has_revision(self, revision_id):
257
240
                        ancestors=None):
258
241
        return GitVersionedFileChecker(self,
259
242
            text_key_references=text_key_references, ancestors=ancestors)
260
 
 
 
243
    
261
244
 
262
245
class GitVersionedFileChecker(repository._VersionedFileChecker):
263
246