93
def add_inventory(self, revid, inv, parents):
94
"""Add the inventory inv to the repository as revid.
81
def add_inventory(self, revision_id, inv, parents):
82
"""Add the inventory inv to the repository as revision_id.
96
:param parents: The revision ids of the parents that revid
84
:param parents: The revision ids of the parents that revision_id
97
85
is known to have and are in the repository already.
99
87
returns the sha1 of the serialized inventory.
101
_mod_revision.check_not_reserved_id(revid)
102
assert inv.revision_id is None or inv.revision_id == revid, \
89
revision_id = osutils.safe_revision_id(revision_id)
90
_mod_revision.check_not_reserved_id(revision_id)
91
assert inv.revision_id is None or inv.revision_id == revision_id, \
103
92
"Mismatch between inventory revision" \
104
" id and insertion revid (%r, %r)" % (inv.revision_id, revid)
93
" id and insertion revid (%r, %r)" % (inv.revision_id, revision_id)
105
94
assert inv.root is not None
106
95
inv_text = self.serialise_inventory(inv)
107
96
inv_sha1 = osutils.sha_string(inv_text)
108
97
inv_vf = self.control_weaves.get_weave('inventory',
109
98
self.get_transaction())
110
self._inventory_add_lines(inv_vf, revid, parents, osutils.split_lines(inv_text))
99
self._inventory_add_lines(inv_vf, revision_id, parents,
100
osutils.split_lines(inv_text))
113
def _inventory_add_lines(self, inv_vf, revid, parents, lines):
103
def _inventory_add_lines(self, inv_vf, revision_id, parents, lines):
114
104
final_parents = []
115
105
for parent in parents:
116
106
if parent in inv_vf:
117
107
final_parents.append(parent)
119
inv_vf.add_lines(revid, final_parents, lines)
109
inv_vf.add_lines(revision_id, final_parents, lines)
121
111
@needs_write_lock
122
def add_revision(self, rev_id, rev, inv=None, config=None):
123
"""Add rev to the revision store as rev_id.
112
def add_revision(self, revision_id, rev, inv=None, config=None):
113
"""Add rev to the revision store as revision_id.
125
:param rev_id: the revision id to use.
115
:param revision_id: the revision id to use.
126
116
:param rev: The revision object.
127
117
:param inv: The inventory for the revision. if None, it will be looked
128
118
up in the inventory storer
777
884
revision_id.encode('ascii')
778
885
except UnicodeEncodeError:
779
886
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."""
889
revision_id.decode('ascii')
890
except UnicodeDecodeError:
891
raise errors.NonAsciiRevisionId(method, self)
895
# remove these delegates a while after bzr 0.15
896
def __make_delegated(name, from_module):
897
def _deprecated_repository_forwarder():
898
symbol_versioning.warn('%s moved to %s in bzr 0.15'
899
% (name, from_module),
902
m = __import__(from_module, globals(), locals(), [name])
904
return getattr(m, name)
905
except AttributeError:
906
raise AttributeError('module %s has no name %s'
908
globals()[name] = _deprecated_repository_forwarder
911
'AllInOneRepository',
912
'WeaveMetaDirRepository',
913
'PreSplitOutRepositoryFormat',
919
__make_delegated(_name, 'bzrlib.repofmt.weaverepo')
924
'RepositoryFormatKnit',
925
'RepositoryFormatKnit1',
926
'RepositoryFormatKnit2',
928
__make_delegated(_name, 'bzrlib.repofmt.knitrepo')
844
931
def install_revision(repository, rev, revision_tree):
930
1017
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):
1095
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
1096
control_store, text_store):
1097
KnitRepository.__init__(self, _format, a_bzrdir, control_files,
1098
_revision_store, control_store, text_store)
1099
self._serializer = xml6.serializer_v6
1101
def deserialise_inventory(self, revision_id, xml):
1102
"""Transform the xml into an inventory object.
1104
:param revision_id: The expected revision id of the inventory.
1105
:param xml: A serialised inventory.
1107
result = self._serializer.read_inventory_from_string(xml)
1108
assert result.root.revision is not None
1111
def serialise_inventory(self, inv):
1112
"""Transform the inventory object into XML text.
1114
:param revision_id: The expected revision id of the inventory.
1115
:param xml: A serialised inventory.
1117
assert inv.revision_id is not None
1118
assert inv.root.revision is not None
1119
return KnitRepository.serialise_inventory(self, inv)
1121
def get_commit_builder(self, branch, parents, config, timestamp=None,
1122
timezone=None, committer=None, revprops=None,
1124
"""Obtain a CommitBuilder for this repository.
1126
:param branch: Branch to commit to.
1127
:param parents: Revision ids of the parents of the new revision.
1128
:param config: Configuration to use.
1129
:param timestamp: Optional timestamp recorded for commit.
1130
:param timezone: Optional timezone for timestamp.
1131
:param committer: Optional committer to set for commit.
1132
:param revprops: Optional dictionary of revision properties.
1133
:param revision_id: Optional revision id.
1135
return RootCommitBuilder(self, parents, config, timestamp, timezone,
1136
committer, revprops, revision_id)
1139
1020
class RepositoryFormatRegistry(registry.Registry):
1140
1021
"""Registry of RepositoryFormats.
1024
def get(self, format_string):
1025
r = registry.Registry.get(self, format_string)
1144
1031
format_registry = RepositoryFormatRegistry()
1145
"""Registry of formats, indexed by their identifying format string."""
1032
"""Registry of formats, indexed by their identifying format string.
1034
This can contain either format instances themselves, or classes/factories that
1035
can be called to obtain one.
1148
1039
class RepositoryFormat(object):
1306
1193
raise NotImplementedError(self.open)
1309
class PreSplitOutRepositoryFormat(RepositoryFormat):
1310
"""Base class for the pre split out repository formats."""
1312
rich_root_data = False
1314
def initialize(self, a_bzrdir, shared=False, _internal=False):
1315
"""Create a weave repository.
1317
TODO: when creating split out bzr branch formats, move this to a common
1318
base for Format5, Format6. or something like that.
1321
raise errors.IncompatibleFormat(self, a_bzrdir._format)
1324
# always initialized when the bzrdir is.
1325
return self.open(a_bzrdir, _found=True)
1327
# Create an empty weave
1329
weavefile.write_weave_v5(weave.Weave(), sio)
1330
empty_weave = sio.getvalue()
1332
mutter('creating repository in %s.', a_bzrdir.transport.base)
1333
dirs = ['revision-store', 'weaves']
1334
files = [('inventory.weave', StringIO(empty_weave)),
1337
# FIXME: RBC 20060125 don't peek under the covers
1338
# NB: no need to escape relative paths that are url safe.
1339
control_files = lockable_files.LockableFiles(a_bzrdir.transport,
1340
'branch-lock', lockable_files.TransportLock)
1341
control_files.create_lock()
1342
control_files.lock_write()
1343
control_files._transport.mkdir_multi(dirs,
1344
mode=control_files._dir_mode)
1346
for file, content in files:
1347
control_files.put(file, content)
1349
control_files.unlock()
1350
return self.open(a_bzrdir, _found=True)
1352
def _get_control_store(self, repo_transport, control_files):
1353
"""Return the control store for this repository."""
1354
return self._get_versioned_file_store('',
1359
def _get_text_store(self, transport, control_files):
1360
"""Get a store for file texts for this format."""
1361
raise NotImplementedError(self._get_text_store)
1363
def open(self, a_bzrdir, _found=False):
1364
"""See RepositoryFormat.open()."""
1366
# we are being called directly and must probe.
1367
raise NotImplementedError
1369
repo_transport = a_bzrdir.get_repository_transport(None)
1370
control_files = a_bzrdir._control_files
1371
text_store = self._get_text_store(repo_transport, control_files)
1372
control_store = self._get_control_store(repo_transport, control_files)
1373
_revision_store = self._get_revision_store(repo_transport, control_files)
1374
return AllInOneRepository(_format=self,
1376
_revision_store=_revision_store,
1377
control_store=control_store,
1378
text_store=text_store)
1380
def check_conversion_target(self, target_format):
1384
class RepositoryFormat4(PreSplitOutRepositoryFormat):
1385
"""Bzr repository format 4.
1387
This repository format has:
1389
- TextStores for texts, inventories,revisions.
1391
This format is deprecated: it indexes texts using a text id which is
1392
removed in format 5; initialization and write support for this format
1397
super(RepositoryFormat4, self).__init__()
1398
self._matchingbzrdir = bzrdir.BzrDirFormat4()
1400
def get_format_description(self):
1401
"""See RepositoryFormat.get_format_description()."""
1402
return "Repository format 4"
1404
def initialize(self, url, shared=False, _internal=False):
1405
"""Format 4 branches cannot be created."""
1406
raise errors.UninitializableFormat(self)
1408
def is_supported(self):
1409
"""Format 4 is not supported.
1411
It is not supported because the model changed from 4 to 5 and the
1412
conversion logic is expensive - so doing it on the fly was not
1417
def _get_control_store(self, repo_transport, control_files):
1418
"""Format 4 repositories have no formal control store at this point.
1420
This will cause any control-file-needing apis to fail - this is desired.
1424
def _get_revision_store(self, repo_transport, control_files):
1425
"""See RepositoryFormat._get_revision_store()."""
1426
from bzrlib.xml4 import serializer_v4
1427
return self._get_text_rev_store(repo_transport,
1430
serializer=serializer_v4)
1432
def _get_text_store(self, transport, control_files):
1433
"""See RepositoryFormat._get_text_store()."""
1436
class RepositoryFormat5(PreSplitOutRepositoryFormat):
1437
"""Bzr control format 5.
1439
This repository format has:
1440
- weaves for file texts and inventory
1442
- TextStores for revisions and signatures.
1446
super(RepositoryFormat5, self).__init__()
1447
self._matchingbzrdir = bzrdir.BzrDirFormat5()
1449
def get_format_description(self):
1450
"""See RepositoryFormat.get_format_description()."""
1451
return "Weave repository format 5"
1453
def _get_revision_store(self, repo_transport, control_files):
1454
"""See RepositoryFormat._get_revision_store()."""
1455
"""Return the revision store object for this a_bzrdir."""
1456
return self._get_text_rev_store(repo_transport,
1461
def _get_text_store(self, transport, control_files):
1462
"""See RepositoryFormat._get_text_store()."""
1463
return self._get_versioned_file_store('weaves', transport, control_files, prefixed=False)
1466
class RepositoryFormat6(PreSplitOutRepositoryFormat):
1467
"""Bzr control format 6.
1469
This repository format has:
1470
- weaves for file texts and inventory
1471
- hash subdirectory based stores.
1472
- TextStores for revisions and signatures.
1476
super(RepositoryFormat6, self).__init__()
1477
self._matchingbzrdir = bzrdir.BzrDirFormat6()
1479
def get_format_description(self):
1480
"""See RepositoryFormat.get_format_description()."""
1481
return "Weave repository format 6"
1483
def _get_revision_store(self, repo_transport, control_files):
1484
"""See RepositoryFormat._get_revision_store()."""
1485
return self._get_text_rev_store(repo_transport,
1491
def _get_text_store(self, transport, control_files):
1492
"""See RepositoryFormat._get_text_store()."""
1493
return self._get_versioned_file_store('weaves', transport, control_files)
1496
1196
class MetaDirRepositoryFormat(RepositoryFormat):
1497
1197
"""Common base class for the new repositories using the metadir layout."""
1499
1199
rich_root_data = False
1200
_matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1501
1202
def __init__(self):
1502
1203
super(MetaDirRepositoryFormat, self).__init__()
1503
self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1505
1205
def _create_control_files(self, a_bzrdir):
1506
1206
"""Create the required files and the initial control_files object."""
1529
1229
control_files.unlock()
1532
class RepositoryFormat7(MetaDirRepositoryFormat):
1533
"""Bzr repository 7.
1535
This repository format has:
1536
- weaves for file texts and inventory
1537
- hash subdirectory based stores.
1538
- TextStores for revisions and signatures.
1539
- a format marker of its own
1540
- an optional 'shared-storage' flag
1541
- an optional 'no-working-trees' flag
1544
def _get_control_store(self, repo_transport, control_files):
1545
"""Return the control store for this repository."""
1546
return self._get_versioned_file_store('',
1551
def get_format_string(self):
1552
"""See RepositoryFormat.get_format_string()."""
1553
return "Bazaar-NG Repository format 7"
1555
def get_format_description(self):
1556
"""See RepositoryFormat.get_format_description()."""
1557
return "Weave repository format 7"
1559
def check_conversion_target(self, target_format):
1562
def _get_revision_store(self, repo_transport, control_files):
1563
"""See RepositoryFormat._get_revision_store()."""
1564
return self._get_text_rev_store(repo_transport,
1571
def _get_text_store(self, transport, control_files):
1572
"""See RepositoryFormat._get_text_store()."""
1573
return self._get_versioned_file_store('weaves',
1577
def initialize(self, a_bzrdir, shared=False):
1578
"""Create a weave repository.
1580
:param shared: If true the repository will be initialized as a shared
1583
# Create an empty weave
1585
weavefile.write_weave_v5(weave.Weave(), sio)
1586
empty_weave = sio.getvalue()
1588
mutter('creating repository in %s.', a_bzrdir.transport.base)
1589
dirs = ['revision-store', 'weaves']
1590
files = [('inventory.weave', StringIO(empty_weave)),
1592
utf8_files = [('format', self.get_format_string())]
1594
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1595
return self.open(a_bzrdir=a_bzrdir, _found=True)
1597
def open(self, a_bzrdir, _found=False, _override_transport=None):
1598
"""See RepositoryFormat.open().
1600
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1601
repository at a slightly different url
1602
than normal. I.e. during 'upgrade'.
1605
format = RepositoryFormat.find_format(a_bzrdir)
1606
assert format.__class__ == self.__class__
1607
if _override_transport is not None:
1608
repo_transport = _override_transport
1610
repo_transport = a_bzrdir.get_repository_transport(None)
1611
control_files = lockable_files.LockableFiles(repo_transport,
1612
'lock', lockdir.LockDir)
1613
text_store = self._get_text_store(repo_transport, control_files)
1614
control_store = self._get_control_store(repo_transport, control_files)
1615
_revision_store = self._get_revision_store(repo_transport, control_files)
1616
return WeaveMetaDirRepository(_format=self,
1618
control_files=control_files,
1619
_revision_store=_revision_store,
1620
control_store=control_store,
1621
text_store=text_store)
1624
class RepositoryFormatKnit(MetaDirRepositoryFormat):
1625
"""Bzr repository knit format (generalized).
1627
This repository format has:
1628
- knits for file texts and inventory
1629
- hash subdirectory based stores.
1630
- knits for revisions and signatures
1631
- TextStores for revisions and signatures.
1632
- a format marker of its own
1633
- an optional 'shared-storage' flag
1634
- an optional 'no-working-trees' flag
1638
def _get_control_store(self, repo_transport, control_files):
1639
"""Return the control store for this repository."""
1640
return VersionedFileStore(
1643
file_mode=control_files._file_mode,
1644
versionedfile_class=knit.KnitVersionedFile,
1645
versionedfile_kwargs={'factory':knit.KnitPlainFactory()},
1648
def _get_revision_store(self, repo_transport, control_files):
1649
"""See RepositoryFormat._get_revision_store()."""
1650
from bzrlib.store.revision.knit import KnitRevisionStore
1651
versioned_file_store = VersionedFileStore(
1653
file_mode=control_files._file_mode,
1656
versionedfile_class=knit.KnitVersionedFile,
1657
versionedfile_kwargs={'delta':False,
1658
'factory':knit.KnitPlainFactory(),
1662
return KnitRevisionStore(versioned_file_store)
1664
def _get_text_store(self, transport, control_files):
1665
"""See RepositoryFormat._get_text_store()."""
1666
return self._get_versioned_file_store('knits',
1669
versionedfile_class=knit.KnitVersionedFile,
1670
versionedfile_kwargs={
1671
'create_parent_dir':True,
1672
'delay_create':True,
1673
'dir_mode':control_files._dir_mode,
1677
def initialize(self, a_bzrdir, shared=False):
1678
"""Create a knit format 1 repository.
1680
:param a_bzrdir: bzrdir to contain the new repository; must already
1682
:param shared: If true the repository will be initialized as a shared
1685
mutter('creating repository in %s.', a_bzrdir.transport.base)
1686
dirs = ['revision-store', 'knits']
1688
utf8_files = [('format', self.get_format_string())]
1690
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1691
repo_transport = a_bzrdir.get_repository_transport(None)
1692
control_files = lockable_files.LockableFiles(repo_transport,
1693
'lock', lockdir.LockDir)
1694
control_store = self._get_control_store(repo_transport, control_files)
1695
transaction = transactions.WriteTransaction()
1696
# trigger a write of the inventory store.
1697
control_store.get_weave_or_empty('inventory', transaction)
1698
_revision_store = self._get_revision_store(repo_transport, control_files)
1699
# the revision id here is irrelevant: it will not be stored, and cannot
1701
_revision_store.has_revision_id('A', transaction)
1702
_revision_store.get_signature_file(transaction)
1703
return self.open(a_bzrdir=a_bzrdir, _found=True)
1705
def open(self, a_bzrdir, _found=False, _override_transport=None):
1706
"""See RepositoryFormat.open().
1708
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1709
repository at a slightly different url
1710
than normal. I.e. during 'upgrade'.
1713
format = RepositoryFormat.find_format(a_bzrdir)
1714
assert format.__class__ == self.__class__
1715
if _override_transport is not None:
1716
repo_transport = _override_transport
1718
repo_transport = a_bzrdir.get_repository_transport(None)
1719
control_files = lockable_files.LockableFiles(repo_transport,
1720
'lock', lockdir.LockDir)
1721
text_store = self._get_text_store(repo_transport, control_files)
1722
control_store = self._get_control_store(repo_transport, control_files)
1723
_revision_store = self._get_revision_store(repo_transport, control_files)
1724
return KnitRepository(_format=self,
1726
control_files=control_files,
1727
_revision_store=_revision_store,
1728
control_store=control_store,
1729
text_store=text_store)
1732
class RepositoryFormatKnit1(RepositoryFormatKnit):
1733
"""Bzr repository knit format 1.
1735
This repository format has:
1736
- knits for file texts and inventory
1737
- hash subdirectory based stores.
1738
- knits for revisions and signatures
1739
- TextStores for revisions and signatures.
1740
- a format marker of its own
1741
- an optional 'shared-storage' flag
1742
- an optional 'no-working-trees' flag
1745
This format was introduced in bzr 0.8.
1747
def get_format_string(self):
1748
"""See RepositoryFormat.get_format_string()."""
1749
return "Bazaar-NG Knit Repository Format 1"
1751
def get_format_description(self):
1752
"""See RepositoryFormat.get_format_description()."""
1753
return "Knit repository format 1"
1755
def check_conversion_target(self, target_format):
1759
class RepositoryFormatKnit2(RepositoryFormatKnit):
1760
"""Bzr repository knit format 2.
1762
THIS FORMAT IS EXPERIMENTAL
1763
This repository format has:
1764
- knits for file texts and inventory
1765
- hash subdirectory based stores.
1766
- knits for revisions and signatures
1767
- TextStores for revisions and signatures.
1768
- a format marker of its own
1769
- an optional 'shared-storage' flag
1770
- an optional 'no-working-trees' flag
1772
- Support for recording full info about the tree root
1776
rich_root_data = True
1778
def get_format_string(self):
1779
"""See RepositoryFormat.get_format_string()."""
1780
return "Bazaar Knit Repository Format 2\n"
1782
def get_format_description(self):
1783
"""See RepositoryFormat.get_format_description()."""
1784
return "Knit repository format 2"
1786
def check_conversion_target(self, target_format):
1787
if not target_format.rich_root_data:
1788
raise errors.BadConversionTarget(
1789
'Does not support rich root data.', target_format)
1791
def open(self, a_bzrdir, _found=False, _override_transport=None):
1792
"""See RepositoryFormat.open().
1794
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1795
repository at a slightly different url
1796
than normal. I.e. during 'upgrade'.
1799
format = RepositoryFormat.find_format(a_bzrdir)
1800
assert format.__class__ == self.__class__
1801
if _override_transport is not None:
1802
repo_transport = _override_transport
1804
repo_transport = a_bzrdir.get_repository_transport(None)
1805
control_files = lockable_files.LockableFiles(repo_transport, 'lock',
1807
text_store = self._get_text_store(repo_transport, control_files)
1808
control_store = self._get_control_store(repo_transport, control_files)
1809
_revision_store = self._get_revision_store(repo_transport, control_files)
1810
return KnitRepository2(_format=self,
1812
control_files=control_files,
1813
_revision_store=_revision_store,
1814
control_store=control_store,
1815
text_store=text_store)
1819
1232
# formats which have no format string are not discoverable
1820
# and not independently creatable, so are not registered.
1821
RepositoryFormat.register_format(RepositoryFormat7())
1233
# and not independently creatable, so are not registered. They're
1234
# all in bzrlib.repofmt.weaverepo now. When an instance of one of these is
1235
# needed, it's constructed directly by the BzrDir. Non-native formats where
1236
# the repository is not separately opened are similar.
1238
format_registry.register_lazy(
1239
'Bazaar-NG Repository format 7',
1240
'bzrlib.repofmt.weaverepo',
1822
1243
# KEEP in sync with bzrdir.format_registry default, which controls the overall
1823
1244
# default control directory format
1824
_default_format = RepositoryFormatKnit1()
1825
RepositoryFormat.register_format(_default_format)
1826
RepositoryFormat.register_format(RepositoryFormatKnit2())
1827
RepositoryFormat._set_default_format(_default_format)
1828
_legacy_formats = [RepositoryFormat4(),
1829
RepositoryFormat5(),
1830
RepositoryFormat6()]
1246
format_registry.register_lazy(
1247
'Bazaar-NG Knit Repository Format 1',
1248
'bzrlib.repofmt.knitrepo',
1249
'RepositoryFormatKnit1',
1251
format_registry.default_key = 'Bazaar-NG Knit Repository Format 1'
1253
format_registry.register_lazy(
1254
'Bazaar Knit Repository Format 2\n',
1255
'bzrlib.repofmt.knitrepo',
1256
'RepositoryFormatKnit2',
1833
1260
class InterRepository(InterObject):