93
def add_inventory(self, revid, inv, parents):
94
"""Add the inventory inv to the repository as revid.
84
def add_inventory(self, revision_id, inv, parents):
85
"""Add the inventory inv to the repository as revision_id.
96
:param parents: The revision ids of the parents that revid
87
:param parents: The revision ids of the parents that revision_id
97
88
is known to have and are in the repository already.
99
90
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, \
92
revision_id = osutils.safe_revision_id(revision_id)
93
_mod_revision.check_not_reserved_id(revision_id)
94
assert inv.revision_id is None or inv.revision_id == revision_id, \
103
95
"Mismatch between inventory revision" \
104
" id and insertion revid (%r, %r)" % (inv.revision_id, revid)
96
" id and insertion revid (%r, %r)" % (inv.revision_id, revision_id)
105
97
assert inv.root is not None
106
98
inv_text = self.serialise_inventory(inv)
107
99
inv_sha1 = osutils.sha_string(inv_text)
108
100
inv_vf = self.control_weaves.get_weave('inventory',
109
101
self.get_transaction())
110
self._inventory_add_lines(inv_vf, revid, parents, osutils.split_lines(inv_text))
102
self._inventory_add_lines(inv_vf, revision_id, parents,
103
osutils.split_lines(inv_text))
113
def _inventory_add_lines(self, inv_vf, revid, parents, lines):
106
def _inventory_add_lines(self, inv_vf, revision_id, parents, lines):
114
107
final_parents = []
115
108
for parent in parents:
116
109
if parent in inv_vf:
117
110
final_parents.append(parent)
119
inv_vf.add_lines(revid, final_parents, lines)
112
inv_vf.add_lines(revision_id, final_parents, lines)
121
114
@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.
115
def add_revision(self, revision_id, rev, inv=None, config=None):
116
"""Add rev to the revision store as revision_id.
125
:param rev_id: the revision id to use.
118
:param revision_id: the revision id to use.
126
119
:param rev: The revision object.
127
120
:param inv: The inventory for the revision. if None, it will be looked
128
121
up in the inventory storer
827
887
revision_id.encode('ascii')
828
888
except UnicodeEncodeError:
829
889
raise errors.NonAsciiRevisionId(method, self)
832
class AllInOneRepository(Repository):
833
"""Legacy support - the repository behaviour for all-in-one branches."""
835
def __init__(self, _format, a_bzrdir, _revision_store, control_store, text_store):
836
# we reuse one control files instance.
837
dir_mode = a_bzrdir._control_files._dir_mode
838
file_mode = a_bzrdir._control_files._file_mode
840
def get_store(name, compressed=True, prefixed=False):
841
# FIXME: This approach of assuming stores are all entirely compressed
842
# or entirely uncompressed is tidy, but breaks upgrade from
843
# some existing branches where there's a mixture; we probably
844
# still want the option to look for both.
845
relpath = a_bzrdir._control_files._escape(name)
846
store = TextStore(a_bzrdir._control_files._transport.clone(relpath),
847
prefixed=prefixed, compressed=compressed,
850
#if self._transport.should_cache():
851
# cache_path = os.path.join(self.cache_root, name)
852
# os.mkdir(cache_path)
853
# store = bzrlib.store.CachedStore(store, cache_path)
856
# not broken out yet because the controlweaves|inventory_store
857
# and text_store | weave_store bits are still different.
858
if isinstance(_format, RepositoryFormat4):
859
# cannot remove these - there is still no consistent api
860
# which allows access to this old info.
861
self.inventory_store = get_store('inventory-store')
862
text_store = get_store('text-store')
863
super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files, _revision_store, control_store, text_store)
865
def get_commit_builder(self, branch, parents, config, timestamp=None,
866
timezone=None, committer=None, revprops=None,
868
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
869
return Repository.get_commit_builder(self, branch, parents, config,
870
timestamp, timezone, committer, revprops, revision_id)
874
"""AllInOne repositories cannot be shared."""
878
def set_make_working_trees(self, new_value):
879
"""Set the policy flag for making working trees when creating branches.
881
This only applies to branches that use this repository.
883
The default is 'True'.
884
:param new_value: True to restore the default, False to disable making
887
raise NotImplementedError(self.set_make_working_trees)
889
def make_working_trees(self):
890
"""Returns the policy for making working trees on new branches."""
892
revision_id.decode('ascii')
893
except UnicodeDecodeError:
894
raise errors.NonAsciiRevisionId(method, self)
898
# remove these delegates a while after bzr 0.15
899
def __make_delegated(name, from_module):
900
def _deprecated_repository_forwarder():
901
symbol_versioning.warn('%s moved to %s in bzr 0.15'
902
% (name, from_module),
905
m = __import__(from_module, globals(), locals(), [name])
907
return getattr(m, name)
908
except AttributeError:
909
raise AttributeError('module %s has no name %s'
911
globals()[name] = _deprecated_repository_forwarder
914
'AllInOneRepository',
915
'WeaveMetaDirRepository',
916
'PreSplitOutRepositoryFormat',
922
__make_delegated(_name, 'bzrlib.repofmt.weaverepo')
926
'RepositoryFormatKnit',
927
'RepositoryFormatKnit1',
929
__make_delegated(_name, 'bzrlib.repofmt.knitrepo')
894
932
def install_revision(repository, rev, revision_tree):
980
1018
return not self.control_files._transport.has('no-working-trees')
983
class WeaveMetaDirRepository(MetaDirRepository):
984
"""A subclass of MetaDirRepository to set weave specific policy."""
986
def get_commit_builder(self, branch, parents, config, timestamp=None,
987
timezone=None, committer=None, revprops=None,
989
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
990
return MetaDirRepository.get_commit_builder(self, branch, parents,
991
config, timestamp, timezone, committer, revprops, revision_id)
994
class KnitRepository(MetaDirRepository):
995
"""Knit format repository."""
997
def _warn_if_deprecated(self):
998
# This class isn't deprecated
1001
def _inventory_add_lines(self, inv_vf, revid, parents, lines):
1002
inv_vf.add_lines_with_ghosts(revid, parents, lines)
1005
def _all_revision_ids(self):
1006
"""See Repository.all_revision_ids()."""
1007
# Knits get the revision graph from the index of the revision knit, so
1008
# it's always possible even if they're on an unlistable transport.
1009
return self._revision_store.all_revision_ids(self.get_transaction())
1011
def fileid_involved_between_revs(self, from_revid, to_revid):
1012
"""Find file_id(s) which are involved in the changes between revisions.
1014
This determines the set of revisions which are involved, and then
1015
finds all file ids affected by those revisions.
1017
vf = self._get_revision_vf()
1018
from_set = set(vf.get_ancestry(from_revid))
1019
to_set = set(vf.get_ancestry(to_revid))
1020
changed = to_set.difference(from_set)
1021
return self._fileid_involved_by_set(changed)
1023
def fileid_involved(self, last_revid=None):
1024
"""Find all file_ids modified in the ancestry of last_revid.
1026
:param last_revid: If None, last_revision() will be used.
1029
changed = set(self.all_revision_ids())
1031
changed = set(self.get_ancestry(last_revid))
1033
changed.remove(None)
1034
return self._fileid_involved_by_set(changed)
1037
def get_ancestry(self, revision_id):
1038
"""Return a list of revision-ids integrated by a revision.
1040
This is topologically sorted.
1042
if revision_id is None:
1044
vf = self._get_revision_vf()
1046
return [None] + vf.get_ancestry(revision_id)
1047
except errors.RevisionNotPresent:
1048
raise errors.NoSuchRevision(self, revision_id)
1051
def get_revision(self, revision_id):
1052
"""Return the Revision object for a named revision"""
1053
return self.get_revision_reconcile(revision_id)
1056
def get_revision_graph(self, revision_id=None):
1057
"""Return a dictionary containing the revision graph.
1059
:param revision_id: The revision_id to get a graph from. If None, then
1060
the entire revision graph is returned. This is a deprecated mode of
1061
operation and will be removed in the future.
1062
:return: a dictionary of revision_id->revision_parents_list.
1064
# special case NULL_REVISION
1065
if revision_id == _mod_revision.NULL_REVISION:
1067
a_weave = self._get_revision_vf()
1068
entire_graph = a_weave.get_graph()
1069
if revision_id is None:
1070
return a_weave.get_graph()
1071
elif revision_id not in a_weave:
1072
raise errors.NoSuchRevision(self, revision_id)
1074
# add what can be reached from revision_id
1076
pending = set([revision_id])
1077
while len(pending) > 0:
1078
node = pending.pop()
1079
result[node] = a_weave.get_parents(node)
1080
for revision_id in result[node]:
1081
if revision_id not in result:
1082
pending.add(revision_id)
1086
def get_revision_graph_with_ghosts(self, revision_ids=None):
1087
"""Return a graph of the revisions with ghosts marked as applicable.
1089
:param revision_ids: an iterable of revisions to graph or None for all.
1090
:return: a Graph object with the graph reachable from revision_ids.
1092
result = graph.Graph()
1093
vf = self._get_revision_vf()
1094
versions = set(vf.versions())
1095
if not revision_ids:
1096
pending = set(self.all_revision_ids())
1099
pending = set(revision_ids)
1100
# special case NULL_REVISION
1101
if _mod_revision.NULL_REVISION in pending:
1102
pending.remove(_mod_revision.NULL_REVISION)
1103
required = set(pending)
1106
revision_id = pending.pop()
1107
if not revision_id in versions:
1108
if revision_id in required:
1109
raise errors.NoSuchRevision(self, revision_id)
1111
result.add_ghost(revision_id)
1112
# mark it as done so we don't try for it again.
1113
done.add(revision_id)
1115
parent_ids = vf.get_parents_with_ghosts(revision_id)
1116
for parent_id in parent_ids:
1117
# is this queued or done ?
1118
if (parent_id not in pending and
1119
parent_id not in done):
1121
pending.add(parent_id)
1122
result.add_node(revision_id, parent_ids)
1123
done.add(revision_id)
1126
def _get_revision_vf(self):
1127
""":return: a versioned file containing the revisions."""
1128
vf = self._revision_store.get_revision_file(self.get_transaction())
1132
def reconcile(self, other=None, thorough=False):
1133
"""Reconcile this repository."""
1134
from bzrlib.reconcile import KnitReconciler
1135
reconciler = KnitReconciler(self, thorough=thorough)
1136
reconciler.reconcile()
1139
def revision_parents(self, revision_id):
1140
return self._get_revision_vf().get_parents(revision_id)
1143
class KnitRepository2(KnitRepository):
1145
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
1146
control_store, text_store):
1147
KnitRepository.__init__(self, _format, a_bzrdir, control_files,
1148
_revision_store, control_store, text_store)
1149
self._serializer = xml6.serializer_v6
1151
def deserialise_inventory(self, revision_id, xml):
1152
"""Transform the xml into an inventory object.
1154
:param revision_id: The expected revision id of the inventory.
1155
:param xml: A serialised inventory.
1157
result = self._serializer.read_inventory_from_string(xml)
1158
assert result.root.revision is not None
1161
def serialise_inventory(self, inv):
1162
"""Transform the inventory object into XML text.
1164
:param revision_id: The expected revision id of the inventory.
1165
:param xml: A serialised inventory.
1167
assert inv.revision_id is not None
1168
assert inv.root.revision is not None
1169
return KnitRepository.serialise_inventory(self, inv)
1171
def get_commit_builder(self, branch, parents, config, timestamp=None,
1172
timezone=None, committer=None, revprops=None,
1174
"""Obtain a CommitBuilder for this repository.
1176
:param branch: Branch to commit to.
1177
:param parents: Revision ids of the parents of the new revision.
1178
:param config: Configuration to use.
1179
:param timestamp: Optional timestamp recorded for commit.
1180
:param timezone: Optional timezone for timestamp.
1181
:param committer: Optional committer to set for commit.
1182
:param revprops: Optional dictionary of revision properties.
1183
:param revision_id: Optional revision id.
1185
return RootCommitBuilder(self, parents, config, timestamp, timezone,
1186
committer, revprops, revision_id)
1189
1021
class RepositoryFormatRegistry(registry.Registry):
1190
1022
"""Registry of RepositoryFormats.
1025
def get(self, format_string):
1026
r = registry.Registry.get(self, format_string)
1194
1032
format_registry = RepositoryFormatRegistry()
1195
"""Registry of formats, indexed by their identifying format string."""
1033
"""Registry of formats, indexed by their identifying format string.
1035
This can contain either format instances themselves, or classes/factories that
1036
can be called to obtain one.
1040
#####################################################################
1041
# Repository Formats
1198
1043
class RepositoryFormat(object):
1199
1044
"""A repository format.
1344
1200
raise NotImplementedError(self.open)
1347
class PreSplitOutRepositoryFormat(RepositoryFormat):
1348
"""Base class for the pre split out repository formats."""
1350
rich_root_data = False
1352
def initialize(self, a_bzrdir, shared=False, _internal=False):
1353
"""Create a weave repository.
1355
TODO: when creating split out bzr branch formats, move this to a common
1356
base for Format5, Format6. or something like that.
1359
raise errors.IncompatibleFormat(self, a_bzrdir._format)
1362
# always initialized when the bzrdir is.
1363
return self.open(a_bzrdir, _found=True)
1365
# Create an empty weave
1367
weavefile.write_weave_v5(weave.Weave(), sio)
1368
empty_weave = sio.getvalue()
1370
mutter('creating repository in %s.', a_bzrdir.transport.base)
1371
dirs = ['revision-store', 'weaves']
1372
files = [('inventory.weave', StringIO(empty_weave)),
1375
# FIXME: RBC 20060125 don't peek under the covers
1376
# NB: no need to escape relative paths that are url safe.
1377
control_files = lockable_files.LockableFiles(a_bzrdir.transport,
1378
'branch-lock', lockable_files.TransportLock)
1379
control_files.create_lock()
1380
control_files.lock_write()
1381
control_files._transport.mkdir_multi(dirs,
1382
mode=control_files._dir_mode)
1384
for file, content in files:
1385
control_files.put(file, content)
1387
control_files.unlock()
1388
return self.open(a_bzrdir, _found=True)
1390
def _get_control_store(self, repo_transport, control_files):
1391
"""Return the control store for this repository."""
1392
return self._get_versioned_file_store('',
1397
def _get_text_store(self, transport, control_files):
1398
"""Get a store for file texts for this format."""
1399
raise NotImplementedError(self._get_text_store)
1401
def open(self, a_bzrdir, _found=False):
1402
"""See RepositoryFormat.open()."""
1404
# we are being called directly and must probe.
1405
raise NotImplementedError
1407
repo_transport = a_bzrdir.get_repository_transport(None)
1408
control_files = a_bzrdir._control_files
1409
text_store = self._get_text_store(repo_transport, control_files)
1410
control_store = self._get_control_store(repo_transport, control_files)
1411
_revision_store = self._get_revision_store(repo_transport, control_files)
1412
return AllInOneRepository(_format=self,
1414
_revision_store=_revision_store,
1415
control_store=control_store,
1416
text_store=text_store)
1418
def check_conversion_target(self, target_format):
1422
class RepositoryFormat4(PreSplitOutRepositoryFormat):
1423
"""Bzr repository format 4.
1425
This repository format has:
1427
- TextStores for texts, inventories,revisions.
1429
This format is deprecated: it indexes texts using a text id which is
1430
removed in format 5; initialization and write support for this format
1435
super(RepositoryFormat4, self).__init__()
1436
self._matchingbzrdir = bzrdir.BzrDirFormat4()
1438
def get_format_description(self):
1439
"""See RepositoryFormat.get_format_description()."""
1440
return "Repository format 4"
1442
def initialize(self, url, shared=False, _internal=False):
1443
"""Format 4 branches cannot be created."""
1444
raise errors.UninitializableFormat(self)
1446
def is_supported(self):
1447
"""Format 4 is not supported.
1449
It is not supported because the model changed from 4 to 5 and the
1450
conversion logic is expensive - so doing it on the fly was not
1455
def _get_control_store(self, repo_transport, control_files):
1456
"""Format 4 repositories have no formal control store at this point.
1458
This will cause any control-file-needing apis to fail - this is desired.
1462
def _get_revision_store(self, repo_transport, control_files):
1463
"""See RepositoryFormat._get_revision_store()."""
1464
from bzrlib.xml4 import serializer_v4
1465
return self._get_text_rev_store(repo_transport,
1468
serializer=serializer_v4)
1470
def _get_text_store(self, transport, control_files):
1471
"""See RepositoryFormat._get_text_store()."""
1474
class RepositoryFormat5(PreSplitOutRepositoryFormat):
1475
"""Bzr control format 5.
1477
This repository format has:
1478
- weaves for file texts and inventory
1480
- TextStores for revisions and signatures.
1484
super(RepositoryFormat5, self).__init__()
1485
self._matchingbzrdir = bzrdir.BzrDirFormat5()
1487
def get_format_description(self):
1488
"""See RepositoryFormat.get_format_description()."""
1489
return "Weave repository format 5"
1491
def _get_revision_store(self, repo_transport, control_files):
1492
"""See RepositoryFormat._get_revision_store()."""
1493
"""Return the revision store object for this a_bzrdir."""
1494
return self._get_text_rev_store(repo_transport,
1499
def _get_text_store(self, transport, control_files):
1500
"""See RepositoryFormat._get_text_store()."""
1501
return self._get_versioned_file_store('weaves', transport, control_files, prefixed=False)
1504
class RepositoryFormat6(PreSplitOutRepositoryFormat):
1505
"""Bzr control format 6.
1507
This repository format has:
1508
- weaves for file texts and inventory
1509
- hash subdirectory based stores.
1510
- TextStores for revisions and signatures.
1514
super(RepositoryFormat6, self).__init__()
1515
self._matchingbzrdir = bzrdir.BzrDirFormat6()
1517
def get_format_description(self):
1518
"""See RepositoryFormat.get_format_description()."""
1519
return "Weave repository format 6"
1521
def _get_revision_store(self, repo_transport, control_files):
1522
"""See RepositoryFormat._get_revision_store()."""
1523
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)
1534
1203
class MetaDirRepositoryFormat(RepositoryFormat):
1535
1204
"""Common base class for the new repositories using the metadir layout."""
1537
1206
rich_root_data = False
1207
_matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1539
1209
def __init__(self):
1540
1210
super(MetaDirRepositoryFormat, self).__init__()
1541
self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1543
1212
def _create_control_files(self, a_bzrdir):
1544
1213
"""Create the required files and the initial control_files object."""
1567
1236
control_files.unlock()
1570
class RepositoryFormat7(MetaDirRepositoryFormat):
1571
"""Bzr repository 7.
1573
This repository format has:
1574
- weaves for file texts and inventory
1575
- hash subdirectory based stores.
1576
- TextStores for revisions and signatures.
1577
- a format marker of its own
1578
- an optional 'shared-storage' flag
1579
- an optional 'no-working-trees' flag
1582
def _get_control_store(self, repo_transport, control_files):
1583
"""Return the control store for this repository."""
1584
return self._get_versioned_file_store('',
1589
def get_format_string(self):
1590
"""See RepositoryFormat.get_format_string()."""
1591
return "Bazaar-NG Repository format 7"
1593
def get_format_description(self):
1594
"""See RepositoryFormat.get_format_description()."""
1595
return "Weave repository format 7"
1597
def check_conversion_target(self, target_format):
1600
def _get_revision_store(self, repo_transport, control_files):
1601
"""See RepositoryFormat._get_revision_store()."""
1602
return self._get_text_rev_store(repo_transport,
1609
def _get_text_store(self, transport, control_files):
1610
"""See RepositoryFormat._get_text_store()."""
1611
return self._get_versioned_file_store('weaves',
1615
def initialize(self, a_bzrdir, shared=False):
1616
"""Create a weave repository.
1618
:param shared: If true the repository will be initialized as a shared
1621
# Create an empty weave
1623
weavefile.write_weave_v5(weave.Weave(), sio)
1624
empty_weave = sio.getvalue()
1626
mutter('creating repository in %s.', a_bzrdir.transport.base)
1627
dirs = ['revision-store', 'weaves']
1628
files = [('inventory.weave', StringIO(empty_weave)),
1630
utf8_files = [('format', self.get_format_string())]
1632
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1633
return self.open(a_bzrdir=a_bzrdir, _found=True)
1635
def open(self, a_bzrdir, _found=False, _override_transport=None):
1636
"""See RepositoryFormat.open().
1638
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1639
repository at a slightly different url
1640
than normal. I.e. during 'upgrade'.
1643
format = RepositoryFormat.find_format(a_bzrdir)
1644
assert format.__class__ == self.__class__
1645
if _override_transport is not None:
1646
repo_transport = _override_transport
1648
repo_transport = a_bzrdir.get_repository_transport(None)
1649
control_files = lockable_files.LockableFiles(repo_transport,
1650
'lock', lockdir.LockDir)
1651
text_store = self._get_text_store(repo_transport, control_files)
1652
control_store = self._get_control_store(repo_transport, control_files)
1653
_revision_store = self._get_revision_store(repo_transport, control_files)
1654
return WeaveMetaDirRepository(_format=self,
1656
control_files=control_files,
1657
_revision_store=_revision_store,
1658
control_store=control_store,
1659
text_store=text_store)
1662
class RepositoryFormatKnit(MetaDirRepositoryFormat):
1663
"""Bzr repository knit format (generalized).
1665
This repository format has:
1666
- knits for file texts and inventory
1667
- hash subdirectory based stores.
1668
- knits for revisions and signatures
1669
- TextStores for revisions and signatures.
1670
- a format marker of its own
1671
- an optional 'shared-storage' flag
1672
- an optional 'no-working-trees' flag
1676
def _get_control_store(self, repo_transport, control_files):
1677
"""Return the control store for this repository."""
1678
return VersionedFileStore(
1681
file_mode=control_files._file_mode,
1682
versionedfile_class=knit.KnitVersionedFile,
1683
versionedfile_kwargs={'factory':knit.KnitPlainFactory()},
1686
def _get_revision_store(self, repo_transport, control_files):
1687
"""See RepositoryFormat._get_revision_store()."""
1688
from bzrlib.store.revision.knit import KnitRevisionStore
1689
versioned_file_store = VersionedFileStore(
1691
file_mode=control_files._file_mode,
1694
versionedfile_class=knit.KnitVersionedFile,
1695
versionedfile_kwargs={'delta':False,
1696
'factory':knit.KnitPlainFactory(),
1700
return KnitRevisionStore(versioned_file_store)
1702
def _get_text_store(self, transport, control_files):
1703
"""See RepositoryFormat._get_text_store()."""
1704
return self._get_versioned_file_store('knits',
1707
versionedfile_class=knit.KnitVersionedFile,
1708
versionedfile_kwargs={
1709
'create_parent_dir':True,
1710
'delay_create':True,
1711
'dir_mode':control_files._dir_mode,
1715
def initialize(self, a_bzrdir, shared=False):
1716
"""Create a knit format 1 repository.
1718
:param a_bzrdir: bzrdir to contain the new repository; must already
1720
:param shared: If true the repository will be initialized as a shared
1723
mutter('creating repository in %s.', a_bzrdir.transport.base)
1724
dirs = ['revision-store', 'knits']
1726
utf8_files = [('format', self.get_format_string())]
1728
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1729
repo_transport = a_bzrdir.get_repository_transport(None)
1730
control_files = lockable_files.LockableFiles(repo_transport,
1731
'lock', lockdir.LockDir)
1732
control_store = self._get_control_store(repo_transport, control_files)
1733
transaction = transactions.WriteTransaction()
1734
# trigger a write of the inventory store.
1735
control_store.get_weave_or_empty('inventory', transaction)
1736
_revision_store = self._get_revision_store(repo_transport, control_files)
1737
# the revision id here is irrelevant: it will not be stored, and cannot
1739
_revision_store.has_revision_id('A', transaction)
1740
_revision_store.get_signature_file(transaction)
1741
return self.open(a_bzrdir=a_bzrdir, _found=True)
1743
def open(self, a_bzrdir, _found=False, _override_transport=None):
1744
"""See RepositoryFormat.open().
1746
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1747
repository at a slightly different url
1748
than normal. I.e. during 'upgrade'.
1751
format = RepositoryFormat.find_format(a_bzrdir)
1752
assert format.__class__ == self.__class__
1753
if _override_transport is not None:
1754
repo_transport = _override_transport
1756
repo_transport = a_bzrdir.get_repository_transport(None)
1757
control_files = lockable_files.LockableFiles(repo_transport,
1758
'lock', lockdir.LockDir)
1759
text_store = self._get_text_store(repo_transport, control_files)
1760
control_store = self._get_control_store(repo_transport, control_files)
1761
_revision_store = self._get_revision_store(repo_transport, control_files)
1762
return KnitRepository(_format=self,
1764
control_files=control_files,
1765
_revision_store=_revision_store,
1766
control_store=control_store,
1767
text_store=text_store)
1770
class RepositoryFormatKnit1(RepositoryFormatKnit):
1771
"""Bzr repository knit format 1.
1773
This repository format has:
1774
- knits for file texts and inventory
1775
- hash subdirectory based stores.
1776
- knits for revisions and signatures
1777
- TextStores for revisions and signatures.
1778
- a format marker of its own
1779
- an optional 'shared-storage' flag
1780
- an optional 'no-working-trees' flag
1783
This format was introduced in bzr 0.8.
1785
def get_format_string(self):
1786
"""See RepositoryFormat.get_format_string()."""
1787
return "Bazaar-NG Knit Repository Format 1"
1789
def get_format_description(self):
1790
"""See RepositoryFormat.get_format_description()."""
1791
return "Knit repository format 1"
1793
def check_conversion_target(self, target_format):
1797
class RepositoryFormatKnit2(RepositoryFormatKnit):
1798
"""Bzr repository knit format 2.
1800
THIS FORMAT IS EXPERIMENTAL
1801
This repository format has:
1802
- knits for file texts and inventory
1803
- hash subdirectory based stores.
1804
- knits for revisions and signatures
1805
- TextStores for revisions and signatures.
1806
- a format marker of its own
1807
- an optional 'shared-storage' flag
1808
- an optional 'no-working-trees' flag
1810
- Support for recording full info about the tree root
1814
rich_root_data = True
1816
def get_format_string(self):
1817
"""See RepositoryFormat.get_format_string()."""
1818
return "Bazaar Knit Repository Format 2\n"
1820
def get_format_description(self):
1821
"""See RepositoryFormat.get_format_description()."""
1822
return "Knit repository format 2"
1824
def check_conversion_target(self, target_format):
1825
if not target_format.rich_root_data:
1826
raise errors.BadConversionTarget(
1827
'Does not support rich root data.', target_format)
1829
def open(self, a_bzrdir, _found=False, _override_transport=None):
1830
"""See RepositoryFormat.open().
1832
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1833
repository at a slightly different url
1834
than normal. I.e. during 'upgrade'.
1837
format = RepositoryFormat.find_format(a_bzrdir)
1838
assert format.__class__ == self.__class__
1839
if _override_transport is not None:
1840
repo_transport = _override_transport
1842
repo_transport = a_bzrdir.get_repository_transport(None)
1843
control_files = lockable_files.LockableFiles(repo_transport, 'lock',
1845
text_store = self._get_text_store(repo_transport, control_files)
1846
control_store = self._get_control_store(repo_transport, control_files)
1847
_revision_store = self._get_revision_store(repo_transport, control_files)
1848
return KnitRepository2(_format=self,
1850
control_files=control_files,
1851
_revision_store=_revision_store,
1852
control_store=control_store,
1853
text_store=text_store)
1857
1239
# formats which have no format string are not discoverable
1858
# and not independently creatable, so are not registered.
1859
RepositoryFormat.register_format(RepositoryFormat7())
1860
# KEEP in sync with bzrdir.format_registry default
1861
RepositoryFormat.register_format(RepositoryFormatKnit1())
1862
RepositoryFormat.register_format(RepositoryFormatKnit2())
1863
_legacy_formats = [RepositoryFormat4(),
1864
RepositoryFormat5(),
1865
RepositoryFormat6()]
1240
# and not independently creatable, so are not registered. They're
1241
# all in bzrlib.repofmt.weaverepo now. When an instance of one of these is
1242
# needed, it's constructed directly by the BzrDir. Non-native formats where
1243
# the repository is not separately opened are similar.
1245
format_registry.register_lazy(
1246
'Bazaar-NG Repository format 7',
1247
'bzrlib.repofmt.weaverepo',
1250
# KEEP in sync with bzrdir.format_registry default, which controls the overall
1251
# default control directory format
1253
format_registry.register_lazy(
1254
'Bazaar-NG Knit Repository Format 1',
1255
'bzrlib.repofmt.knitrepo',
1256
'RepositoryFormatKnit1',
1258
format_registry.default_key = 'Bazaar-NG Knit Repository Format 1'
1260
format_registry.register_lazy(
1261
'Bazaar Knit Repository Format 3 (bzr 0.15)\n',
1262
'bzrlib.repofmt.knitrepo',
1263
'RepositoryFormatKnit3',
1868
1267
class InterRepository(InterObject):