1774
1782
parent_map = self.get_parent_map(revision_ids)
1775
1783
return [parent_map.get(r, None) for r in revision_ids]
1777
def get_parent_map(self, keys):
1778
"""See graph._StackedParentsProvider.get_parent_map
1780
This implementation accesses the combined revision index to provide
1783
self._pack_collection.ensure_loaded()
1784
index = self._pack_collection.revision_index.combined_index
1787
raise ValueError('get_parent_map(None) is not valid')
1788
if _mod_revision.NULL_REVISION in keys:
1789
keys.discard(_mod_revision.NULL_REVISION)
1790
found_parents = {_mod_revision.NULL_REVISION:()}
1793
search_keys = set((revision_id,) for revision_id in keys)
1794
for index, key, value, refs in index.iter_entries(search_keys):
1797
parents = (_mod_revision.NULL_REVISION,)
1799
parents = tuple(parent[0] for parent in parents)
1800
found_parents[key[0]] = parents
1801
return found_parents
1803
def has_revisions(self, revision_ids):
1804
"""See Repository.has_revisions()."""
1805
revision_ids = set(revision_ids)
1806
result = revision_ids.intersection(
1807
set([None, _mod_revision.NULL_REVISION]))
1808
revision_ids.difference_update(result)
1809
index = self._pack_collection.revision_index.combined_index
1810
keys = [(revision_id,) for revision_id in revision_ids]
1811
result.update(node[1][0] for node in index.iter_entries(keys))
1814
1785
def _make_parents_provider(self):
1815
1786
return graph.CachingParentsProvider(self)
1897
1874
transaction = self._transaction
1898
1875
self._transaction = None
1899
1876
transaction.finish()
1877
for repo in self._fallback_repositories:
1901
1880
self.control_files.unlock()
1881
for repo in self._fallback_repositories:
1885
class RepositoryFormatPack(MetaDirRepositoryFormat):
1886
"""Format logic for pack structured repositories.
1888
This repository format has:
1889
- a list of packs in pack-names
1890
- packs in packs/NAME.pack
1891
- indices in indices/NAME.{iix,six,tix,rix}
1892
- knit deltas in the packs, knit indices mapped to the indices.
1893
- thunk objects to support the knits programming API.
1894
- a format marker of its own
1895
- an optional 'shared-storage' flag
1896
- an optional 'no-working-trees' flag
1900
# Set this attribute in derived classes to control the repository class
1901
# created by open and initialize.
1902
repository_class = None
1903
# Set this attribute in derived classes to control the
1904
# _commit_builder_class that the repository objects will have passed to
1905
# their constructor.
1906
_commit_builder_class = None
1907
# Set this attribute in derived clases to control the _serializer that the
1908
# repository objects will have passed to their constructor.
1910
# External references are not supported in pack repositories yet.
1911
supports_external_lookups = False
1913
def initialize(self, a_bzrdir, shared=False):
1914
"""Create a pack based repository.
1916
:param a_bzrdir: bzrdir to contain the new repository; must already
1918
:param shared: If true the repository will be initialized as a shared
1921
mutter('creating repository in %s.', a_bzrdir.transport.base)
1922
dirs = ['indices', 'obsolete_packs', 'packs', 'upload']
1923
builder = GraphIndexBuilder()
1924
files = [('pack-names', builder.finish())]
1925
utf8_files = [('format', self.get_format_string())]
1927
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1928
return self.open(a_bzrdir=a_bzrdir, _found=True)
1930
def open(self, a_bzrdir, _found=False, _override_transport=None):
1931
"""See RepositoryFormat.open().
1933
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1934
repository at a slightly different url
1935
than normal. I.e. during 'upgrade'.
1938
format = RepositoryFormat.find_format(a_bzrdir)
1939
if _override_transport is not None:
1940
repo_transport = _override_transport
1942
repo_transport = a_bzrdir.get_repository_transport(None)
1943
control_files = lockable_files.LockableFiles(repo_transport,
1944
'lock', lockdir.LockDir)
1945
return self.repository_class(_format=self,
1947
control_files=control_files,
1948
_commit_builder_class=self._commit_builder_class,
1949
_serializer=self._serializer)
1952
class RepositoryFormatKnitPack1(RepositoryFormatPack):
1953
"""A no-subtrees parameterized Pack repository.
1955
This format was introduced in 0.92.
1958
repository_class = KnitPackRepository
1959
_commit_builder_class = PackCommitBuilder
1960
_serializer = xml5.serializer_v5
1962
def _get_matching_bzrdir(self):
1963
return bzrdir.format_registry.make_bzrdir('pack-0.92')
1965
def _ignore_setting_bzrdir(self, format):
1968
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
1970
def get_format_string(self):
1971
"""See RepositoryFormat.get_format_string()."""
1972
return "Bazaar pack repository format 1 (needs bzr 0.92)\n"
1974
def get_format_description(self):
1975
"""See RepositoryFormat.get_format_description()."""
1976
return "Packs containing knits without subtree support"
1978
def check_conversion_target(self, target_format):
1904
1982
class RepositoryFormatPack(MetaDirRepositoryFormat):
2079
2157
return "Packs containing knits with rich root support\n"
2160
class RepositoryFormatKnitPack5(RepositoryFormatPack):
2161
"""Repository that supports external references to allow stacking.
2165
Supports external lookups, which results in non-truncated ghosts after
2166
reconcile compared to pack-0.92 formats.
2169
repository_class = KnitPackRepository
2170
_commit_builder_class = PackCommitBuilder
2171
_serializer = xml5.serializer_v5
2172
supports_external_lookups = True
2174
def _get_matching_bzrdir(self):
2175
return bzrdir.format_registry.make_bzrdir('development1')
2177
def _ignore_setting_bzrdir(self, format):
2180
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2182
def get_format_string(self):
2183
"""See RepositoryFormat.get_format_string()."""
2184
return "Bazaar RepositoryFormatKnitPack5 (bzr 1.6)\n"
2186
def get_format_description(self):
2187
"""See RepositoryFormat.get_format_description()."""
2190
def check_conversion_target(self, target_format):
2194
class RepositoryFormatKnitPack5RichRoot(RepositoryFormatPack):
2195
"""A repository with subtrees and external references.
2199
Supports external lookups, which results in non-truncated ghosts after
2200
reconcile compared to pack-0.92 formats.
2203
repository_class = KnitPackRepository
2204
_commit_builder_class = PackRootCommitBuilder
2205
rich_root_data = True
2206
supports_tree_reference = False # no subtrees
2207
_serializer = xml7.serializer_v7
2209
supports_external_lookups = True
2211
def _get_matching_bzrdir(self):
2212
return bzrdir.format_registry.make_bzrdir(
2213
'development1-subtree')
2215
def _ignore_setting_bzrdir(self, format):
2218
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2220
def check_conversion_target(self, target_format):
2221
if not target_format.rich_root_data:
2222
raise errors.BadConversionTarget(
2223
'Does not support rich root data.', target_format)
2225
def get_format_string(self):
2226
"""See RepositoryFormat.get_format_string()."""
2227
return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
2229
def get_format_description(self):
2230
"""See RepositoryFormat.get_format_description()."""
2082
2234
class RepositoryFormatPackDevelopment0(RepositoryFormatPack):
2083
2235
"""A no-subtrees development repository.
2154
2306
"pack-0.92-subtree\n")
2309
class RepositoryFormatPackDevelopment1(RepositoryFormatPackDevelopment0):
2310
"""A no-subtrees development repository.
2312
This format should be retained until the second release after bzr 1.5.
2314
Supports external lookups, which results in non-truncated ghosts after
2315
reconcile compared to pack-0.92 formats.
2318
supports_external_lookups = True
2320
def _get_matching_bzrdir(self):
2321
return bzrdir.format_registry.make_bzrdir('development1')
2323
def _ignore_setting_bzrdir(self, format):
2326
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2328
def get_format_string(self):
2329
"""See RepositoryFormat.get_format_string()."""
2330
return "Bazaar development format 1 (needs bzr.dev from before 1.6)\n"
2332
def get_format_description(self):
2333
"""See RepositoryFormat.get_format_description()."""
2334
return ("Development repository format, currently the same as "
2335
"pack-0.92 with external reference support.\n")
2337
def check_conversion_target(self, target_format):
2341
class RepositoryFormatPackDevelopment1Subtree(RepositoryFormatPackDevelopment0Subtree):
2342
"""A subtrees development repository.
2344
This format should be retained until the second release after bzr 1.5.
2346
Supports external lookups, which results in non-truncated ghosts after
2347
reconcile compared to pack-0.92 formats.
2350
supports_external_lookups = True
2352
def _get_matching_bzrdir(self):
2353
return bzrdir.format_registry.make_bzrdir(
2354
'development1-subtree')
2356
def _ignore_setting_bzrdir(self, format):
2359
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2361
def check_conversion_target(self, target_format):
2362
if not target_format.rich_root_data:
2363
raise errors.BadConversionTarget(
2364
'Does not support rich root data.', target_format)
2365
if not getattr(target_format, 'supports_tree_reference', False):
2366
raise errors.BadConversionTarget(
2367
'Does not support nested trees', target_format)
2369
def get_format_string(self):
2370
"""See RepositoryFormat.get_format_string()."""
2371
return ("Bazaar development format 1 with subtree support "
2372
"(needs bzr.dev from before 1.6)\n")
2374
def get_format_description(self):
2375
"""See RepositoryFormat.get_format_description()."""
2376
return ("Development repository format, currently the same as "
2377
"pack-0.92-subtree with external reference support.\n")