179
179
to_texts = self.to_repository.texts
180
180
from_texts = self.from_repository.texts
181
181
to_texts.insert_record_stream(from_texts.get_record_stream(
182
text_keys, 'topological', False))
182
text_keys, self.to_repository._fetch_order,
183
self.to_repository._fetch_uses_deltas))
183
184
# Cause an error if a text occurs after we have done the
240
243
to_weave.insert_record_stream(from_weave.get_record_stream(
241
244
[(rev_id,) for rev_id in revs],
242
'topological', False))
245
self.to_repository._fetch_order,
246
self.to_repository._fetch_uses_deltas))
244
248
child_pb.finished()
246
def _generate_root_texts(self, revs):
247
"""This will be called by __fetch between fetching weave texts and
248
fetching the inventory weave.
250
Subclasses should override this if they need to generate root texts
251
after fetching weave texts.
256
class GenericRepoFetcher(RepoFetcher):
257
"""This is a generic repo to repo fetcher.
259
This makes minimal assumptions about repo layout and contents.
260
It triggers a reconciliation after fetching to ensure integrity.
263
def _fetch_revision_texts(self, revs, pb):
264
"""Fetch revision object texts"""
268
pb.update('copying revisions', count, total)
270
sig_text = self.from_repository.get_signature_text(rev)
271
self.to_repository.add_signature_text(rev, sig_text)
272
except errors.NoSuchRevision:
275
self._copy_revision(rev)
277
# fixup inventory if needed:
278
# this is expensive because we have no inverse index to current ghosts.
279
# but on local disk its a few seconds and sftp push is already insane.
281
# FIXME: repository should inform if this is needed.
282
self.to_repository.reconcile()
284
def _copy_revision(self, rev_id):
285
rev = self.from_repository.get_revision(rev_id)
286
self.to_repository.add_revision(rev_id, rev)
289
class KnitRepoFetcher(RepoFetcher):
290
"""This is a knit format repository specific fetcher.
292
This differs from the GenericRepoFetcher by not doing a
293
reconciliation after copying, and using knit joining to
297
250
def _fetch_revision_texts(self, revs, pb):
298
251
# may need to be a InterRevisionStore call here.
299
252
to_sf = self.to_repository.signatures
301
254
# A missing signature is just skipped.
302
255
to_sf.insert_record_stream(filter_absent(from_sf.get_record_stream(
303
256
[(rev_id,) for rev_id in revs],
304
'unordered', False)))
257
self.to_repository._fetch_order,
258
self.to_repository._fetch_uses_deltas)))
305
259
self._fetch_just_revision_texts(revs)
307
261
def _fetch_just_revision_texts(self, version_ids):
309
263
from_rf = self.from_repository.revisions
310
264
to_rf.insert_record_stream(from_rf.get_record_stream(
311
265
[(rev_id,) for rev_id in version_ids],
312
'topological', False))
266
self.to_repository._fetch_order,
267
self.to_repository._fetch_uses_deltas))
269
def _generate_root_texts(self, revs):
270
"""This will be called by __fetch between fetching weave texts and
271
fetching the inventory weave.
273
Subclasses should override this if they need to generate root texts
274
after fetching weave texts.
315
279
class Inter1and2Helper(object):
420
384
self.target.add_revision(revision.revision_id, revision)
423
class Model1toKnit2Fetcher(GenericRepoFetcher):
387
class Model1toKnit2Fetcher(RepoFetcher):
424
388
"""Fetch from a Model1 repository into a Knit2 repository
426
390
def __init__(self, to_repository, from_repository, last_revision=None,
427
391
pb=None, find_ghosts=True):
428
392
self.helper = Inter1and2Helper(from_repository, to_repository)
429
GenericRepoFetcher.__init__(self, to_repository, from_repository,
393
RepoFetcher.__init__(self, to_repository, from_repository,
430
394
last_revision, pb, find_ghosts)
432
396
def _generate_root_texts(self, revs):
435
399
def _fetch_inventory_weave(self, revs, pb):
436
400
self.helper.regenerate_inventory(revs)
402
def _fetch_revision_texts(self, revs, pb):
403
"""Fetch revision object texts"""
407
pb.update('copying revisions', count, total)
409
sig_text = self.from_repository.get_signature_text(rev)
410
self.to_repository.add_signature_text(rev, sig_text)
411
except errors.NoSuchRevision:
414
self._copy_revision(rev)
438
417
def _copy_revision(self, rev):
439
418
self.helper.fetch_revisions([rev])
442
class Knit1to2Fetcher(KnitRepoFetcher):
421
class Knit1to2Fetcher(RepoFetcher):
443
422
"""Fetch from a Knit1 repository into a Knit2 repository"""
445
def __init__(self, to_repository, from_repository, last_revision=None,
424
def __init__(self, to_repository, from_repository, last_revision=None,
446
425
pb=None, find_ghosts=True):
447
426
self.helper = Inter1and2Helper(from_repository, to_repository)
448
KnitRepoFetcher.__init__(self, to_repository, from_repository,
427
RepoFetcher.__init__(self, to_repository, from_repository,
449
428
last_revision, pb, find_ghosts)
451
430
def _generate_root_texts(self, revs):