1774
1778
parent_map = self.get_parent_map(revision_ids)
1775
1779
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
1781
def _make_parents_provider(self):
1804
1782
return graph.CachingParentsProvider(self)
1886
1870
transaction = self._transaction
1887
1871
self._transaction = None
1888
1872
transaction.finish()
1873
for repo in self._fallback_repositories:
1890
1876
self.control_files.unlock()
1877
for repo in self._fallback_repositories:
1881
class RepositoryFormatPack(MetaDirRepositoryFormat):
1882
"""Format logic for pack structured repositories.
1884
This repository format has:
1885
- a list of packs in pack-names
1886
- packs in packs/NAME.pack
1887
- indices in indices/NAME.{iix,six,tix,rix}
1888
- knit deltas in the packs, knit indices mapped to the indices.
1889
- thunk objects to support the knits programming API.
1890
- a format marker of its own
1891
- an optional 'shared-storage' flag
1892
- an optional 'no-working-trees' flag
1896
# Set this attribute in derived classes to control the repository class
1897
# created by open and initialize.
1898
repository_class = None
1899
# Set this attribute in derived classes to control the
1900
# _commit_builder_class that the repository objects will have passed to
1901
# their constructor.
1902
_commit_builder_class = None
1903
# Set this attribute in derived clases to control the _serializer that the
1904
# repository objects will have passed to their constructor.
1906
# External references are not supported in pack repositories yet.
1907
supports_external_lookups = False
1909
def initialize(self, a_bzrdir, shared=False):
1910
"""Create a pack based repository.
1912
:param a_bzrdir: bzrdir to contain the new repository; must already
1914
:param shared: If true the repository will be initialized as a shared
1917
mutter('creating repository in %s.', a_bzrdir.transport.base)
1918
dirs = ['indices', 'obsolete_packs', 'packs', 'upload']
1919
builder = GraphIndexBuilder()
1920
files = [('pack-names', builder.finish())]
1921
utf8_files = [('format', self.get_format_string())]
1923
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
1924
return self.open(a_bzrdir=a_bzrdir, _found=True)
1926
def open(self, a_bzrdir, _found=False, _override_transport=None):
1927
"""See RepositoryFormat.open().
1929
:param _override_transport: INTERNAL USE ONLY. Allows opening the
1930
repository at a slightly different url
1931
than normal. I.e. during 'upgrade'.
1934
format = RepositoryFormat.find_format(a_bzrdir)
1935
if _override_transport is not None:
1936
repo_transport = _override_transport
1938
repo_transport = a_bzrdir.get_repository_transport(None)
1939
control_files = lockable_files.LockableFiles(repo_transport,
1940
'lock', lockdir.LockDir)
1941
return self.repository_class(_format=self,
1943
control_files=control_files,
1944
_commit_builder_class=self._commit_builder_class,
1945
_serializer=self._serializer)
1948
class RepositoryFormatKnitPack1(RepositoryFormatPack):
1949
"""A no-subtrees parameterized Pack repository.
1951
This format was introduced in 0.92.
1954
repository_class = KnitPackRepository
1955
_commit_builder_class = PackCommitBuilder
1956
_serializer = xml5.serializer_v5
1958
def _get_matching_bzrdir(self):
1959
return bzrdir.format_registry.make_bzrdir('pack-0.92')
1961
def _ignore_setting_bzrdir(self, format):
1964
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
1966
def get_format_string(self):
1967
"""See RepositoryFormat.get_format_string()."""
1968
return "Bazaar pack repository format 1 (needs bzr 0.92)\n"
1970
def get_format_description(self):
1971
"""See RepositoryFormat.get_format_description()."""
1972
return "Packs containing knits without subtree support"
1974
def check_conversion_target(self, target_format):
1893
1978
class RepositoryFormatPack(MetaDirRepositoryFormat):
2143
2228
"pack-0.92-subtree\n")
2231
class RepositoryFormatPackDevelopment1(RepositoryFormatPackDevelopment0):
2232
"""A no-subtrees development repository.
2234
This format should be retained until the second release after bzr 1.5.
2236
Supports external lookups, which results in non-truncated ghosts after
2237
reconcile compared to pack-0.92 formats.
2240
supports_external_lookups = True
2242
def _get_matching_bzrdir(self):
2243
return bzrdir.format_registry.make_bzrdir('development1')
2245
def _ignore_setting_bzrdir(self, format):
2248
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2250
def get_format_string(self):
2251
"""See RepositoryFormat.get_format_string()."""
2252
return "Bazaar development format 1 (needs bzr.dev from before 1.6)\n"
2254
def get_format_description(self):
2255
"""See RepositoryFormat.get_format_description()."""
2256
return ("Development repository format, currently the same as "
2257
"pack-0.92 with external reference support.\n")
2259
def check_conversion_target(self, target_format):
2263
class RepositoryFormatPackDevelopment1Subtree(RepositoryFormatPackDevelopment0Subtree):
2264
"""A subtrees development repository.
2266
This format should be retained until the second release after bzr 1.5.
2268
Supports external lookups, which results in non-truncated ghosts after
2269
reconcile compared to pack-0.92 formats.
2272
supports_external_lookups = True
2274
def _get_matching_bzrdir(self):
2275
return bzrdir.format_registry.make_bzrdir(
2276
'development1-subtree')
2278
def _ignore_setting_bzrdir(self, format):
2281
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2283
def check_conversion_target(self, target_format):
2284
if not target_format.rich_root_data:
2285
raise errors.BadConversionTarget(
2286
'Does not support rich root data.', target_format)
2287
if not getattr(target_format, 'supports_tree_reference', False):
2288
raise errors.BadConversionTarget(
2289
'Does not support nested trees', target_format)
2291
def get_format_string(self):
2292
"""See RepositoryFormat.get_format_string()."""
2293
return ("Bazaar development format 1 with subtree support "
2294
"(needs bzr.dev from before 1.6)\n")
2296
def get_format_description(self):
2297
"""See RepositoryFormat.get_format_description()."""
2298
return ("Development repository format, currently the same as "
2299
"pack-0.92-subtree with external reference support.\n")