827
865
raise errors.NonAsciiRevisionId(method, self)
830
class AllInOneRepository(Repository):
831
"""Legacy support - the repository behaviour for all-in-one branches."""
833
def __init__(self, _format, a_bzrdir, _revision_store, control_store, text_store):
834
# we reuse one control files instance.
835
dir_mode = a_bzrdir._control_files._dir_mode
836
file_mode = a_bzrdir._control_files._file_mode
838
def get_store(name, compressed=True, prefixed=False):
839
# FIXME: This approach of assuming stores are all entirely compressed
840
# or entirely uncompressed is tidy, but breaks upgrade from
841
# some existing branches where there's a mixture; we probably
842
# still want the option to look for both.
843
relpath = a_bzrdir._control_files._escape(name)
844
store = TextStore(a_bzrdir._control_files._transport.clone(relpath),
845
prefixed=prefixed, compressed=compressed,
848
#if self._transport.should_cache():
849
# cache_path = os.path.join(self.cache_root, name)
850
# os.mkdir(cache_path)
851
# store = bzrlib.store.CachedStore(store, cache_path)
854
# not broken out yet because the controlweaves|inventory_store
855
# and text_store | weave_store bits are still different.
856
if isinstance(_format, RepositoryFormat4):
857
# cannot remove these - there is still no consistent api
858
# which allows access to this old info.
859
self.inventory_store = get_store('inventory-store')
860
text_store = get_store('text-store')
861
super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files, _revision_store, control_store, text_store)
863
def get_commit_builder(self, branch, parents, config, timestamp=None,
864
timezone=None, committer=None, revprops=None,
866
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
867
return Repository.get_commit_builder(self, branch, parents, config,
868
timestamp, timezone, committer, revprops, revision_id)
872
"""AllInOne repositories cannot be shared."""
876
def set_make_working_trees(self, new_value):
877
"""Set the policy flag for making working trees when creating branches.
879
This only applies to branches that use this repository.
881
The default is 'True'.
882
:param new_value: True to restore the default, False to disable making
885
raise NotImplementedError(self.set_make_working_trees)
887
def make_working_trees(self):
888
"""Returns the policy for making working trees on new branches."""
869
# remove these delegates a while after bzr 0.15
870
def __make_delegated(name, from_module):
871
def _deprecated_repository_forwarder():
872
symbol_versioning.warn('%s moved to %s in bzr 0.15'
873
% (name, from_module),
876
m = __import__(from_module, globals(), locals(), [name])
878
return getattr(m, name)
879
except AttributeError:
880
raise AttributeError('module %s has no name %s'
882
globals()[name] = _deprecated_repository_forwarder
885
'AllInOneRepository',
886
'WeaveMetaDirRepository',
887
'PreSplitOutRepositoryFormat',
893
__make_delegated(_name, 'bzrlib.repofmt.weaverepo')
898
'RepositoryFormatKnit',
899
'RepositoryFormatKnit1',
900
'RepositoryFormatKnit2',
902
__make_delegated(_name, 'bzrlib.repofmt.knitrepo')
892
905
def install_revision(repository, rev, revision_tree):
978
991
return not self.control_files._transport.has('no-working-trees')
981
class WeaveMetaDirRepository(MetaDirRepository):
982
"""A subclass of MetaDirRepository to set weave specific policy."""
984
def get_commit_builder(self, branch, parents, config, timestamp=None,
985
timezone=None, committer=None, revprops=None,
987
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
988
return MetaDirRepository.get_commit_builder(self, branch, parents,
989
config, timestamp, timezone, committer, revprops, revision_id)
992
class KnitRepository(MetaDirRepository):
993
"""Knit format repository."""
995
def _warn_if_deprecated(self):
996
# This class isn't deprecated
999
def _inventory_add_lines(self, inv_vf, revid, parents, lines):
1000
inv_vf.add_lines_with_ghosts(revid, parents, lines)
1003
def _all_revision_ids(self):
1004
"""See Repository.all_revision_ids()."""
1005
# Knits get the revision graph from the index of the revision knit, so
1006
# it's always possible even if they're on an unlistable transport.
1007
return self._revision_store.all_revision_ids(self.get_transaction())
1009
def fileid_involved_between_revs(self, from_revid, to_revid):
1010
"""Find file_id(s) which are involved in the changes between revisions.
1012
This determines the set of revisions which are involved, and then
1013
finds all file ids affected by those revisions.
1015
# TODO: jam 20070210 Is this function even used?
1016
from_revid = osutils.safe_revision_id(from_revid)
1017
to_revid = osutils.safe_revision_id(to_revid)
1018
vf = self._get_revision_vf()
1019
from_set = set(vf.get_ancestry(from_revid))
1020
to_set = set(vf.get_ancestry(to_revid))
1021
changed = to_set.difference(from_set)
1022
return self._fileid_involved_by_set(changed)
1024
def fileid_involved(self, last_revid=None):
1025
"""Find all file_ids modified in the ancestry of last_revid.
1027
:param last_revid: If None, last_revision() will be used.
1029
# TODO: jam 20070210 Is this used anymore?
1031
changed = set(self.all_revision_ids())
1033
changed = set(self.get_ancestry(last_revid))
1035
changed.remove(None)
1036
return self._fileid_involved_by_set(changed)
1039
def get_ancestry(self, revision_id):
1040
"""Return a list of revision-ids integrated by a revision.
1042
This is topologically sorted.
1044
if revision_id is None:
1046
revision_id = osutils.safe_revision_id(revision_id)
1047
vf = self._get_revision_vf()
1049
return [None] + vf.get_ancestry(revision_id)
1050
except errors.RevisionNotPresent:
1051
raise errors.NoSuchRevision(self, revision_id)
1054
def get_revision(self, revision_id):
1055
"""Return the Revision object for a named revision"""
1056
revision_id = osutils.safe_revision_id(revision_id)
1057
return self.get_revision_reconcile(revision_id)
1060
def get_revision_graph(self, revision_id=None):
1061
"""Return a dictionary containing the revision graph.
1063
:param revision_id: The revision_id to get a graph from. If None, then
1064
the entire revision graph is returned. This is a deprecated mode of
1065
operation and will be removed in the future.
1066
:return: a dictionary of revision_id->revision_parents_list.
1068
# special case NULL_REVISION
1069
if revision_id == _mod_revision.NULL_REVISION:
1071
revision_id = osutils.safe_revision_id(revision_id)
1072
a_weave = self._get_revision_vf()
1073
entire_graph = a_weave.get_graph()
1074
if revision_id is None:
1075
return a_weave.get_graph()
1076
elif revision_id not in a_weave:
1077
raise errors.NoSuchRevision(self, revision_id)
1079
# add what can be reached from revision_id
1081
pending = set([revision_id])
1082
while len(pending) > 0:
1083
node = pending.pop()
1084
result[node] = a_weave.get_parents(node)
1085
for revision_id in result[node]:
1086
if revision_id not in result:
1087
pending.add(revision_id)
1091
def get_revision_graph_with_ghosts(self, revision_ids=None):
1092
"""Return a graph of the revisions with ghosts marked as applicable.
1094
:param revision_ids: an iterable of revisions to graph or None for all.
1095
:return: a Graph object with the graph reachable from revision_ids.
1097
result = graph.Graph()
1098
vf = self._get_revision_vf()
1099
versions = set(vf.versions())
1100
if not revision_ids:
1101
pending = set(self.all_revision_ids())
1104
pending = set(osutils.safe_revision_id(r) for r in revision_ids)
1105
# special case NULL_REVISION
1106
if _mod_revision.NULL_REVISION in pending:
1107
pending.remove(_mod_revision.NULL_REVISION)
1108
required = set(pending)
1111
revision_id = pending.pop()
1112
if not revision_id in versions:
1113
if revision_id in required:
1114
raise errors.NoSuchRevision(self, revision_id)
1116
result.add_ghost(revision_id)
1117
# mark it as done so we don't try for it again.
1118
done.add(revision_id)
1120
parent_ids = vf.get_parents_with_ghosts(revision_id)
1121
for parent_id in parent_ids:
1122
# is this queued or done ?
1123
if (parent_id not in pending and
1124
parent_id not in done):
1126
pending.add(parent_id)
1127
result.add_node(revision_id, parent_ids)
1128
done.add(revision_id)
1131
def _get_revision_vf(self):
1132
""":return: a versioned file containing the revisions."""
1133
vf = self._revision_store.get_revision_file(self.get_transaction())
1137
def reconcile(self, other=None, thorough=False):
1138
"""Reconcile this repository."""
1139
from bzrlib.reconcile import KnitReconciler
1140
reconciler = KnitReconciler(self, thorough=thorough)
1141
reconciler.reconcile()
1144
def revision_parents(self, revision_id):
1145
revision_id = osutils.safe_revision_id(revision_id)
1146
return self._get_revision_vf().get_parents(revision_id)
1149
class KnitRepository2(KnitRepository):
1151
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
1152
control_store, text_store):
1153
KnitRepository.__init__(self, _format, a_bzrdir, control_files,
1154
_revision_store, control_store, text_store)
1155
self._serializer = xml6.serializer_v6
1157
def deserialise_inventory(self, revision_id, xml):
1158
"""Transform the xml into an inventory object.
1160
:param revision_id: The expected revision id of the inventory.
1161
:param xml: A serialised inventory.
1163
result = self._serializer.read_inventory_from_string(xml)
1164
assert result.root.revision is not None
1167
def serialise_inventory(self, inv):
1168
"""Transform the inventory object into XML text.
1170
:param revision_id: The expected revision id of the inventory.
1171
:param xml: A serialised inventory.
1173
assert inv.revision_id is not None
1174
assert inv.root.revision is not None
1175
return KnitRepository.serialise_inventory(self, inv)
1177
def get_commit_builder(self, branch, parents, config, timestamp=None,
1178
timezone=None, committer=None, revprops=None,
1180
"""Obtain a CommitBuilder for this repository.
1182
:param branch: Branch to commit to.
1183
:param parents: Revision ids of the parents of the new revision.
1184
:param config: Configuration to use.
1185
:param timestamp: Optional timestamp recorded for commit.
1186
:param timezone: Optional timezone for timestamp.
1187
:param committer: Optional committer to set for commit.
1188
:param revprops: Optional dictionary of revision properties.
1189
:param revision_id: Optional revision id.
1191
revision_id = osutils.safe_revision_id(revision_id)
1192
return RootCommitBuilder(self, parents, config, timestamp, timezone,
1193
committer, revprops, revision_id)
1196
994
class RepositoryFormatRegistry(registry.Registry):
1197
995
"""Registry of RepositoryFormats.
998
def get(self, format_string):
999
r = registry.Registry.get(self, format_string)
1201
1005
format_registry = RepositoryFormatRegistry()
1202
"""Registry of formats, indexed by their identifying format string."""
1006
"""Registry of formats, indexed by their identifying format string.
1008
This can contain either format instances themselves, or classes/factories that
1009
can be called to obtain one.
1205
1013
class RepositoryFormat(object):
1363
1167
raise NotImplementedError(self.open)
1366
class PreSplitOutRepositoryFormat(RepositoryFormat):
1367
"""Base class for the pre split out repository formats."""
1369
rich_root_data = False
1371
def initialize(self, a_bzrdir, shared=False, _internal=False):
1372
"""Create a weave repository.
1374
TODO: when creating split out bzr branch formats, move this to a common
1375
base for Format5, Format6. or something like that.
1378
raise errors.IncompatibleFormat(self, a_bzrdir._format)
1381
# always initialized when the bzrdir is.
1382
return self.open(a_bzrdir, _found=True)
1384
# Create an empty weave
1386
weavefile.write_weave_v5(weave.Weave(), sio)
1387
empty_weave = sio.getvalue()
1389
mutter('creating repository in %s.', a_bzrdir.transport.base)
1390
dirs = ['revision-store', 'weaves']
1391
files = [('inventory.weave', StringIO(empty_weave)),
1394
# FIXME: RBC 20060125 don't peek under the covers
1395
# NB: no need to escape relative paths that are url safe.
1396
control_files = lockable_files.LockableFiles(a_bzrdir.transport,
1397
'branch-lock', lockable_files.TransportLock)
1398
control_files.create_lock()
1399
control_files.lock_write()
1400
control_files._transport.mkdir_multi(dirs,
1401
mode=control_files._dir_mode)
1403
for file, content in files:
1404
control_files.put(file, content)
1406
control_files.unlock()
1407
return self.open(a_bzrdir, _found=True)
1409
def _get_control_store(self, repo_transport, control_files):
1410
"""Return the control store for this repository."""
1411
return self._get_versioned_file_store('',
1416
def _get_text_store(self, transport, control_files):
1417
"""Get a store for file texts for this format."""
1418
raise NotImplementedError(self._get_text_store)
1420
def open(self, a_bzrdir, _found=False):
1421
"""See RepositoryFormat.open()."""
1423
# we are being called directly and must probe.
1424
raise NotImplementedError
1426
repo_transport = a_bzrdir.get_repository_transport(None)
1427
control_files = a_bzrdir._control_files
1428
text_store = self._get_text_store(repo_transport, control_files)
1429
control_store = self._get_control_store(repo_transport, control_files)
1430
_revision_store = self._get_revision_store(repo_transport, control_files)
1431
return AllInOneRepository(_format=self,
1433
_revision_store=_revision_store,
1434
control_store=control_store,
1435
text_store=text_store)
1437
def check_conversion_target(self, target_format):
1441
class RepositoryFormat4(PreSplitOutRepositoryFormat):
1442
"""Bzr repository format 4.
1444
This repository format has:
1446
- TextStores for texts, inventories,revisions.
1448
This format is deprecated: it indexes texts using a text id which is
1449
removed in format 5; initialization and write support for this format
1454
super(RepositoryFormat4, self).__init__()
1455
self._matchingbzrdir = bzrdir.BzrDirFormat4()
1457
def get_format_description(self):
1458
"""See RepositoryFormat.get_format_description()."""
1459
return "Repository format 4"
1461
def initialize(self, url, shared=False, _internal=False):
1462
"""Format 4 branches cannot be created."""
1463
raise errors.UninitializableFormat(self)
1465
def is_supported(self):
1466
"""Format 4 is not supported.
1468
It is not supported because the model changed from 4 to 5 and the
1469
conversion logic is expensive - so doing it on the fly was not
1474
def _get_control_store(self, repo_transport, control_files):
1475
"""Format 4 repositories have no formal control store at this point.
1477
This will cause any control-file-needing apis to fail - this is desired.
1481
def _get_revision_store(self, repo_transport, control_files):
1482
"""See RepositoryFormat._get_revision_store()."""
1483
from bzrlib.xml4 import serializer_v4
1484
return self._get_text_rev_store(repo_transport,
1487
serializer=serializer_v4)
1489
def _get_text_store(self, transport, control_files):
1490
"""See RepositoryFormat._get_text_store()."""
1493
class RepositoryFormat5(PreSplitOutRepositoryFormat):
1494
"""Bzr control format 5.
1496
This repository format has:
1497
- weaves for file texts and inventory
1499
- TextStores for revisions and signatures.
1503
super(RepositoryFormat5, self).__init__()
1504
self._matchingbzrdir = bzrdir.BzrDirFormat5()
1506
def get_format_description(self):
1507
"""See RepositoryFormat.get_format_description()."""
1508
return "Weave repository format 5"
1510
def _get_revision_store(self, repo_transport, control_files):
1511
"""See RepositoryFormat._get_revision_store()."""
1512
"""Return the revision store object for this a_bzrdir."""
1513
return self._get_text_rev_store(repo_transport,
1518
def _get_text_store(self, transport, control_files):
1519
"""See RepositoryFormat._get_text_store()."""
1520
return self._get_versioned_file_store('weaves', transport, control_files, prefixed=False)
1523
class RepositoryFormat6(PreSplitOutRepositoryFormat):
1524
"""Bzr control format 6.
1526
This repository format has:
1527
- weaves for file texts and inventory
1528
- hash subdirectory based stores.
1529
- TextStores for revisions and signatures.
1533
super(RepositoryFormat6, self).__init__()
1534
self._matchingbzrdir = bzrdir.BzrDirFormat6()
1536
def get_format_description(self):
1537
"""See RepositoryFormat.get_format_description()."""
1538
return "Weave repository format 6"
1540
def _get_revision_store(self, repo_transport, control_files):
1541
"""See RepositoryFormat._get_revision_store()."""
1542
return self._get_text_rev_store(repo_transport,
1548
def _get_text_store(self, transport, control_files):
1549
"""See RepositoryFormat._get_text_store()."""
1550
return self._get_versioned_file_store('weaves', transport, control_files)
1553
1170
class MetaDirRepositoryFormat(RepositoryFormat):
1554
1171
"""Common base class for the new repositories using the metadir layout."""
1556
1173
rich_root_data = False
1174
_matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1558
1176
def __init__(self):
1559
1177
super(MetaDirRepositoryFormat, self).__init__()
1560
self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1562
1179
def _create_control_files(self, a_bzrdir):
1563
1180
"""Create the required files and the initial control_files object."""
1586
1203
control_files.unlock()
1589
class RepositoryFormat7(MetaDirRepositoryFormat):
1590
"""Bzr repository 7.
1592
This repository format has:
1593
- weaves for file texts and inventory
1594
- hash subdirectory based stores.
1595
- TextStores for revisions and signatures.
1596
- a format marker of its own
1597
- an optional 'shared-storage' flag
1598
- an optional 'no-working-trees' flag
1601
def _get_control_store(self, repo_transport, control_files):
1602
"""Return the control store for this repository."""
1603
return self._get_versioned_file_store('',
1608
def get_format_string(self):
1609
"""See RepositoryFormat.get_format_string()."""
1610
return "Bazaar-NG Repository format 7"
1612
def get_format_description(self):
1613
"""See RepositoryFormat.get_format_description()."""
1614
return "Weave repository format 7"
1616
def check_conversion_target(self, target_format):
1619
def _get_revision_store(self, repo_transport, control_files):
1620
"""See RepositoryFormat._get_revision_store()."""
1621
return self._get_text_rev_store(repo_transport,
1628
def _get_text_store(self, transport, control_files):
1629
"""See RepositoryFormat._get_text_store()."""
1630
return self._get_versioned_file_store('weaves',
1634
def initialize(self, a_bzrdir, shared=False):
1635
"""Create a weave repository.
1637
:param shared: If true the repository will be initialized as a shared
1640
# Create an empty weave
1642
weavefile.write_weave_v5(weave.Weave(), sio)
1643
empty_weave = sio.getvalue()
1645
mutter('creating repository in %s.', a_bzrdir.transport.base)
1646
dirs = ['revision-store', 'weaves']
1647
files = [('inventory.weave', StringIO(empty_weave)),
1649
utf8_files = [('format', self.get_format_string())]
1651
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1652
return self.open(a_bzrdir=a_bzrdir, _found=True)
1654
def open(self, a_bzrdir, _found=False, _override_transport=None):
1655
"""See RepositoryFormat.open().
1657
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1658
repository at a slightly different url
1659
than normal. I.e. during 'upgrade'.
1662
format = RepositoryFormat.find_format(a_bzrdir)
1663
assert format.__class__ == self.__class__
1664
if _override_transport is not None:
1665
repo_transport = _override_transport
1667
repo_transport = a_bzrdir.get_repository_transport(None)
1668
control_files = lockable_files.LockableFiles(repo_transport,
1669
'lock', lockdir.LockDir)
1670
text_store = self._get_text_store(repo_transport, control_files)
1671
control_store = self._get_control_store(repo_transport, control_files)
1672
_revision_store = self._get_revision_store(repo_transport, control_files)
1673
return WeaveMetaDirRepository(_format=self,
1675
control_files=control_files,
1676
_revision_store=_revision_store,
1677
control_store=control_store,
1678
text_store=text_store)
1681
class RepositoryFormatKnit(MetaDirRepositoryFormat):
1682
"""Bzr repository knit format (generalized).
1684
This repository format has:
1685
- knits for file texts and inventory
1686
- hash subdirectory based stores.
1687
- knits for revisions and signatures
1688
- TextStores for revisions and signatures.
1689
- a format marker of its own
1690
- an optional 'shared-storage' flag
1691
- an optional 'no-working-trees' flag
1695
def _get_control_store(self, repo_transport, control_files):
1696
"""Return the control store for this repository."""
1697
return VersionedFileStore(
1700
file_mode=control_files._file_mode,
1701
versionedfile_class=knit.KnitVersionedFile,
1702
versionedfile_kwargs={'factory':knit.KnitPlainFactory()},
1705
def _get_revision_store(self, repo_transport, control_files):
1706
"""See RepositoryFormat._get_revision_store()."""
1707
from bzrlib.store.revision.knit import KnitRevisionStore
1708
versioned_file_store = VersionedFileStore(
1710
file_mode=control_files._file_mode,
1713
versionedfile_class=knit.KnitVersionedFile,
1714
versionedfile_kwargs={'delta':False,
1715
'factory':knit.KnitPlainFactory(),
1719
return KnitRevisionStore(versioned_file_store)
1721
def _get_text_store(self, transport, control_files):
1722
"""See RepositoryFormat._get_text_store()."""
1723
return self._get_versioned_file_store('knits',
1726
versionedfile_class=knit.KnitVersionedFile,
1727
versionedfile_kwargs={
1728
'create_parent_dir':True,
1729
'delay_create':True,
1730
'dir_mode':control_files._dir_mode,
1734
def initialize(self, a_bzrdir, shared=False):
1735
"""Create a knit format 1 repository.
1737
:param a_bzrdir: bzrdir to contain the new repository; must already
1739
:param shared: If true the repository will be initialized as a shared
1742
mutter('creating repository in %s.', a_bzrdir.transport.base)
1743
dirs = ['revision-store', 'knits']
1745
utf8_files = [('format', self.get_format_string())]
1747
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1748
repo_transport = a_bzrdir.get_repository_transport(None)
1749
control_files = lockable_files.LockableFiles(repo_transport,
1750
'lock', lockdir.LockDir)
1751
control_store = self._get_control_store(repo_transport, control_files)
1752
transaction = transactions.WriteTransaction()
1753
# trigger a write of the inventory store.
1754
control_store.get_weave_or_empty('inventory', transaction)
1755
_revision_store = self._get_revision_store(repo_transport, control_files)
1756
# the revision id here is irrelevant: it will not be stored, and cannot
1758
_revision_store.has_revision_id('A', transaction)
1759
_revision_store.get_signature_file(transaction)
1760
return self.open(a_bzrdir=a_bzrdir, _found=True)
1762
def open(self, a_bzrdir, _found=False, _override_transport=None):
1763
"""See RepositoryFormat.open().
1765
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1766
repository at a slightly different url
1767
than normal. I.e. during 'upgrade'.
1770
format = RepositoryFormat.find_format(a_bzrdir)
1771
assert format.__class__ == self.__class__
1772
if _override_transport is not None:
1773
repo_transport = _override_transport
1775
repo_transport = a_bzrdir.get_repository_transport(None)
1776
control_files = lockable_files.LockableFiles(repo_transport,
1777
'lock', lockdir.LockDir)
1778
text_store = self._get_text_store(repo_transport, control_files)
1779
control_store = self._get_control_store(repo_transport, control_files)
1780
_revision_store = self._get_revision_store(repo_transport, control_files)
1781
return KnitRepository(_format=self,
1783
control_files=control_files,
1784
_revision_store=_revision_store,
1785
control_store=control_store,
1786
text_store=text_store)
1789
class RepositoryFormatKnit1(RepositoryFormatKnit):
1790
"""Bzr repository knit format 1.
1792
This repository format has:
1793
- knits for file texts and inventory
1794
- hash subdirectory based stores.
1795
- knits for revisions and signatures
1796
- TextStores for revisions and signatures.
1797
- a format marker of its own
1798
- an optional 'shared-storage' flag
1799
- an optional 'no-working-trees' flag
1802
This format was introduced in bzr 0.8.
1804
def get_format_string(self):
1805
"""See RepositoryFormat.get_format_string()."""
1806
return "Bazaar-NG Knit Repository Format 1"
1808
def get_format_description(self):
1809
"""See RepositoryFormat.get_format_description()."""
1810
return "Knit repository format 1"
1812
def check_conversion_target(self, target_format):
1816
class RepositoryFormatKnit2(RepositoryFormatKnit):
1817
"""Bzr repository knit format 2.
1819
THIS FORMAT IS EXPERIMENTAL
1820
This repository format has:
1821
- knits for file texts and inventory
1822
- hash subdirectory based stores.
1823
- knits for revisions and signatures
1824
- TextStores for revisions and signatures.
1825
- a format marker of its own
1826
- an optional 'shared-storage' flag
1827
- an optional 'no-working-trees' flag
1829
- Support for recording full info about the tree root
1833
rich_root_data = True
1835
def get_format_string(self):
1836
"""See RepositoryFormat.get_format_string()."""
1837
return "Bazaar Knit Repository Format 2\n"
1839
def get_format_description(self):
1840
"""See RepositoryFormat.get_format_description()."""
1841
return "Knit repository format 2"
1843
def check_conversion_target(self, target_format):
1844
if not target_format.rich_root_data:
1845
raise errors.BadConversionTarget(
1846
'Does not support rich root data.', target_format)
1848
def open(self, a_bzrdir, _found=False, _override_transport=None):
1849
"""See RepositoryFormat.open().
1851
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1852
repository at a slightly different url
1853
than normal. I.e. during 'upgrade'.
1856
format = RepositoryFormat.find_format(a_bzrdir)
1857
assert format.__class__ == self.__class__
1858
if _override_transport is not None:
1859
repo_transport = _override_transport
1861
repo_transport = a_bzrdir.get_repository_transport(None)
1862
control_files = lockable_files.LockableFiles(repo_transport, 'lock',
1864
text_store = self._get_text_store(repo_transport, control_files)
1865
control_store = self._get_control_store(repo_transport, control_files)
1866
_revision_store = self._get_revision_store(repo_transport, control_files)
1867
return KnitRepository2(_format=self,
1869
control_files=control_files,
1870
_revision_store=_revision_store,
1871
control_store=control_store,
1872
text_store=text_store)
1876
1206
# formats which have no format string are not discoverable
1877
# and not independently creatable, so are not registered.
1878
RepositoryFormat.register_format(RepositoryFormat7())
1207
# and not independently creatable, so are not registered. They're
1208
# all in bzrlib.repofmt.weaverepo now. When an instance of one of these is
1209
# needed, it's constructed directly by the BzrDir. Non-native formats where
1210
# the repository is not separately opened are similar.
1212
format_registry.register_lazy(
1213
'Bazaar-NG Repository format 7',
1214
'bzrlib.repofmt.weaverepo',
1879
1217
# KEEP in sync with bzrdir.format_registry default, which controls the overall
1880
1218
# default control directory format
1881
_default_format = RepositoryFormatKnit1()
1882
RepositoryFormat.register_format(_default_format)
1883
RepositoryFormat.register_format(RepositoryFormatKnit2())
1884
RepositoryFormat._set_default_format(_default_format)
1885
_legacy_formats = [RepositoryFormat4(),
1886
RepositoryFormat5(),
1887
RepositoryFormat6()]
1220
format_registry.register_lazy(
1221
'Bazaar-NG Knit Repository Format 1',
1222
'bzrlib.repofmt.knitrepo',
1223
'RepositoryFormatKnit1',
1225
format_registry.default_key = 'Bazaar-NG Knit Repository Format 1'
1227
format_registry.register_lazy(
1228
'Bazaar Knit Repository Format 2\n',
1229
'bzrlib.repofmt.knitrepo',
1230
'RepositoryFormatKnit2',
1890
1234
class InterRepository(InterObject):