779
820
raise errors.NonAsciiRevisionId(method, self)
782
class AllInOneRepository(Repository):
783
"""Legacy support - the repository behaviour for all-in-one branches."""
785
def __init__(self, _format, a_bzrdir, _revision_store, control_store, text_store):
786
# we reuse one control files instance.
787
dir_mode = a_bzrdir._control_files._dir_mode
788
file_mode = a_bzrdir._control_files._file_mode
790
def get_store(name, compressed=True, prefixed=False):
791
# FIXME: This approach of assuming stores are all entirely compressed
792
# or entirely uncompressed is tidy, but breaks upgrade from
793
# some existing branches where there's a mixture; we probably
794
# still want the option to look for both.
795
relpath = a_bzrdir._control_files._escape(name)
796
store = TextStore(a_bzrdir._control_files._transport.clone(relpath),
797
prefixed=prefixed, compressed=compressed,
800
#if self._transport.should_cache():
801
# cache_path = os.path.join(self.cache_root, name)
802
# os.mkdir(cache_path)
803
# store = bzrlib.store.CachedStore(store, cache_path)
806
# not broken out yet because the controlweaves|inventory_store
807
# and text_store | weave_store bits are still different.
808
if isinstance(_format, RepositoryFormat4):
809
# cannot remove these - there is still no consistent api
810
# which allows access to this old info.
811
self.inventory_store = get_store('inventory-store')
812
text_store = get_store('text-store')
813
super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files, _revision_store, control_store, text_store)
815
def get_commit_builder(self, branch, parents, config, timestamp=None,
816
timezone=None, committer=None, revprops=None,
818
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
819
return Repository.get_commit_builder(self, branch, parents, config,
820
timestamp, timezone, committer, revprops, revision_id)
824
"""AllInOne repositories cannot be shared."""
828
def set_make_working_trees(self, new_value):
829
"""Set the policy flag for making working trees when creating branches.
831
This only applies to branches that use this repository.
833
The default is 'True'.
834
:param new_value: True to restore the default, False to disable making
837
raise NotImplementedError(self.set_make_working_trees)
839
def make_working_trees(self):
840
"""Returns the policy for making working trees on new branches."""
824
# remove these delegates a while after bzr 0.15
825
def __make_delegated(name, from_module):
826
def _deprecated_repository_forwarder():
827
symbol_versioning.warn('%s moved to %s in bzr 0.15'
828
% (name, from_module),
831
m = __import__(from_module, globals(), locals(), [name])
833
return getattr(m, name)
834
except AttributeError:
835
raise AttributeError('module %s has no name %s'
837
globals()[name] = _deprecated_repository_forwarder
840
'AllInOneRepository',
841
'WeaveMetaDirRepository',
842
'PreSplitOutRepositoryFormat',
848
__make_delegated(_name, 'bzrlib.repofmt.weaverepo')
853
'RepositoryFormatKnit',
854
'RepositoryFormatKnit1',
855
'RepositoryFormatKnit2',
857
__make_delegated(_name, 'bzrlib.repofmt.knitrepo')
844
860
def install_revision(repository, rev, revision_tree):
930
946
return not self.control_files._transport.has('no-working-trees')
933
class WeaveMetaDirRepository(MetaDirRepository):
934
"""A subclass of MetaDirRepository to set weave specific policy."""
936
def get_commit_builder(self, branch, parents, config, timestamp=None,
937
timezone=None, committer=None, revprops=None,
939
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
940
return MetaDirRepository.get_commit_builder(self, branch, parents,
941
config, timestamp, timezone, committer, revprops, revision_id)
944
class KnitRepository(MetaDirRepository):
945
"""Knit format repository."""
947
def _warn_if_deprecated(self):
948
# This class isn't deprecated
951
def _inventory_add_lines(self, inv_vf, revid, parents, lines):
952
inv_vf.add_lines_with_ghosts(revid, parents, lines)
955
def _all_revision_ids(self):
956
"""See Repository.all_revision_ids()."""
957
# Knits get the revision graph from the index of the revision knit, so
958
# it's always possible even if they're on an unlistable transport.
959
return self._revision_store.all_revision_ids(self.get_transaction())
961
def fileid_involved_between_revs(self, from_revid, to_revid):
962
"""Find file_id(s) which are involved in the changes between revisions.
964
This determines the set of revisions which are involved, and then
965
finds all file ids affected by those revisions.
967
vf = self._get_revision_vf()
968
from_set = set(vf.get_ancestry(from_revid))
969
to_set = set(vf.get_ancestry(to_revid))
970
changed = to_set.difference(from_set)
971
return self._fileid_involved_by_set(changed)
973
def fileid_involved(self, last_revid=None):
974
"""Find all file_ids modified in the ancestry of last_revid.
976
:param last_revid: If None, last_revision() will be used.
979
changed = set(self.all_revision_ids())
981
changed = set(self.get_ancestry(last_revid))
984
return self._fileid_involved_by_set(changed)
987
def get_ancestry(self, revision_id):
988
"""Return a list of revision-ids integrated by a revision.
990
This is topologically sorted.
992
if revision_id is None:
994
vf = self._get_revision_vf()
996
return [None] + vf.get_ancestry(revision_id)
997
except errors.RevisionNotPresent:
998
raise errors.NoSuchRevision(self, revision_id)
1001
def get_revision(self, revision_id):
1002
"""Return the Revision object for a named revision"""
1003
return self.get_revision_reconcile(revision_id)
1006
def get_revision_graph(self, revision_id=None):
1007
"""Return a dictionary containing the revision graph.
1009
:param revision_id: The revision_id to get a graph from. If None, then
1010
the entire revision graph is returned. This is a deprecated mode of
1011
operation and will be removed in the future.
1012
:return: a dictionary of revision_id->revision_parents_list.
1014
# special case NULL_REVISION
1015
if revision_id == _mod_revision.NULL_REVISION:
1017
a_weave = self._get_revision_vf()
1018
entire_graph = a_weave.get_graph()
1019
if revision_id is None:
1020
return a_weave.get_graph()
1021
elif revision_id not in a_weave:
1022
raise errors.NoSuchRevision(self, revision_id)
1024
# add what can be reached from revision_id
1026
pending = set([revision_id])
1027
while len(pending) > 0:
1028
node = pending.pop()
1029
result[node] = a_weave.get_parents(node)
1030
for revision_id in result[node]:
1031
if revision_id not in result:
1032
pending.add(revision_id)
1036
def get_revision_graph_with_ghosts(self, revision_ids=None):
1037
"""Return a graph of the revisions with ghosts marked as applicable.
1039
:param revision_ids: an iterable of revisions to graph or None for all.
1040
:return: a Graph object with the graph reachable from revision_ids.
1042
result = graph.Graph()
1043
vf = self._get_revision_vf()
1044
versions = set(vf.versions())
1045
if not revision_ids:
1046
pending = set(self.all_revision_ids())
1049
pending = set(revision_ids)
1050
# special case NULL_REVISION
1051
if _mod_revision.NULL_REVISION in pending:
1052
pending.remove(_mod_revision.NULL_REVISION)
1053
required = set(pending)
1056
revision_id = pending.pop()
1057
if not revision_id in versions:
1058
if revision_id in required:
1059
raise errors.NoSuchRevision(self, revision_id)
1061
result.add_ghost(revision_id)
1062
# mark it as done so we don't try for it again.
1063
done.add(revision_id)
1065
parent_ids = vf.get_parents_with_ghosts(revision_id)
1066
for parent_id in parent_ids:
1067
# is this queued or done ?
1068
if (parent_id not in pending and
1069
parent_id not in done):
1071
pending.add(parent_id)
1072
result.add_node(revision_id, parent_ids)
1073
done.add(revision_id)
1076
def _get_revision_vf(self):
1077
""":return: a versioned file containing the revisions."""
1078
vf = self._revision_store.get_revision_file(self.get_transaction())
1082
def reconcile(self, other=None, thorough=False):
1083
"""Reconcile this repository."""
1084
from bzrlib.reconcile import KnitReconciler
1085
reconciler = KnitReconciler(self, thorough=thorough)
1086
reconciler.reconcile()
1089
def revision_parents(self, revision_id):
1090
return self._get_revision_vf().get_parents(revision_id)
1093
class KnitRepository2(KnitRepository):
1094
"""Experimental enhanced knit format"""
1096
# corresponds to RepositoryFormatKnit2
1098
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
1099
control_store, text_store):
1100
KnitRepository.__init__(self, _format, a_bzrdir, control_files,
1101
_revision_store, control_store, text_store)
1102
self._transport = control_files._transport
1103
self._serializer = xml6.serializer_v6
1105
def deserialise_inventory(self, revision_id, xml):
1106
"""Transform the xml into an inventory object.
1108
:param revision_id: The expected revision id of the inventory.
1109
:param xml: A serialised inventory.
1111
result = self._serializer.read_inventory_from_string(xml)
1112
assert result.root.revision is not None
1115
def serialise_inventory(self, inv):
1116
"""Transform the inventory object into XML text.
1118
:param revision_id: The expected revision id of the inventory.
1119
:param xml: A serialised inventory.
1121
assert inv.revision_id is not None
1122
assert inv.root.revision is not None
1123
return KnitRepository.serialise_inventory(self, inv)
1125
def get_commit_builder(self, branch, parents, config, timestamp=None,
1126
timezone=None, committer=None, revprops=None,
1128
"""Obtain a CommitBuilder for this repository.
1130
:param branch: Branch to commit to.
1131
:param parents: Revision ids of the parents of the new revision.
1132
:param config: Configuration to use.
1133
:param timestamp: Optional timestamp recorded for commit.
1134
:param timezone: Optional timezone for timestamp.
1135
:param committer: Optional committer to set for commit.
1136
:param revprops: Optional dictionary of revision properties.
1137
:param revision_id: Optional revision id.
1139
return RootCommitBuilder(self, parents, config, timestamp, timezone,
1140
committer, revprops, revision_id)
949
class RepositoryFormatRegistry(registry.Registry):
950
"""Registry of RepositoryFormats.
953
def get(self, format_string):
954
r = registry.Registry.get(self, format_string)
960
format_registry = RepositoryFormatRegistry()
961
"""Registry of formats, indexed by their identifying format string.
963
This can contain either format instances themselves, or classes/factories that
964
can be called to obtain one.
1143
968
#####################################################################
1284
1125
raise NotImplementedError(self.open)
1287
def register_format(klass, format):
1288
klass._formats[format.get_format_string()] = format
1291
def set_default_format(klass, format):
1292
klass._default_format = format
1295
def unregister_format(klass, format):
1296
assert klass._formats[format.get_format_string()] is format
1297
del klass._formats[format.get_format_string()]
1300
class PreSplitOutRepositoryFormat(RepositoryFormat):
1301
"""Base class for the pre split out repository formats."""
1303
rich_root_data = False
1305
def initialize(self, a_bzrdir, shared=False, _internal=False):
1306
"""Create a weave repository.
1308
TODO: when creating split out bzr branch formats, move this to a common
1309
base for Format5, Format6. or something like that.
1312
raise errors.IncompatibleFormat(self, a_bzrdir._format)
1315
# always initialized when the bzrdir is.
1316
return self.open(a_bzrdir, _found=True)
1318
# Create an empty weave
1320
weavefile.write_weave_v5(weave.Weave(), sio)
1321
empty_weave = sio.getvalue()
1323
mutter('creating repository in %s.', a_bzrdir.transport.base)
1324
dirs = ['revision-store', 'weaves']
1325
files = [('inventory.weave', StringIO(empty_weave)),
1328
# FIXME: RBC 20060125 don't peek under the covers
1329
# NB: no need to escape relative paths that are url safe.
1330
control_files = lockable_files.LockableFiles(a_bzrdir.transport,
1331
'branch-lock', lockable_files.TransportLock)
1332
control_files.create_lock()
1333
control_files.lock_write()
1334
control_files._transport.mkdir_multi(dirs,
1335
mode=control_files._dir_mode)
1337
for file, content in files:
1338
control_files.put(file, content)
1340
control_files.unlock()
1341
return self.open(a_bzrdir, _found=True)
1343
def _get_control_store(self, repo_transport, control_files):
1344
"""Return the control store for this repository."""
1345
return self._get_versioned_file_store('',
1350
def _get_text_store(self, transport, control_files):
1351
"""Get a store for file texts for this format."""
1352
raise NotImplementedError(self._get_text_store)
1354
def open(self, a_bzrdir, _found=False):
1355
"""See RepositoryFormat.open()."""
1357
# we are being called directly and must probe.
1358
raise NotImplementedError
1360
repo_transport = a_bzrdir.get_repository_transport(None)
1361
control_files = a_bzrdir._control_files
1362
text_store = self._get_text_store(repo_transport, control_files)
1363
control_store = self._get_control_store(repo_transport, control_files)
1364
_revision_store = self._get_revision_store(repo_transport, control_files)
1365
return AllInOneRepository(_format=self,
1367
_revision_store=_revision_store,
1368
control_store=control_store,
1369
text_store=text_store)
1371
def check_conversion_target(self, target_format):
1375
class RepositoryFormat4(PreSplitOutRepositoryFormat):
1376
"""Bzr repository format 4.
1378
This repository format has:
1380
- TextStores for texts, inventories,revisions.
1382
This format is deprecated: it indexes texts using a text id which is
1383
removed in format 5; initialization and write support for this format
1388
super(RepositoryFormat4, self).__init__()
1389
self._matchingbzrdir = bzrdir.BzrDirFormat4()
1391
def get_format_description(self):
1392
"""See RepositoryFormat.get_format_description()."""
1393
return "Repository format 4"
1395
def initialize(self, url, shared=False, _internal=False):
1396
"""Format 4 branches cannot be created."""
1397
raise errors.UninitializableFormat(self)
1399
def is_supported(self):
1400
"""Format 4 is not supported.
1402
It is not supported because the model changed from 4 to 5 and the
1403
conversion logic is expensive - so doing it on the fly was not
1408
def _get_control_store(self, repo_transport, control_files):
1409
"""Format 4 repositories have no formal control store at this point.
1411
This will cause any control-file-needing apis to fail - this is desired.
1415
def _get_revision_store(self, repo_transport, control_files):
1416
"""See RepositoryFormat._get_revision_store()."""
1417
from bzrlib.xml4 import serializer_v4
1418
return self._get_text_rev_store(repo_transport,
1421
serializer=serializer_v4)
1423
def _get_text_store(self, transport, control_files):
1424
"""See RepositoryFormat._get_text_store()."""
1427
class RepositoryFormat5(PreSplitOutRepositoryFormat):
1428
"""Bzr control format 5.
1430
This repository format has:
1431
- weaves for file texts and inventory
1433
- TextStores for revisions and signatures.
1437
super(RepositoryFormat5, self).__init__()
1438
self._matchingbzrdir = bzrdir.BzrDirFormat5()
1440
def get_format_description(self):
1441
"""See RepositoryFormat.get_format_description()."""
1442
return "Weave repository format 5"
1444
def _get_revision_store(self, repo_transport, control_files):
1445
"""See RepositoryFormat._get_revision_store()."""
1446
"""Return the revision store object for this a_bzrdir."""
1447
return self._get_text_rev_store(repo_transport,
1452
def _get_text_store(self, transport, control_files):
1453
"""See RepositoryFormat._get_text_store()."""
1454
return self._get_versioned_file_store('weaves', transport, control_files, prefixed=False)
1457
class RepositoryFormat6(PreSplitOutRepositoryFormat):
1458
"""Bzr control format 6.
1460
This repository format has:
1461
- weaves for file texts and inventory
1462
- hash subdirectory based stores.
1463
- TextStores for revisions and signatures.
1467
super(RepositoryFormat6, self).__init__()
1468
self._matchingbzrdir = bzrdir.BzrDirFormat6()
1470
def get_format_description(self):
1471
"""See RepositoryFormat.get_format_description()."""
1472
return "Weave repository format 6"
1474
def _get_revision_store(self, repo_transport, control_files):
1475
"""See RepositoryFormat._get_revision_store()."""
1476
return self._get_text_rev_store(repo_transport,
1482
def _get_text_store(self, transport, control_files):
1483
"""See RepositoryFormat._get_text_store()."""
1484
return self._get_versioned_file_store('weaves', transport, control_files)
1487
1128
class MetaDirRepositoryFormat(RepositoryFormat):
1488
1129
"""Common base class for the new repositories using the metadir layout."""
1490
1131
rich_root_data = False
1132
_matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1492
1134
def __init__(self):
1493
1135
super(MetaDirRepositoryFormat, self).__init__()
1494
self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1496
1137
def _create_control_files(self, a_bzrdir):
1497
1138
"""Create the required files and the initial control_files object."""
1520
1161
control_files.unlock()
1523
class RepositoryFormat7(MetaDirRepositoryFormat):
1524
"""Bzr repository 7.
1526
This repository format has:
1527
- weaves for file texts and inventory
1528
- hash subdirectory based stores.
1529
- TextStores for revisions and signatures.
1530
- a format marker of its own
1531
- an optional 'shared-storage' flag
1532
- an optional 'no-working-trees' flag
1535
def _get_control_store(self, repo_transport, control_files):
1536
"""Return the control store for this repository."""
1537
return self._get_versioned_file_store('',
1542
def get_format_string(self):
1543
"""See RepositoryFormat.get_format_string()."""
1544
return "Bazaar-NG Repository format 7"
1546
def get_format_description(self):
1547
"""See RepositoryFormat.get_format_description()."""
1548
return "Weave repository format 7"
1550
def check_conversion_target(self, target_format):
1553
def _get_revision_store(self, repo_transport, control_files):
1554
"""See RepositoryFormat._get_revision_store()."""
1555
return self._get_text_rev_store(repo_transport,
1562
def _get_text_store(self, transport, control_files):
1563
"""See RepositoryFormat._get_text_store()."""
1564
return self._get_versioned_file_store('weaves',
1568
def initialize(self, a_bzrdir, shared=False):
1569
"""Create a weave repository.
1571
:param shared: If true the repository will be initialized as a shared
1574
# Create an empty weave
1576
weavefile.write_weave_v5(weave.Weave(), sio)
1577
empty_weave = sio.getvalue()
1579
mutter('creating repository in %s.', a_bzrdir.transport.base)
1580
dirs = ['revision-store', 'weaves']
1581
files = [('inventory.weave', StringIO(empty_weave)),
1583
utf8_files = [('format', self.get_format_string())]
1585
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1586
return self.open(a_bzrdir=a_bzrdir, _found=True)
1588
def open(self, a_bzrdir, _found=False, _override_transport=None):
1589
"""See RepositoryFormat.open().
1591
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1592
repository at a slightly different url
1593
than normal. I.e. during 'upgrade'.
1596
format = RepositoryFormat.find_format(a_bzrdir)
1597
assert format.__class__ == self.__class__
1598
if _override_transport is not None:
1599
repo_transport = _override_transport
1601
repo_transport = a_bzrdir.get_repository_transport(None)
1602
control_files = lockable_files.LockableFiles(repo_transport,
1603
'lock', lockdir.LockDir)
1604
text_store = self._get_text_store(repo_transport, control_files)
1605
control_store = self._get_control_store(repo_transport, control_files)
1606
_revision_store = self._get_revision_store(repo_transport, control_files)
1607
return WeaveMetaDirRepository(_format=self,
1609
control_files=control_files,
1610
_revision_store=_revision_store,
1611
control_store=control_store,
1612
text_store=text_store)
1615
class RepositoryFormatKnit(MetaDirRepositoryFormat):
1616
"""Bzr repository knit format (generalized).
1618
This repository format has:
1619
- knits for file texts and inventory
1620
- hash subdirectory based stores.
1621
- knits for revisions and signatures
1622
- TextStores for revisions and signatures.
1623
- a format marker of its own
1624
- an optional 'shared-storage' flag
1625
- an optional 'no-working-trees' flag
1629
def _get_control_store(self, repo_transport, control_files):
1630
"""Return the control store for this repository."""
1631
return VersionedFileStore(
1634
file_mode=control_files._file_mode,
1635
versionedfile_class=knit.KnitVersionedFile,
1636
versionedfile_kwargs={'factory':knit.KnitPlainFactory()},
1639
def _get_revision_store(self, repo_transport, control_files):
1640
"""See RepositoryFormat._get_revision_store()."""
1641
from bzrlib.store.revision.knit import KnitRevisionStore
1642
versioned_file_store = VersionedFileStore(
1644
file_mode=control_files._file_mode,
1647
versionedfile_class=knit.KnitVersionedFile,
1648
versionedfile_kwargs={'delta':False,
1649
'factory':knit.KnitPlainFactory(),
1653
return KnitRevisionStore(versioned_file_store)
1655
def _get_text_store(self, transport, control_files):
1656
"""See RepositoryFormat._get_text_store()."""
1657
return self._get_versioned_file_store('knits',
1660
versionedfile_class=knit.KnitVersionedFile,
1661
versionedfile_kwargs={
1662
'create_parent_dir':True,
1663
'delay_create':True,
1664
'dir_mode':control_files._dir_mode,
1668
def initialize(self, a_bzrdir, shared=False):
1669
"""Create a knit format 1 repository.
1671
:param a_bzrdir: bzrdir to contain the new repository; must already
1673
:param shared: If true the repository will be initialized as a shared
1676
mutter('creating repository in %s.', a_bzrdir.transport.base)
1677
dirs = ['revision-store', 'knits']
1679
utf8_files = [('format', self.get_format_string())]
1681
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1682
repo_transport = a_bzrdir.get_repository_transport(None)
1683
control_files = lockable_files.LockableFiles(repo_transport,
1684
'lock', lockdir.LockDir)
1685
control_store = self._get_control_store(repo_transport, control_files)
1686
transaction = transactions.WriteTransaction()
1687
# trigger a write of the inventory store.
1688
control_store.get_weave_or_empty('inventory', transaction)
1689
_revision_store = self._get_revision_store(repo_transport, control_files)
1690
# the revision id here is irrelevant: it will not be stored, and cannot
1692
_revision_store.has_revision_id('A', transaction)
1693
_revision_store.get_signature_file(transaction)
1694
return self.open(a_bzrdir=a_bzrdir, _found=True)
1696
def open(self, a_bzrdir, _found=False, _override_transport=None):
1697
"""See RepositoryFormat.open().
1699
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1700
repository at a slightly different url
1701
than normal. I.e. during 'upgrade'.
1704
format = RepositoryFormat.find_format(a_bzrdir)
1705
assert format.__class__ == self.__class__
1706
if _override_transport is not None:
1707
repo_transport = _override_transport
1709
repo_transport = a_bzrdir.get_repository_transport(None)
1710
control_files = lockable_files.LockableFiles(repo_transport,
1711
'lock', lockdir.LockDir)
1712
text_store = self._get_text_store(repo_transport, control_files)
1713
control_store = self._get_control_store(repo_transport, control_files)
1714
_revision_store = self._get_revision_store(repo_transport, control_files)
1715
return KnitRepository(_format=self,
1717
control_files=control_files,
1718
_revision_store=_revision_store,
1719
control_store=control_store,
1720
text_store=text_store)
1723
class RepositoryFormatKnit1(RepositoryFormatKnit):
1724
"""Bzr repository knit format 1.
1726
This repository format has:
1727
- knits for file texts and inventory
1728
- hash subdirectory based stores.
1729
- knits for revisions and signatures
1730
- TextStores for revisions and signatures.
1731
- a format marker of its own
1732
- an optional 'shared-storage' flag
1733
- an optional 'no-working-trees' flag
1736
This format was introduced in bzr 0.8.
1738
def get_format_string(self):
1739
"""See RepositoryFormat.get_format_string()."""
1740
return "Bazaar-NG Knit Repository Format 1"
1742
def get_format_description(self):
1743
"""See RepositoryFormat.get_format_description()."""
1744
return "Knit repository format 1"
1746
def check_conversion_target(self, target_format):
1750
class RepositoryFormatKnit2(RepositoryFormatKnit):
1751
"""Bzr repository knit format 2.
1753
THIS FORMAT IS EXPERIMENTAL
1754
This repository format has:
1755
- knits for file texts and inventory
1756
- hash subdirectory based stores.
1757
- knits for revisions and signatures
1758
- TextStores for revisions and signatures.
1759
- a format marker of its own
1760
- an optional 'shared-storage' flag
1761
- an optional 'no-working-trees' flag
1763
- Support for recording full info about the tree root
1766
rich_root_data = True
1768
def get_format_string(self):
1769
"""See RepositoryFormat.get_format_string()."""
1770
return "Bazaar Knit Repository Format 2\n"
1772
def get_format_description(self):
1773
"""See RepositoryFormat.get_format_description()."""
1774
return "Knit repository format 2"
1776
def check_conversion_target(self, target_format):
1777
if not target_format.rich_root_data:
1778
raise errors.BadConversionTarget(
1779
'Does not support rich root data.', target_format)
1781
def open(self, a_bzrdir, _found=False, _override_transport=None):
1782
"""See RepositoryFormat.open().
1784
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1785
repository at a slightly different url
1786
than normal. I.e. during 'upgrade'.
1789
format = RepositoryFormat.find_format(a_bzrdir)
1790
assert format.__class__ == self.__class__
1791
if _override_transport is not None:
1792
repo_transport = _override_transport
1794
repo_transport = a_bzrdir.get_repository_transport(None)
1795
control_files = lockable_files.LockableFiles(repo_transport, 'lock',
1797
text_store = self._get_text_store(repo_transport, control_files)
1798
control_store = self._get_control_store(repo_transport, control_files)
1799
_revision_store = self._get_revision_store(repo_transport, control_files)
1800
return KnitRepository2(_format=self,
1802
control_files=control_files,
1803
_revision_store=_revision_store,
1804
control_store=control_store,
1805
text_store=text_store)
1807
def initialize(self, a_bzrdir, shared=False):
1808
repo = super(RepositoryFormatKnit2, self).initialize(a_bzrdir, shared)
1809
repo._transport.put_bytes_non_atomic('tags', '')
1812
def supports_tags(self):
1817
1164
# formats which have no format string are not discoverable
1818
# and not independently creatable, so are not registered.
1819
RepositoryFormat.register_format(RepositoryFormat7())
1820
# KEEP in sync with bzrdir.format_registry default
1821
_default_format = RepositoryFormatKnit1()
1822
RepositoryFormat.register_format(_default_format)
1823
RepositoryFormat.register_format(RepositoryFormatKnit2())
1824
RepositoryFormat.set_default_format(_default_format)
1825
_legacy_formats = [RepositoryFormat4(),
1826
RepositoryFormat5(),
1827
RepositoryFormat6()]
1165
# and not independently creatable, so are not registered. They're
1166
# all in bzrlib.repofmt.weaverepo now. When an instance of one of these is
1167
# needed, it's constructed directly by the BzrDir. Non-native formats where
1168
# the repository is not separately opened are similar.
1170
format_registry.register_lazy(
1171
'Bazaar-NG Repository format 7',
1172
'bzrlib.repofmt.weaverepo',
1175
# KEEP in sync with bzrdir.format_registry default, which controls the overall
1176
# default control directory format
1178
format_registry.register_lazy(
1179
'Bazaar-NG Knit Repository Format 1',
1180
'bzrlib.repofmt.knitrepo',
1181
'RepositoryFormatKnit1',
1183
format_registry.default_key = 'Bazaar-NG Knit Repository Format 1'
1185
format_registry.register_lazy(
1186
'Bazaar Knit Repository Format 2\n',
1187
'bzrlib.repofmt.knitrepo',
1188
'RepositoryFormatKnit2',
1830
1192
class InterRepository(InterObject):