/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

Set refs/heads/master if no ref is set yet.

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
91
91
        interrepo = repository.InterRepository.get(source, self)
92
92
        return interrepo.dfetch(stop_revision)
93
93
 
 
94
    def dfetch_refs(self, source, stop_revision):
 
95
        interrepo = repository.InterRepository.get(source, self)
 
96
        return interrepo.dfetch_refs(stop_revision)
 
97
 
 
98
    def fetch_refs(self, source, stop_revision):
 
99
        interrepo = repository.InterRepository.get(source, self)
 
100
        return interrepo.fetch_refs(stop_revision)
 
101
 
94
102
 
95
103
class LocalGitRepository(GitRepository):
96
104
    """Git repository on the file system."""
105
113
        self.texts = GitTexts(self)
106
114
 
107
115
    def _iter_revision_ids(self):
108
 
        mapping = self.get_mapping()
109
116
        for sha in self._git.object_store:
110
117
            o = self._git.object_store[sha]
111
118
            if not isinstance(o, Commit):
112
119
                continue
113
 
            rev, roundtrip_revid, verifiers = mapping.import_commit(o,
 
120
            rev = self.get_mapping().import_commit(o,
114
121
                self.lookup_foreign_revision_id)
115
 
            yield o.id, rev.revision_id, roundtrip_revid
 
122
            yield o.id, rev.revision_id
116
123
 
117
124
    def all_revision_ids(self):
118
125
        ret = set([])
119
 
        for git_sha, revid, roundtrip_revid in self._iter_revision_ids():
 
126
        for git_sha, revid in self._iter_revision_ids():
120
127
            ret.add(revid)
121
 
            if roundtrip_revid:
122
 
                ret.add(roundtrip_revid)
123
128
        return ret
124
129
 
125
130
    def get_parent_map(self, revids):
134
139
                commit = self._git[hexsha]
135
140
            except KeyError:
136
141
                continue
137
 
            parent_map[revision_id] = [
138
 
                self.lookup_foreign_revision_id(p, mapping)
139
 
                for p in commit.parents]
 
142
            parent_map[revision_id] = [self.lookup_foreign_revision_id(p, mapping) for p in commit.parents]
140
143
        return parent_map
141
144
 
142
145
    def get_ancestry(self, revision_id, topo_sorted=True):
155
158
    def get_signature_text(self, revision_id):
156
159
        raise errors.NoSuchRevision(self, revision_id)
157
160
 
158
 
    def pack(self, hint=None, clean_obsolete_packs=False):
159
 
        self._git.object_store.pack_loose_objects()
160
 
 
161
161
    def lookup_foreign_revision_id(self, foreign_revid, mapping=None):
162
162
        """Lookup a revision id.
163
163
 
164
164
        """
165
 
        assert type(foreign_revid) is str
166
165
        if mapping is None:
167
166
            mapping = self.get_mapping()
168
167
        from dulwich.protocol import (
171
170
        if foreign_revid == ZERO_SHA:
172
171
            return revision.NULL_REVISION
173
172
        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
 
173
        rev = mapping.import_commit(commit, lambda x: None)
 
174
        return rev.revision_id
181
175
 
182
176
    def has_signature_for_revision_id(self, revision_id):
183
177
        return False
189
183
            if mapping is None:
190
184
                mapping = self.get_mapping()
191
185
            try:
192
 
                return (self._git.refs[mapping.revid_as_refname(bzr_revid)],
193
 
                        mapping)
 
186
                return self._git.refs[mapping.revid_as_refname(bzr_revid)], mapping
194
187
            except KeyError:
195
188
                # Update refs from Git commit objects
196
189
                # 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:
 
190
                for git_sha, revid in self._iter_revision_ids():
 
191
                    self._git.refs[mapping.revid_as_refname(revid)] = git_sha
 
192
                    if revid == bzr_revid:
203
193
                        return git_sha, mapping
204
194
                raise errors.NoSuchRevision(self, bzr_revid)
205
195
 
209
199
            commit = self._git[git_commit_id]
210
200
        except KeyError:
211
201
            raise errors.NoSuchRevision(self, revision_id)
212
 
        revision, roundtrip_revid, verifiers = mapping.import_commit(
213
 
            commit, self.lookup_foreign_revision_id)
 
202
        # print "fetched revision:", git_commit_id
 
203
        revision = mapping.import_commit(commit,
 
204
            self.lookup_foreign_revision_id)
214
205
        assert revision is not None
215
 
        # FIXME: check verifiers ?
216
 
        if roundtrip_revid:
217
 
            revision.revision_id = roundtrip_revid
218
206
        return revision
219
207
 
220
208
    def has_revision(self, revision_id):
257
245
                        ancestors=None):
258
246
        return GitVersionedFileChecker(self,
259
247
            text_key_references=text_key_references, ancestors=ancestors)
260
 
 
 
248
    
261
249
 
262
250
class GitVersionedFileChecker(repository._VersionedFileChecker):
263
251