983
def _get_revision_store(self, repo_transport, control_files):
984
"""See RepositoryFormat._get_revision_store()."""
985
return self._get_text_rev_store(repo_transport,
992
def open(self, a_bzrdir, _found=False, _override_transport=None):
993
"""See RepositoryFormat.open().
995
:param _override_transport: INTERNAL USE ONLY. Allows opening the
996
repository at a slightly different url
997
than normal. I.e. during 'upgrade'.
1000
format = RepositoryFormat.find_format(a_bzrdir)
1001
assert format.__class__ == self.__class__
1002
if _override_transport is not None:
1003
repo_transport = _override_transport
1005
repo_transport = a_bzrdir.get_repository_transport(None)
1006
control_files = LockableFiles(repo_transport, 'lock')
1007
text_store = self._get_text_store(repo_transport, control_files)
1008
control_store = self._get_control_store(repo_transport, control_files)
1009
_revision_store = self._get_revision_store(repo_transport, control_files)
1010
return MetaDirRepository(_format=self,
1012
control_files=control_files,
1013
_revision_store=_revision_store,
1014
control_store=control_store,
1015
text_store=text_store)
1017
987
def _upload_blank_content(self, a_bzrdir, dirs, files, utf8_files, shared):
1018
988
"""Upload the initial blank content."""
1019
989
control_files = self._create_control_files(a_bzrdir)
1047
1017
"""See RepositoryFormat.get_format_string()."""
1048
1018
return "Bazaar-NG Repository format 7"
1020
def _get_revision_store(self, repo_transport, control_files):
1021
"""See RepositoryFormat._get_revision_store()."""
1022
return self._get_text_rev_store(repo_transport,
1050
1029
def _get_text_store(self, transport, control_files):
1051
1030
"""See RepositoryFormat._get_text_store()."""
1052
1031
return self._get_versioned_file_store('weaves',
1094
1073
text_store = self._get_text_store(repo_transport, control_files)
1095
1074
control_store = self._get_control_store(repo_transport, control_files)
1096
1075
_revision_store = self._get_revision_store(repo_transport, control_files)
1097
return KnitRepository(_format=self,
1099
control_files=control_files,
1100
_revision_store=_revision_store,
1101
control_store=control_store,
1102
text_store=text_store)
1076
return MetaDirRepository(_format=self,
1078
control_files=control_files,
1079
_revision_store=_revision_store,
1080
control_store=control_store,
1081
text_store=text_store)
1105
1084
class RepositoryFormatKnit1(MetaDirRepositoryFormat):
1119
1098
"""See RepositoryFormat.get_format_string()."""
1120
1099
return "Bazaar-NG Knit Repository Format 1"
1101
def _get_revision_store(self, repo_transport, control_files):
1102
"""See RepositoryFormat._get_revision_store()."""
1103
from bzrlib.store.revision.knit import KnitRevisionStore
1104
versioned_file_store = VersionedFileStore(
1105
repo_transport.clone('revision-store'),
1106
file_mode = control_files._file_mode,
1108
versionedfile_class=KnitVersionedFile)
1109
return KnitRevisionStore(versioned_file_store)
1122
1111
def _get_text_store(self, transport, control_files):
1123
1112
"""See RepositoryFormat._get_text_store()."""
1124
1113
return self._get_versioned_file_store('knits',
1156
1145
bzrlib.transactions.PassThroughTransaction())
1157
1146
return self.open(a_bzrdir=a_bzrdir, _found=True)
1148
def open(self, a_bzrdir, _found=False, _override_transport=None):
1149
"""See RepositoryFormat.open().
1151
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1152
repository at a slightly different url
1153
than normal. I.e. during 'upgrade'.
1156
format = RepositoryFormat.find_format(a_bzrdir)
1157
assert format.__class__ == self.__class__
1158
if _override_transport is not None:
1159
repo_transport = _override_transport
1161
repo_transport = a_bzrdir.get_repository_transport(None)
1162
control_files = LockableFiles(repo_transport, 'lock')
1163
text_store = self._get_text_store(repo_transport, control_files)
1164
control_store = self._get_control_store(repo_transport, control_files)
1165
_revision_store = self._get_revision_store(repo_transport, control_files)
1166
return KnitRepository(_format=self,
1168
control_files=control_files,
1169
_revision_store=_revision_store,
1170
control_store=control_store,
1171
text_store=text_store)
1160
1174
# formats which have no format string are not discoverable
1161
1175
# and not independently creatable, so are not registered.
1232
1246
Returns the copied revision count and the failed revisions in a tuple:
1233
1247
(copied, failures).
1235
from bzrlib.fetch import RepoFetcher
1249
from bzrlib.fetch import GenericRepoFetcher
1236
1250
mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
1237
1251
self.source, self.source._format, self.target, self.target._format)
1238
f = RepoFetcher(to_repository=self.target,
1239
from_repository=self.source,
1240
last_revision=revision_id,
1252
f = GenericRepoFetcher(to_repository=self.target,
1253
from_repository=self.source,
1254
last_revision=revision_id,
1242
1256
return f.count_copied, f.failed_revisions
1244
1258
def lock_read(self):
1349
1363
@needs_write_lock
1350
1364
def fetch(self, revision_id=None, pb=None):
1351
1365
"""See InterRepository.fetch()."""
1352
from bzrlib.fetch import RepoFetcher
1366
from bzrlib.fetch import GenericRepoFetcher
1353
1367
mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
1354
1368
self.source, self.source._format, self.target, self.target._format)
1355
f = RepoFetcher(to_repository=self.target,
1356
from_repository=self.source,
1357
last_revision=revision_id,
1369
f = GenericRepoFetcher(to_repository=self.target,
1370
from_repository=self.source,
1371
last_revision=revision_id,
1359
1373
return f.count_copied, f.failed_revisions
1361
1375
@needs_read_lock
1399
1413
return self.source._eliminate_revisions_not_present(required_topo_revisions)
1416
class InterKnitRepo(InterRepository):
1417
"""Optimised code paths between Knit based repositories."""
1419
_matching_repo_format = RepositoryFormatKnit1()
1420
"""Repository format for testing with."""
1423
def is_compatible(source, target):
1424
"""Be compatible with known Knit formats.
1426
We dont test for the stores being of specific types becase that
1427
could lead to confusing results, and there is no need to be
1431
return (isinstance(source._format, (RepositoryFormatKnit1)) and
1432
isinstance(target._format, (RepositoryFormatKnit1)))
1433
except AttributeError:
1437
def fetch(self, revision_id=None, pb=None):
1438
"""See InterRepository.fetch()."""
1439
from bzrlib.fetch import KnitRepoFetcher
1440
mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
1441
self.source, self.source._format, self.target, self.target._format)
1442
f = KnitRepoFetcher(to_repository=self.target,
1443
from_repository=self.source,
1444
last_revision=revision_id,
1446
return f.count_copied, f.failed_revisions
1449
def missing_revision_ids(self, revision_id=None):
1450
"""See InterRepository.missing_revision_ids()."""
1451
if revision_id is not None:
1452
source_ids = self.source.get_ancestry(revision_id)
1453
assert source_ids.pop(0) == None
1455
source_ids = self.source._all_possible_ids()
1456
source_ids_set = set(source_ids)
1457
# source_ids is the worst possible case we may need to pull.
1458
# now we want to filter source_ids against what we actually
1459
# have in target, but dont try to check for existence where we know
1460
# we do not have a revision as that would be pointless.
1461
target_ids = set(self.target._all_possible_ids())
1462
possibly_present_revisions = target_ids.intersection(source_ids_set)
1463
actually_present_revisions = set(self.target._eliminate_revisions_not_present(possibly_present_revisions))
1464
required_revisions = source_ids_set.difference(actually_present_revisions)
1465
required_topo_revisions = [rev_id for rev_id in source_ids if rev_id in required_revisions]
1466
if revision_id is not None:
1467
# we used get_ancestry to determine source_ids then we are assured all
1468
# revisions referenced are present as they are installed in topological order.
1469
# and the tip revision was validated by get_ancestry.
1470
return required_topo_revisions
1472
# if we just grabbed the possibly available ids, then
1473
# we only have an estimate of whats available and need to validate
1474
# that against the revision records.
1475
return self.source._eliminate_revisions_not_present(required_topo_revisions)
1402
1477
InterRepository.register_optimiser(InterWeaveRepo)
1478
InterRepository.register_optimiser(InterKnitRepo)
1405
1481
class RepositoryTestProviderAdapter(object):