113
113
"""See InterRepository.copy_content."""
114
114
self.fetch(revision_id, pb, find_ghosts=False)
116
def dfetch_refs(self, update_refs):
117
"""Fetch non-roundtripped revisions into the target repository.
119
:param update_refs: Generate refs to fetch. Receives dictionary
120
with old names to old git shas. Should return a dictionary
121
of new names to Bazaar revision ids.
122
:return: revision id map, old refs dictionary and new refs dictionary
124
raise NotImplementedError(self.dfetch_refs)
126
def fetch_refs(self, update_refs):
127
"""Fetch possibly roundtripped revisions into the target repository.
116
def fetch_refs(self, update_refs, lossy):
117
"""Fetch possibly roundtripped revisions into the target repository
129
120
:param update_refs: Generate refs to fetch. Receives dictionary
130
121
with old refs (git shas), returns dictionary of new names to
123
:param lossy: Whether to roundtrip
132
124
:return: old refs, new refs
134
126
raise NotImplementedError(self.fetch_refs)
219
211
bzr_refs[k] = (v, revid)
222
def fetch_refs(self, update_refs):
223
self.source_store.lock_read()
225
old_refs = self._get_target_bzr_refs()
226
new_refs = update_refs(old_refs)
227
self.fetch(mapped_refs=new_refs.values())
229
self.source_store.unlock()
230
return old_refs, new_refs
232
def dfetch_refs(self, update_refs):
233
self.source_store.lock_read()
235
old_refs = self._get_target_bzr_refs()
236
new_refs = update_refs(old_refs)
239
todo = list(self.missing_revisions(new_refs.values()))
240
pb = ui.ui_factory.nested_progress_bar()
242
object_generator = self._get_missing_objects_iterator(pb)
243
for old_bzr_revid, git_commit in object_generator.import_revisions(
244
todo, roundtrip=False):
245
new_bzr_revid = self.mapping.revision_id_foreign_to_bzr(git_commit)
246
assert type(old_bzr_revid) is str
247
assert type(new_bzr_revid) is str
248
assert type(git_commit) is str
249
revidmap[old_bzr_revid] = new_bzr_revid
250
gitidmap[old_bzr_revid] = git_commit
251
self.target_store.add_objects(object_generator)
214
def fetch_refs(self, update_refs, lossy):
215
self.source_store.lock_read()
217
old_refs = self._get_target_bzr_refs()
218
new_refs = update_refs(old_refs)
219
revidmap = self.fetch_objects(new_refs.values(), roundtrip=not lossy)
254
220
for name, (gitid, revid) in new_refs.iteritems():
255
221
if gitid is None:
257
gitid = gitidmap[revid]
223
gitid = revidmap[revid][0]
259
225
gitid = self.source_store._lookup_revision_sha1(revid)
226
assert len(gitid) == 40
260
227
self.target_refs[name] = gitid
262
229
self.source_store.unlock()
263
230
return revidmap, old_refs, new_refs
232
def fetch_objects(self, revs, roundtrip):
233
todo = list(self.missing_revisions(revs))
235
pb = ui.ui_factory.nested_progress_bar()
237
object_generator = self._get_missing_objects_iterator(pb)
238
for (old_revid, git_sha) in object_generator.import_revisions(
239
todo, roundtrip=roundtrip):
241
self.mapping.revision_id_bzr_to_foreign(old_revid)
242
except errors.InvalidRevisionId:
243
self.target_refs[self.mapping.revid_as_refname(old_revid)] = git_sha
245
new_revid = self.mapping.revision_id_foreign_to_bzr(git_sha)
247
new_revid = old_revid
248
revidmap[old_revid] = (git_sha, new_revid)
249
self.target_store.add_objects(object_generator)
265
254
def _get_missing_objects_iterator(self, pb):
266
255
return MissingObjectsIterator(self.source_store, self.source, pb)
282
271
stop_revisions = [(None, revid) for revid in fetch_spec.heads]
284
273
stop_revisions = [(None, revid) for revid in self.source.all_revision_ids()]
285
todo = list(self.missing_revisions(stop_revisions))
286
pb = ui.ui_factory.nested_progress_bar()
288
object_generator = self._get_missing_objects_iterator(pb)
289
for (revid, git_sha) in object_generator.import_revisions(
290
todo, roundtrip=True):
292
self.mapping.revision_id_bzr_to_foreign(revid)
293
except errors.InvalidRevisionId:
294
self.target_refs[self.mapping.revid_as_refname(revid)] = git_sha
295
self.target_store.add_objects(object_generator)
274
self.fetch_objects(stop_revisions, roundtrip=True)
299
276
self.source_store.unlock()