3349
3352
'bzrlib.repofmt.pack_repo',
3350
3353
'RepositoryFormatKnitPack6RichRoot',
3355
format_registry.register_lazy(
3356
'Bazaar repository format 2a (needs bzr 1.16 or later)\n',
3357
'bzrlib.repofmt.groupcompress_repo',
3358
'RepositoryFormat2a',
3353
3361
# Development formats.
3354
# Obsolete but kept pending a CHK based subtree format.
3362
# Check their docstrings to see if/when they are obsolete.
3355
3363
format_registry.register_lazy(
3356
3364
("Bazaar development format 2 with subtree support "
3357
3365
"(needs bzr.dev from before 1.8)\n"),
3358
3366
'bzrlib.repofmt.pack_repo',
3359
3367
'RepositoryFormatPackDevelopment2Subtree',
3362
# 1.14->1.16 go below here
3363
format_registry.register_lazy(
3364
'Bazaar development format - group compression and chk inventory'
3365
' (needs bzr.dev from 1.14)\n',
3366
'bzrlib.repofmt.groupcompress_repo',
3367
'RepositoryFormatCHK1',
3370
format_registry.register_lazy(
3371
'Bazaar development format - chk repository with bencode revision '
3372
'serialization (needs bzr.dev from 1.16)\n',
3373
'bzrlib.repofmt.groupcompress_repo',
3374
'RepositoryFormatCHK2',
3376
format_registry.register_lazy(
3377
'Bazaar repository format 2a (needs bzr 1.16 or later)\n',
3378
'bzrlib.repofmt.groupcompress_repo',
3379
'RepositoryFormat2a',
3381
3369
format_registry.register_lazy(
3382
3370
'Bazaar development format 8\n',
3383
3371
'bzrlib.repofmt.groupcompress_repo',
3565
3553
return InterRepository._same_model(source, target)
3568
class InterWeaveRepo(InterSameDataRepository):
3569
"""Optimised code paths between Weave based repositories.
3571
This should be in bzrlib/repofmt/weaverepo.py but we have not yet
3572
implemented lazy inter-object optimisation.
3576
def _get_repo_format_to_test(self):
3577
from bzrlib.repofmt import weaverepo
3578
return weaverepo.RepositoryFormat7()
3581
def is_compatible(source, target):
3582
"""Be compatible with known Weave formats.
3584
We don't test for the stores being of specific types because that
3585
could lead to confusing results, and there is no need to be
3588
from bzrlib.repofmt.weaverepo import (
3594
return (isinstance(source._format, (RepositoryFormat5,
3596
RepositoryFormat7)) and
3597
isinstance(target._format, (RepositoryFormat5,
3599
RepositoryFormat7)))
3600
except AttributeError:
3604
def copy_content(self, revision_id=None):
3605
"""See InterRepository.copy_content()."""
3606
# weave specific optimised path:
3608
self.target.set_make_working_trees(self.source.make_working_trees())
3609
except (errors.RepositoryUpgradeRequired, NotImplemented):
3611
# FIXME do not peek!
3612
if self.source._transport.listable():
3613
pb = ui.ui_factory.nested_progress_bar()
3615
self.target.texts.insert_record_stream(
3616
self.source.texts.get_record_stream(
3617
self.source.texts.keys(), 'topological', False))
3618
pb.update('Copying inventory', 0, 1)
3619
self.target.inventories.insert_record_stream(
3620
self.source.inventories.get_record_stream(
3621
self.source.inventories.keys(), 'topological', False))
3622
self.target.signatures.insert_record_stream(
3623
self.source.signatures.get_record_stream(
3624
self.source.signatures.keys(),
3626
self.target.revisions.insert_record_stream(
3627
self.source.revisions.get_record_stream(
3628
self.source.revisions.keys(),
3629
'topological', True))
3633
self.target.fetch(self.source, revision_id=revision_id)
3636
def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
3637
"""See InterRepository.missing_revision_ids()."""
3638
# we want all revisions to satisfy revision_id in source.
3639
# but we don't want to stat every file here and there.
3640
# we want then, all revisions other needs to satisfy revision_id
3641
# checked, but not those that we have locally.
3642
# so the first thing is to get a subset of the revisions to
3643
# satisfy revision_id in source, and then eliminate those that
3644
# we do already have.
3645
# this is slow on high latency connection to self, but as this
3646
# disk format scales terribly for push anyway due to rewriting
3647
# inventory.weave, this is considered acceptable.
3649
if revision_id is not None:
3650
source_ids = self.source.get_ancestry(revision_id)
3651
if source_ids[0] is not None:
3652
raise AssertionError()
3655
source_ids = self.source._all_possible_ids()
3656
source_ids_set = set(source_ids)
3657
# source_ids is the worst possible case we may need to pull.
3658
# now we want to filter source_ids against what we actually
3659
# have in target, but don't try to check for existence where we know
3660
# we do not have a revision as that would be pointless.
3661
target_ids = set(self.target._all_possible_ids())
3662
possibly_present_revisions = target_ids.intersection(source_ids_set)
3663
actually_present_revisions = set(
3664
self.target._eliminate_revisions_not_present(possibly_present_revisions))
3665
required_revisions = source_ids_set.difference(actually_present_revisions)
3666
if revision_id is not None:
3667
# we used get_ancestry to determine source_ids then we are assured all
3668
# revisions referenced are present as they are installed in topological order.
3669
# and the tip revision was validated by get_ancestry.
3670
result_set = required_revisions
3672
# if we just grabbed the possibly available ids, then
3673
# we only have an estimate of whats available and need to validate
3674
# that against the revision records.
3676
self.source._eliminate_revisions_not_present(required_revisions))
3677
return self.source.revision_ids_to_search_result(result_set)
3680
class InterKnitRepo(InterSameDataRepository):
3681
"""Optimised code paths between Knit based repositories."""
3684
def _get_repo_format_to_test(self):
3685
from bzrlib.repofmt import knitrepo
3686
return knitrepo.RepositoryFormatKnit1()
3689
def is_compatible(source, target):
3690
"""Be compatible with known Knit formats.
3692
We don't test for the stores being of specific types because that
3693
could lead to confusing results, and there is no need to be
3696
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
3698
are_knits = (isinstance(source._format, RepositoryFormatKnit) and
3699
isinstance(target._format, RepositoryFormatKnit))
3700
except AttributeError:
3702
return are_knits and InterRepository._same_model(source, target)
3705
def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
3706
"""See InterRepository.missing_revision_ids()."""
3707
if revision_id is not None:
3708
source_ids = self.source.get_ancestry(revision_id)
3709
if source_ids[0] is not None:
3710
raise AssertionError()
3713
source_ids = self.source.all_revision_ids()
3714
source_ids_set = set(source_ids)
3715
# source_ids is the worst possible case we may need to pull.
3716
# now we want to filter source_ids against what we actually
3717
# have in target, but don't try to check for existence where we know
3718
# we do not have a revision as that would be pointless.
3719
target_ids = set(self.target.all_revision_ids())
3720
possibly_present_revisions = target_ids.intersection(source_ids_set)
3721
actually_present_revisions = set(
3722
self.target._eliminate_revisions_not_present(possibly_present_revisions))
3723
required_revisions = source_ids_set.difference(actually_present_revisions)
3724
if revision_id is not None:
3725
# we used get_ancestry to determine source_ids then we are assured all
3726
# revisions referenced are present as they are installed in topological order.
3727
# and the tip revision was validated by get_ancestry.
3728
result_set = required_revisions
3730
# if we just grabbed the possibly available ids, then
3731
# we only have an estimate of whats available and need to validate
3732
# that against the revision records.
3734
self.source._eliminate_revisions_not_present(required_revisions))
3735
return self.source.revision_ids_to_search_result(result_set)
3738
3556
class InterDifferingSerializer(InterRepository):