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
855
912
revision_id.encode('ascii')
856
913
except UnicodeEncodeError:
857
914
raise errors.NonAsciiRevisionId(method, self)
860
class AllInOneRepository(Repository):
861
"""Legacy support - the repository behaviour for all-in-one branches."""
863
def __init__(self, _format, a_bzrdir, _revision_store, control_store, text_store):
864
# we reuse one control files instance.
865
dir_mode = a_bzrdir._control_files._dir_mode
866
file_mode = a_bzrdir._control_files._file_mode
868
def get_store(name, compressed=True, prefixed=False):
869
# FIXME: This approach of assuming stores are all entirely compressed
870
# or entirely uncompressed is tidy, but breaks upgrade from
871
# some existing branches where there's a mixture; we probably
872
# still want the option to look for both.
873
relpath = a_bzrdir._control_files._escape(name)
874
store = TextStore(a_bzrdir._control_files._transport.clone(relpath),
875
prefixed=prefixed, compressed=compressed,
878
#if self._transport.should_cache():
879
# cache_path = os.path.join(self.cache_root, name)
880
# os.mkdir(cache_path)
881
# store = bzrlib.store.CachedStore(store, cache_path)
884
# not broken out yet because the controlweaves|inventory_store
885
# and text_store | weave_store bits are still different.
886
if isinstance(_format, RepositoryFormat4):
887
# cannot remove these - there is still no consistent api
888
# which allows access to this old info.
889
self.inventory_store = get_store('inventory-store')
890
text_store = get_store('text-store')
891
super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files, _revision_store, control_store, text_store)
893
def get_commit_builder(self, branch, parents, config, timestamp=None,
894
timezone=None, committer=None, revprops=None,
896
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
897
return Repository.get_commit_builder(self, branch, parents, config,
898
timestamp, timezone, committer, revprops, revision_id)
902
"""AllInOne repositories cannot be shared."""
906
def set_make_working_trees(self, new_value):
907
"""Set the policy flag for making working trees when creating branches.
909
This only applies to branches that use this repository.
911
The default is 'True'.
912
:param new_value: True to restore the default, False to disable making
915
raise NotImplementedError(self.set_make_working_trees)
917
def make_working_trees(self):
918
"""Returns the policy for making working trees on new branches."""
917
revision_id.decode('ascii')
918
except UnicodeDecodeError:
919
raise errors.NonAsciiRevisionId(method, self)
923
# remove these delegates a while after bzr 0.15
924
def __make_delegated(name, from_module):
925
def _deprecated_repository_forwarder():
926
symbol_versioning.warn('%s moved to %s in bzr 0.15'
927
% (name, from_module),
930
m = __import__(from_module, globals(), locals(), [name])
932
return getattr(m, name)
933
except AttributeError:
934
raise AttributeError('module %s has no name %s'
936
globals()[name] = _deprecated_repository_forwarder
939
'AllInOneRepository',
940
'WeaveMetaDirRepository',
941
'PreSplitOutRepositoryFormat',
947
__make_delegated(_name, 'bzrlib.repofmt.weaverepo')
952
'RepositoryFormatKnit',
953
'RepositoryFormatKnit1',
954
'RepositoryFormatKnit2',
956
__make_delegated(_name, 'bzrlib.repofmt.knitrepo')
922
959
def install_revision(repository, rev, revision_tree):
1008
1045
return not self.control_files._transport.has('no-working-trees')
1011
class WeaveMetaDirRepository(MetaDirRepository):
1012
"""A subclass of MetaDirRepository to set weave specific policy."""
1014
def get_commit_builder(self, branch, parents, config, timestamp=None,
1015
timezone=None, committer=None, revprops=None,
1017
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
1018
return MetaDirRepository.get_commit_builder(self, branch, parents,
1019
config, timestamp, timezone, committer, revprops, revision_id)
1022
class KnitRepository(MetaDirRepository):
1023
"""Knit format repository."""
1025
def _warn_if_deprecated(self):
1026
# This class isn't deprecated
1029
def _inventory_add_lines(self, inv_vf, revid, parents, lines):
1030
inv_vf.add_lines_with_ghosts(revid, parents, lines)
1033
def _all_revision_ids(self):
1034
"""See Repository.all_revision_ids()."""
1035
# Knits get the revision graph from the index of the revision knit, so
1036
# it's always possible even if they're on an unlistable transport.
1037
return self._revision_store.all_revision_ids(self.get_transaction())
1039
def fileid_involved_between_revs(self, from_revid, to_revid):
1040
"""Find file_id(s) which are involved in the changes between revisions.
1042
This determines the set of revisions which are involved, and then
1043
finds all file ids affected by those revisions.
1045
vf = self._get_revision_vf()
1046
from_set = set(vf.get_ancestry(from_revid))
1047
to_set = set(vf.get_ancestry(to_revid))
1048
changed = to_set.difference(from_set)
1049
return self._fileid_involved_by_set(changed)
1051
def fileid_involved(self, last_revid=None):
1052
"""Find all file_ids modified in the ancestry of last_revid.
1054
:param last_revid: If None, last_revision() will be used.
1057
changed = set(self.all_revision_ids())
1059
changed = set(self.get_ancestry(last_revid))
1061
changed.remove(None)
1062
return self._fileid_involved_by_set(changed)
1065
def get_ancestry(self, revision_id):
1066
"""Return a list of revision-ids integrated by a revision.
1068
This is topologically sorted.
1070
if revision_id is None:
1072
vf = self._get_revision_vf()
1074
return [None] + vf.get_ancestry(revision_id)
1075
except errors.RevisionNotPresent:
1076
raise errors.NoSuchRevision(self, revision_id)
1079
def get_revision(self, revision_id):
1080
"""Return the Revision object for a named revision"""
1081
return self.get_revision_reconcile(revision_id)
1084
def get_revision_graph(self, revision_id=None):
1085
"""Return a dictionary containing the revision graph.
1087
:param revision_id: The revision_id to get a graph from. If None, then
1088
the entire revision graph is returned. This is a deprecated mode of
1089
operation and will be removed in the future.
1090
:return: a dictionary of revision_id->revision_parents_list.
1092
# special case NULL_REVISION
1093
if revision_id == _mod_revision.NULL_REVISION:
1095
a_weave = self._get_revision_vf()
1096
entire_graph = a_weave.get_graph()
1097
if revision_id is None:
1098
return a_weave.get_graph()
1099
elif revision_id not in a_weave:
1100
raise errors.NoSuchRevision(self, revision_id)
1102
# add what can be reached from revision_id
1104
pending = set([revision_id])
1105
while len(pending) > 0:
1106
node = pending.pop()
1107
result[node] = a_weave.get_parents(node)
1108
for revision_id in result[node]:
1109
if revision_id not in result:
1110
pending.add(revision_id)
1114
def get_revision_graph_with_ghosts(self, revision_ids=None):
1115
"""Return a graph of the revisions with ghosts marked as applicable.
1117
:param revision_ids: an iterable of revisions to graph or None for all.
1118
:return: a Graph object with the graph reachable from revision_ids.
1120
result = graph.Graph()
1121
vf = self._get_revision_vf()
1122
versions = set(vf.versions())
1123
if not revision_ids:
1124
pending = set(self.all_revision_ids())
1127
pending = set(revision_ids)
1128
# special case NULL_REVISION
1129
if _mod_revision.NULL_REVISION in pending:
1130
pending.remove(_mod_revision.NULL_REVISION)
1131
required = set(pending)
1134
revision_id = pending.pop()
1135
if not revision_id in versions:
1136
if revision_id in required:
1137
raise errors.NoSuchRevision(self, revision_id)
1139
result.add_ghost(revision_id)
1140
# mark it as done so we don't try for it again.
1141
done.add(revision_id)
1143
parent_ids = vf.get_parents_with_ghosts(revision_id)
1144
for parent_id in parent_ids:
1145
# is this queued or done ?
1146
if (parent_id not in pending and
1147
parent_id not in done):
1149
pending.add(parent_id)
1150
result.add_node(revision_id, parent_ids)
1151
done.add(revision_id)
1154
def _get_revision_vf(self):
1155
""":return: a versioned file containing the revisions."""
1156
vf = self._revision_store.get_revision_file(self.get_transaction())
1160
def reconcile(self, other=None, thorough=False):
1161
"""Reconcile this repository."""
1162
from bzrlib.reconcile import KnitReconciler
1163
reconciler = KnitReconciler(self, thorough=thorough)
1164
reconciler.reconcile()
1167
def revision_parents(self, revision_id):
1168
return self._get_revision_vf().get_parents(revision_id)
1171
class KnitRepository2(KnitRepository):
1173
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
1174
control_store, text_store):
1175
KnitRepository.__init__(self, _format, a_bzrdir, control_files,
1176
_revision_store, control_store, text_store)
1177
self._serializer = xml6.serializer_v6
1179
def deserialise_inventory(self, revision_id, xml):
1180
"""Transform the xml into an inventory object.
1182
:param revision_id: The expected revision id of the inventory.
1183
:param xml: A serialised inventory.
1185
result = self._serializer.read_inventory_from_string(xml)
1186
assert result.root.revision is not None
1189
def serialise_inventory(self, inv):
1190
"""Transform the inventory object into XML text.
1192
:param revision_id: The expected revision id of the inventory.
1193
:param xml: A serialised inventory.
1195
assert inv.revision_id is not None
1196
assert inv.root.revision is not None
1197
return KnitRepository.serialise_inventory(self, inv)
1199
def get_commit_builder(self, branch, parents, config, timestamp=None,
1200
timezone=None, committer=None, revprops=None,
1202
"""Obtain a CommitBuilder for this repository.
1204
:param branch: Branch to commit to.
1205
:param parents: Revision ids of the parents of the new revision.
1206
:param config: Configuration to use.
1207
:param timestamp: Optional timestamp recorded for commit.
1208
:param timezone: Optional timezone for timestamp.
1209
:param committer: Optional committer to set for commit.
1210
:param revprops: Optional dictionary of revision properties.
1211
:param revision_id: Optional revision id.
1213
return RootCommitBuilder(self, parents, config, timestamp, timezone,
1214
committer, revprops, revision_id)
1217
1048
class RepositoryFormatRegistry(registry.Registry):
1218
1049
"""Registry of RepositoryFormats.
1052
def get(self, format_string):
1053
r = registry.Registry.get(self, format_string)
1222
1059
format_registry = RepositoryFormatRegistry()
1223
"""Registry of formats, indexed by their identifying format string."""
1060
"""Registry of formats, indexed by their identifying format string.
1062
This can contain either format instances themselves, or classes/factories that
1063
can be called to obtain one.
1226
1067
class RepositoryFormat(object):
1374
1223
raise NotImplementedError(self.open)
1377
class PreSplitOutRepositoryFormat(RepositoryFormat):
1378
"""Base class for the pre split out repository formats."""
1380
rich_root_data = False
1382
def initialize(self, a_bzrdir, shared=False, _internal=False):
1383
"""Create a weave repository.
1385
TODO: when creating split out bzr branch formats, move this to a common
1386
base for Format5, Format6. or something like that.
1389
raise errors.IncompatibleFormat(self, a_bzrdir._format)
1392
# always initialized when the bzrdir is.
1393
return self.open(a_bzrdir, _found=True)
1395
# Create an empty weave
1397
weavefile.write_weave_v5(weave.Weave(), sio)
1398
empty_weave = sio.getvalue()
1400
mutter('creating repository in %s.', a_bzrdir.transport.base)
1401
dirs = ['revision-store', 'weaves']
1402
files = [('inventory.weave', StringIO(empty_weave)),
1405
# FIXME: RBC 20060125 don't peek under the covers
1406
# NB: no need to escape relative paths that are url safe.
1407
control_files = lockable_files.LockableFiles(a_bzrdir.transport,
1408
'branch-lock', lockable_files.TransportLock)
1409
control_files.create_lock()
1410
control_files.lock_write()
1411
control_files._transport.mkdir_multi(dirs,
1412
mode=control_files._dir_mode)
1414
for file, content in files:
1415
control_files.put(file, content)
1417
control_files.unlock()
1418
return self.open(a_bzrdir, _found=True)
1420
def _get_control_store(self, repo_transport, control_files):
1421
"""Return the control store for this repository."""
1422
return self._get_versioned_file_store('',
1427
def _get_text_store(self, transport, control_files):
1428
"""Get a store for file texts for this format."""
1429
raise NotImplementedError(self._get_text_store)
1431
def open(self, a_bzrdir, _found=False):
1432
"""See RepositoryFormat.open()."""
1434
# we are being called directly and must probe.
1435
raise NotImplementedError
1437
repo_transport = a_bzrdir.get_repository_transport(None)
1438
control_files = a_bzrdir._control_files
1439
text_store = self._get_text_store(repo_transport, control_files)
1440
control_store = self._get_control_store(repo_transport, control_files)
1441
_revision_store = self._get_revision_store(repo_transport, control_files)
1442
return AllInOneRepository(_format=self,
1444
_revision_store=_revision_store,
1445
control_store=control_store,
1446
text_store=text_store)
1448
def check_conversion_target(self, target_format):
1452
class RepositoryFormat4(PreSplitOutRepositoryFormat):
1453
"""Bzr repository format 4.
1455
This repository format has:
1457
- TextStores for texts, inventories,revisions.
1459
This format is deprecated: it indexes texts using a text id which is
1460
removed in format 5; initialization and write support for this format
1465
super(RepositoryFormat4, self).__init__()
1466
self._matchingbzrdir = bzrdir.BzrDirFormat4()
1468
def get_format_description(self):
1469
"""See RepositoryFormat.get_format_description()."""
1470
return "Repository format 4"
1472
def initialize(self, url, shared=False, _internal=False):
1473
"""Format 4 branches cannot be created."""
1474
raise errors.UninitializableFormat(self)
1476
def is_supported(self):
1477
"""Format 4 is not supported.
1479
It is not supported because the model changed from 4 to 5 and the
1480
conversion logic is expensive - so doing it on the fly was not
1485
def _get_control_store(self, repo_transport, control_files):
1486
"""Format 4 repositories have no formal control store at this point.
1488
This will cause any control-file-needing apis to fail - this is desired.
1492
def _get_revision_store(self, repo_transport, control_files):
1493
"""See RepositoryFormat._get_revision_store()."""
1494
from bzrlib.xml4 import serializer_v4
1495
return self._get_text_rev_store(repo_transport,
1498
serializer=serializer_v4)
1500
def _get_text_store(self, transport, control_files):
1501
"""See RepositoryFormat._get_text_store()."""
1504
class RepositoryFormat5(PreSplitOutRepositoryFormat):
1505
"""Bzr control format 5.
1507
This repository format has:
1508
- weaves for file texts and inventory
1510
- TextStores for revisions and signatures.
1514
super(RepositoryFormat5, self).__init__()
1515
self._matchingbzrdir = bzrdir.BzrDirFormat5()
1517
def get_format_description(self):
1518
"""See RepositoryFormat.get_format_description()."""
1519
return "Weave repository format 5"
1521
def _get_revision_store(self, repo_transport, control_files):
1522
"""See RepositoryFormat._get_revision_store()."""
1523
"""Return the revision store object for this a_bzrdir."""
1524
return self._get_text_rev_store(repo_transport,
1529
def _get_text_store(self, transport, control_files):
1530
"""See RepositoryFormat._get_text_store()."""
1531
return self._get_versioned_file_store('weaves', transport, control_files, prefixed=False)
1534
class RepositoryFormat6(PreSplitOutRepositoryFormat):
1535
"""Bzr control format 6.
1537
This repository format has:
1538
- weaves for file texts and inventory
1539
- hash subdirectory based stores.
1540
- TextStores for revisions and signatures.
1544
super(RepositoryFormat6, self).__init__()
1545
self._matchingbzrdir = bzrdir.BzrDirFormat6()
1547
def get_format_description(self):
1548
"""See RepositoryFormat.get_format_description()."""
1549
return "Weave repository format 6"
1551
def _get_revision_store(self, repo_transport, control_files):
1552
"""See RepositoryFormat._get_revision_store()."""
1553
return self._get_text_rev_store(repo_transport,
1559
def _get_text_store(self, transport, control_files):
1560
"""See RepositoryFormat._get_text_store()."""
1561
return self._get_versioned_file_store('weaves', transport, control_files)
1564
1226
class MetaDirRepositoryFormat(RepositoryFormat):
1565
1227
"""Common base class for the new repositories using the metadir layout."""
1567
1229
rich_root_data = False
1230
_matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1569
1232
def __init__(self):
1570
1233
super(MetaDirRepositoryFormat, self).__init__()
1571
self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1573
1235
def _create_control_files(self, a_bzrdir):
1574
1236
"""Create the required files and the initial control_files object."""
1597
1259
control_files.unlock()
1600
class RepositoryFormat7(MetaDirRepositoryFormat):
1601
"""Bzr repository 7.
1603
This repository format has:
1604
- weaves for file texts and inventory
1605
- hash subdirectory based stores.
1606
- TextStores for revisions and signatures.
1607
- a format marker of its own
1608
- an optional 'shared-storage' flag
1609
- an optional 'no-working-trees' flag
1612
def _get_control_store(self, repo_transport, control_files):
1613
"""Return the control store for this repository."""
1614
return self._get_versioned_file_store('',
1619
def get_format_string(self):
1620
"""See RepositoryFormat.get_format_string()."""
1621
return "Bazaar-NG Repository format 7"
1623
def get_format_description(self):
1624
"""See RepositoryFormat.get_format_description()."""
1625
return "Weave repository format 7"
1627
def check_conversion_target(self, target_format):
1630
def _get_revision_store(self, repo_transport, control_files):
1631
"""See RepositoryFormat._get_revision_store()."""
1632
return self._get_text_rev_store(repo_transport,
1639
def _get_text_store(self, transport, control_files):
1640
"""See RepositoryFormat._get_text_store()."""
1641
return self._get_versioned_file_store('weaves',
1645
def initialize(self, a_bzrdir, shared=False):
1646
"""Create a weave repository.
1648
:param shared: If true the repository will be initialized as a shared
1651
# Create an empty weave
1653
weavefile.write_weave_v5(weave.Weave(), sio)
1654
empty_weave = sio.getvalue()
1656
mutter('creating repository in %s.', a_bzrdir.transport.base)
1657
dirs = ['revision-store', 'weaves']
1658
files = [('inventory.weave', StringIO(empty_weave)),
1660
utf8_files = [('format', self.get_format_string())]
1662
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1663
return self.open(a_bzrdir=a_bzrdir, _found=True)
1665
def open(self, a_bzrdir, _found=False, _override_transport=None):
1666
"""See RepositoryFormat.open().
1668
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1669
repository at a slightly different url
1670
than normal. I.e. during 'upgrade'.
1673
format = RepositoryFormat.find_format(a_bzrdir)
1674
assert format.__class__ == self.__class__
1675
if _override_transport is not None:
1676
repo_transport = _override_transport
1678
repo_transport = a_bzrdir.get_repository_transport(None)
1679
control_files = lockable_files.LockableFiles(repo_transport,
1680
'lock', lockdir.LockDir)
1681
text_store = self._get_text_store(repo_transport, control_files)
1682
control_store = self._get_control_store(repo_transport, control_files)
1683
_revision_store = self._get_revision_store(repo_transport, control_files)
1684
return WeaveMetaDirRepository(_format=self,
1686
control_files=control_files,
1687
_revision_store=_revision_store,
1688
control_store=control_store,
1689
text_store=text_store)
1692
class RepositoryFormatKnit(MetaDirRepositoryFormat):
1693
"""Bzr repository knit format (generalized).
1695
This repository format has:
1696
- knits for file texts and inventory
1697
- hash subdirectory based stores.
1698
- knits for revisions and signatures
1699
- TextStores for revisions and signatures.
1700
- a format marker of its own
1701
- an optional 'shared-storage' flag
1702
- an optional 'no-working-trees' flag
1706
def _get_control_store(self, repo_transport, control_files):
1707
"""Return the control store for this repository."""
1708
return VersionedFileStore(
1711
file_mode=control_files._file_mode,
1712
versionedfile_class=knit.KnitVersionedFile,
1713
versionedfile_kwargs={'factory':knit.KnitPlainFactory()},
1716
def _get_revision_store(self, repo_transport, control_files):
1717
"""See RepositoryFormat._get_revision_store()."""
1718
from bzrlib.store.revision.knit import KnitRevisionStore
1719
versioned_file_store = VersionedFileStore(
1721
file_mode=control_files._file_mode,
1724
versionedfile_class=knit.KnitVersionedFile,
1725
versionedfile_kwargs={'delta':False,
1726
'factory':knit.KnitPlainFactory(),
1730
return KnitRevisionStore(versioned_file_store)
1732
def _get_text_store(self, transport, control_files):
1733
"""See RepositoryFormat._get_text_store()."""
1734
return self._get_versioned_file_store('knits',
1737
versionedfile_class=knit.KnitVersionedFile,
1738
versionedfile_kwargs={
1739
'create_parent_dir':True,
1740
'delay_create':True,
1741
'dir_mode':control_files._dir_mode,
1745
def initialize(self, a_bzrdir, shared=False):
1746
"""Create a knit format 1 repository.
1748
:param a_bzrdir: bzrdir to contain the new repository; must already
1750
:param shared: If true the repository will be initialized as a shared
1753
mutter('creating repository in %s.', a_bzrdir.transport.base)
1754
dirs = ['revision-store', 'knits']
1756
utf8_files = [('format', self.get_format_string())]
1758
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1759
repo_transport = a_bzrdir.get_repository_transport(None)
1760
control_files = lockable_files.LockableFiles(repo_transport,
1761
'lock', lockdir.LockDir)
1762
control_store = self._get_control_store(repo_transport, control_files)
1763
transaction = transactions.WriteTransaction()
1764
# trigger a write of the inventory store.
1765
control_store.get_weave_or_empty('inventory', transaction)
1766
_revision_store = self._get_revision_store(repo_transport, control_files)
1767
# the revision id here is irrelevant: it will not be stored, and cannot
1769
_revision_store.has_revision_id('A', transaction)
1770
_revision_store.get_signature_file(transaction)
1771
return self.open(a_bzrdir=a_bzrdir, _found=True)
1773
def open(self, a_bzrdir, _found=False, _override_transport=None):
1774
"""See RepositoryFormat.open().
1776
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1777
repository at a slightly different url
1778
than normal. I.e. during 'upgrade'.
1781
format = RepositoryFormat.find_format(a_bzrdir)
1782
assert format.__class__ == self.__class__
1783
if _override_transport is not None:
1784
repo_transport = _override_transport
1786
repo_transport = a_bzrdir.get_repository_transport(None)
1787
control_files = lockable_files.LockableFiles(repo_transport,
1788
'lock', lockdir.LockDir)
1789
text_store = self._get_text_store(repo_transport, control_files)
1790
control_store = self._get_control_store(repo_transport, control_files)
1791
_revision_store = self._get_revision_store(repo_transport, control_files)
1792
return KnitRepository(_format=self,
1794
control_files=control_files,
1795
_revision_store=_revision_store,
1796
control_store=control_store,
1797
text_store=text_store)
1800
class RepositoryFormatKnit1(RepositoryFormatKnit):
1801
"""Bzr repository knit format 1.
1803
This repository format has:
1804
- knits for file texts and inventory
1805
- hash subdirectory based stores.
1806
- knits for revisions and signatures
1807
- TextStores for revisions and signatures.
1808
- a format marker of its own
1809
- an optional 'shared-storage' flag
1810
- an optional 'no-working-trees' flag
1813
This format was introduced in bzr 0.8.
1815
def get_format_string(self):
1816
"""See RepositoryFormat.get_format_string()."""
1817
return "Bazaar-NG Knit Repository Format 1"
1819
def get_format_description(self):
1820
"""See RepositoryFormat.get_format_description()."""
1821
return "Knit repository format 1"
1823
def check_conversion_target(self, target_format):
1827
class RepositoryFormatKnit2(RepositoryFormatKnit):
1828
"""Bzr repository knit format 2.
1830
THIS FORMAT IS EXPERIMENTAL
1831
This repository format has:
1832
- knits for file texts and inventory
1833
- hash subdirectory based stores.
1834
- knits for revisions and signatures
1835
- TextStores for revisions and signatures.
1836
- a format marker of its own
1837
- an optional 'shared-storage' flag
1838
- an optional 'no-working-trees' flag
1840
- Support for recording full info about the tree root
1844
rich_root_data = True
1846
def get_format_string(self):
1847
"""See RepositoryFormat.get_format_string()."""
1848
return "Bazaar Knit Repository Format 2\n"
1850
def get_format_description(self):
1851
"""See RepositoryFormat.get_format_description()."""
1852
return "Knit repository format 2"
1854
def check_conversion_target(self, target_format):
1855
if not target_format.rich_root_data:
1856
raise errors.BadConversionTarget(
1857
'Does not support rich root data.', target_format)
1859
def open(self, a_bzrdir, _found=False, _override_transport=None):
1860
"""See RepositoryFormat.open().
1862
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1863
repository at a slightly different url
1864
than normal. I.e. during 'upgrade'.
1867
format = RepositoryFormat.find_format(a_bzrdir)
1868
assert format.__class__ == self.__class__
1869
if _override_transport is not None:
1870
repo_transport = _override_transport
1872
repo_transport = a_bzrdir.get_repository_transport(None)
1873
control_files = lockable_files.LockableFiles(repo_transport, 'lock',
1875
text_store = self._get_text_store(repo_transport, control_files)
1876
control_store = self._get_control_store(repo_transport, control_files)
1877
_revision_store = self._get_revision_store(repo_transport, control_files)
1878
return KnitRepository2(_format=self,
1880
control_files=control_files,
1881
_revision_store=_revision_store,
1882
control_store=control_store,
1883
text_store=text_store)
1887
1262
# formats which have no format string are not discoverable
1888
# and not independently creatable, so are not registered.
1889
RepositoryFormat.register_format(RepositoryFormat7())
1890
# KEEP in sync with bzrdir.format_registry default
1891
RepositoryFormat.register_format(RepositoryFormatKnit1())
1892
RepositoryFormat.register_format(RepositoryFormatKnit2())
1893
_legacy_formats = [RepositoryFormat4(),
1894
RepositoryFormat5(),
1895
RepositoryFormat6()]
1263
# and not independently creatable, so are not registered. They're
1264
# all in bzrlib.repofmt.weaverepo now. When an instance of one of these is
1265
# needed, it's constructed directly by the BzrDir. Non-native formats where
1266
# the repository is not separately opened are similar.
1268
format_registry.register_lazy(
1269
'Bazaar-NG Repository format 7',
1270
'bzrlib.repofmt.weaverepo',
1273
# KEEP in sync with bzrdir.format_registry default, which controls the overall
1274
# default control directory format
1276
format_registry.register_lazy(
1277
'Bazaar-NG Knit Repository Format 1',
1278
'bzrlib.repofmt.knitrepo',
1279
'RepositoryFormatKnit1',
1281
format_registry.default_key = 'Bazaar-NG Knit Repository Format 1'
1283
format_registry.register_lazy(
1284
'Bazaar Knit Repository Format 2\n',
1285
'bzrlib.repofmt.knitrepo',
1286
'RepositoryFormatKnit2',
1898
1290
class InterRepository(InterObject):