/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

Use InterRepo directly.

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):
155
150
    def get_signature_text(self, revision_id):
156
151
        raise errors.NoSuchRevision(self, revision_id)
157
152
 
158
 
    def pack(self, hint=None, clean_obsolete_packs=False):
159
 
        self._git.object_store.pack_loose_objects()
160
 
 
161
153
    def lookup_foreign_revision_id(self, foreign_revid, mapping=None):
162
154
        """Lookup a revision id.
163
155
 
164
156
        """
165
 
        assert type(foreign_revid) is str
166
157
        if mapping is None:
167
158
            mapping = self.get_mapping()
168
159
        from dulwich.protocol import (
171
162
        if foreign_revid == ZERO_SHA:
172
163
            return revision.NULL_REVISION
173
164
        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
 
165
        rev = mapping.import_commit(commit, lambda x: None)
 
166
        return rev.revision_id
181
167
 
182
168
    def has_signature_for_revision_id(self, revision_id):
183
169
        return False
189
175
            if mapping is None:
190
176
                mapping = self.get_mapping()
191
177
            try:
192
 
                return (self._git.refs[mapping.revid_as_refname(bzr_revid)],
193
 
                        mapping)
 
178
                return self._git.refs[mapping.revid_as_refname(bzr_revid)], mapping
194
179
            except KeyError:
195
180
                # Update refs from Git commit objects
196
181
                # 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:
 
182
                for git_sha, revid in self._iter_revision_ids():
 
183
                    self._git.refs[mapping.revid_as_refname(revid)] = git_sha
 
184
                    if revid == bzr_revid:
203
185
                        return git_sha, mapping
204
186
                raise errors.NoSuchRevision(self, bzr_revid)
205
187
 
209
191
            commit = self._git[git_commit_id]
210
192
        except KeyError:
211
193
            raise errors.NoSuchRevision(self, revision_id)
212
 
        revision, roundtrip_revid, verifiers = mapping.import_commit(
213
 
            commit, self.lookup_foreign_revision_id)
 
194
        # print "fetched revision:", git_commit_id
 
195
        revision = mapping.import_commit(commit,
 
196
            self.lookup_foreign_revision_id)
214
197
        assert revision is not None
215
 
        # FIXME: check verifiers ?
216
 
        if roundtrip_revid:
217
 
            revision.revision_id = roundtrip_revid
218
198
        return revision
219
199
 
220
200
    def has_revision(self, revision_id):
257
237
                        ancestors=None):
258
238
        return GitVersionedFileChecker(self,
259
239
            text_key_references=text_key_references, ancestors=ancestors)
260
 
 
 
240
    
261
241
 
262
242
class GitVersionedFileChecker(repository._VersionedFileChecker):
263
243