375
358
when working locally.
376
359
:return: The created control directory
378
with contextlib.ExitStack() as stack:
379
fetch_spec_factory = fetch.FetchSpecFactory()
380
if revision_id is not None:
381
fetch_spec_factory.add_revision_ids([revision_id])
382
fetch_spec_factory.source_branch_stop_revision_id = revision_id
383
if possible_transports is None:
384
possible_transports = []
386
possible_transports = list(possible_transports) + [
388
target_transport = _mod_transport.get_transport(url,
390
target_transport.ensure_base()
391
cloning_format = self.cloning_metadir(stacked)
392
# Create/update the result branch
361
operation = cleanup.OperationWithCleanups(self._sprout)
362
return operation.run(url, revision_id=revision_id,
363
force_new_repo=force_new_repo, recurse=recurse,
364
possible_transports=possible_transports,
365
accelerator_tree=accelerator_tree, hardlink=hardlink,
366
stacked=stacked, source_branch=source_branch,
367
create_tree_if_local=create_tree_if_local)
369
def _sprout(self, op, url, revision_id=None, force_new_repo=False,
370
recurse='down', possible_transports=None,
371
accelerator_tree=None, hardlink=False, stacked=False,
372
source_branch=None, create_tree_if_local=True):
373
add_cleanup = op.add_cleanup
374
fetch_spec_factory = fetch.FetchSpecFactory()
375
if revision_id is not None:
376
fetch_spec_factory.add_revision_ids([revision_id])
377
fetch_spec_factory.source_branch_stop_revision_id = revision_id
378
if possible_transports is None:
379
possible_transports = []
381
possible_transports = list(possible_transports) + [
383
target_transport = _mod_transport.get_transport(url,
385
target_transport.ensure_base()
386
cloning_format = self.cloning_metadir(stacked)
387
# Create/update the result branch
389
result = controldir.ControlDir.open_from_transport(target_transport)
390
except errors.NotBranchError:
391
result = cloning_format.initialize_on_transport(target_transport)
392
source_branch, source_repository = self._find_source_repo(
393
add_cleanup, source_branch)
394
fetch_spec_factory.source_branch = source_branch
395
# if a stacked branch wasn't requested, we don't create one
396
# even if the origin was stacked
397
if stacked and source_branch is not None:
398
stacked_branch_url = self.root_transport.base
400
stacked_branch_url = None
401
repository_policy = result.determine_repository_policy(
402
force_new_repo, stacked_branch_url, require_stacking=stacked)
403
result_repo, is_new_repo = repository_policy.acquire_repository(
404
possible_transports=possible_transports)
405
add_cleanup(result_repo.lock_write().unlock)
406
fetch_spec_factory.source_repo = source_repository
407
fetch_spec_factory.target_repo = result_repo
408
if stacked or (len(result_repo._fallback_repositories) != 0):
409
target_repo_kind = fetch.TargetRepoKinds.STACKED
411
target_repo_kind = fetch.TargetRepoKinds.EMPTY
413
target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
414
fetch_spec_factory.target_repo_kind = target_repo_kind
415
if source_repository is not None:
416
fetch_spec = fetch_spec_factory.make_fetch_spec()
417
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
419
if source_branch is None:
420
# this is for sprouting a controldir without a branch; is that
422
# Not especially, but it's part of the contract.
423
result_branch = result.create_branch()
425
result_branch = source_branch.sprout(result,
426
revision_id=revision_id, repository_policy=repository_policy,
427
repository=result_repo)
428
mutter("created new branch %r" % (result_branch,))
430
# Create/update the result working tree
431
if (create_tree_if_local and not result.has_workingtree() and
432
isinstance(target_transport, local.LocalTransport) and
433
(result_repo is None or result_repo.make_working_trees())):
434
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
435
hardlink=hardlink, from_branch=result_branch)
394
result = controldir.ControlDir.open_from_transport(
396
except errors.NotBranchError:
397
result = cloning_format.initialize_on_transport(target_transport)
398
source_branch, source_repository = self._find_source_repo(
399
stack, source_branch)
400
fetch_spec_factory.source_branch = source_branch
401
# if a stacked branch wasn't requested, we don't create one
402
# even if the origin was stacked
403
if stacked and source_branch is not None:
404
stacked_branch_url = self.root_transport.base
406
stacked_branch_url = None
407
repository_policy = result.determine_repository_policy(
408
force_new_repo, stacked_branch_url, require_stacking=stacked)
409
result_repo, is_new_repo = repository_policy.acquire_repository(
410
possible_transports=possible_transports)
411
stack.enter_context(result_repo.lock_write())
412
fetch_spec_factory.source_repo = source_repository
413
fetch_spec_factory.target_repo = result_repo
414
if stacked or (len(result_repo._fallback_repositories) != 0):
415
target_repo_kind = fetch.TargetRepoKinds.STACKED
417
target_repo_kind = fetch.TargetRepoKinds.EMPTY
419
target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
420
fetch_spec_factory.target_repo_kind = target_repo_kind
421
if source_repository is not None:
422
fetch_spec = fetch_spec_factory.make_fetch_spec()
423
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
425
if source_branch is None:
426
# this is for sprouting a controldir without a branch; is that
428
# Not especially, but it's part of the contract.
429
result_branch = result.create_branch()
431
result_branch = source_branch.sprout(
432
result, revision_id=revision_id,
433
repository_policy=repository_policy, repository=result_repo)
434
mutter("created new branch %r" % (result_branch,))
436
# Create/update the result working tree
437
if (create_tree_if_local and not result.has_workingtree()
438
and isinstance(target_transport, local.LocalTransport)
439
and (result_repo is None or result_repo.make_working_trees())
440
and result.open_branch(
442
possible_transports=possible_transports).name == result_branch.name):
443
wt = result.create_workingtree(
444
accelerator_tree=accelerator_tree, hardlink=hardlink,
445
from_branch=result_branch)
446
with wt.lock_write():
447
if not wt.is_versioned(''):
449
wt.set_root_id(self.open_workingtree.path2id(''))
450
except errors.NoWorkingTree:
454
if recurse == 'down':
458
basis = tree.basis_tree()
459
stack.enter_context(basis.lock_read())
460
elif result_branch is not None:
461
basis = tree = result_branch.basis_tree()
462
elif source_branch is not None:
463
basis = tree = source_branch.basis_tree()
465
stack.enter_context(tree.lock_read())
466
subtrees = tree.iter_references()
469
for path in subtrees:
470
target = urlutils.join(url, urlutils.escape(path))
471
sublocation = tree.reference_parent(
472
path, branch=result_branch,
473
possible_transports=possible_transports)
474
if sublocation is None:
476
'Ignoring nested tree %s, parent location unknown.',
479
sublocation.controldir.sprout(
480
target, basis.get_reference_revision(path),
481
force_new_repo=force_new_repo, recurse=recurse,
438
if wt.path2id('') is None:
440
wt.set_root_id(self.open_workingtree.get_root_id())
441
except errors.NoWorkingTree:
447
if recurse == 'down':
450
basis = wt.basis_tree()
451
elif result_branch is not None:
452
basis = result_branch.basis_tree()
453
elif source_branch is not None:
454
basis = source_branch.basis_tree()
455
if basis is not None:
456
add_cleanup(basis.lock_read().unlock)
457
subtrees = basis.iter_references()
460
for path, file_id in subtrees:
461
target = urlutils.join(url, urlutils.escape(path))
462
sublocation = source_branch.reference_parent(file_id, path)
463
sublocation.bzrdir.sprout(target,
464
basis.get_reference_revision(file_id, path),
465
force_new_repo=force_new_repo, recurse=recurse,
485
469
def _available_backup_name(self, base):
486
470
"""Find a non-existing backup file name based on base.
488
See breezy.osutils.available_backup_name about race conditions.
472
See brzlib.osutils.available_backup_name about race conditions.
490
474
return osutils.available_backup_name(base, self.root_transport.has)
1230
1224
self.features[name] = necessity
1227
class BzrProber(controldir.Prober):
1228
"""Prober for formats that use a .bzr/ control directory."""
1230
formats = registry.FormatRegistry(controldir.network_format_registry)
1231
"""The known .bzr formats."""
1234
def probe_transport(klass, transport):
1235
"""Return the .bzrdir style format present in a directory."""
1237
format_string = transport.get_bytes(".bzr/branch-format")
1238
except errors.NoSuchFile:
1239
raise errors.NotBranchError(path=transport.base)
1241
first_line = format_string[:format_string.index("\n")+1]
1243
first_line = format_string
1245
cls = klass.formats.get(first_line)
1247
raise errors.UnknownFormatError(format=first_line, kind='bzrdir')
1248
return cls.from_string(format_string)
1251
def known_formats(cls):
1253
for name, format in cls.formats.iteritems():
1254
if callable(format):
1260
controldir.ControlDirFormat.register_prober(BzrProber)
1263
class RemoteBzrProber(controldir.Prober):
1264
"""Prober for remote servers that provide a Bazaar smart server."""
1267
def probe_transport(klass, transport):
1268
"""Return a RemoteBzrDirFormat object if it looks possible."""
1270
medium = transport.get_smart_medium()
1271
except (NotImplementedError, AttributeError,
1272
errors.TransportNotPossible, errors.NoSmartMedium,
1273
errors.SmartProtocolError):
1274
# no smart server, so not a branch for this format type.
1275
raise errors.NotBranchError(path=transport.base)
1277
# Decline to open it if the server doesn't support our required
1278
# version (3) so that the VFS-based transport will do it.
1279
if medium.should_probe():
1281
server_version = medium.protocol_version()
1282
except errors.SmartProtocolError:
1283
# Apparently there's no usable smart server there, even though
1284
# the medium supports the smart protocol.
1285
raise errors.NotBranchError(path=transport.base)
1286
if server_version != '2':
1287
raise errors.NotBranchError(path=transport.base)
1288
from brzlib.remote import RemoteBzrDirFormat
1289
return RemoteBzrDirFormat()
1292
def known_formats(cls):
1293
from brzlib.remote import RemoteBzrDirFormat
1294
return set([RemoteBzrDirFormat()])
1233
1297
class BzrDirFormat(BzrFormat, controldir.ControlDirFormat):
1234
1298
"""ControlDirFormat base class for .bzr/ directories.
1738
1791
def convert(self, to_convert, pb):
1739
1792
"""See Converter.convert()."""
1740
self.controldir = to_convert
1741
with ui.ui_factory.nested_progress_bar() as self.pb:
1744
self.step('checking repository format')
1746
repo = self.controldir.open_repository()
1747
except errors.NoRepositoryPresent:
1750
repo_fmt = self.target_format.repository_format
1751
if not isinstance(repo._format, repo_fmt.__class__):
1752
from ..repository import CopyConverter
1753
ui.ui_factory.note(gettext('starting repository conversion'))
1754
if not repo_fmt.supports_overriding_transport:
1755
raise AssertionError(
1756
"Repository in metadir does not support "
1757
"overriding transport")
1758
converter = CopyConverter(self.target_format.repository_format)
1759
converter.convert(repo, pb)
1760
for branch in self.controldir.list_branches():
1761
# TODO: conversions of Branch and Tree should be done by
1762
# InterXFormat lookups/some sort of registry.
1763
# Avoid circular imports
1793
self.bzrdir = to_convert
1794
self.pb = ui.ui_factory.nested_progress_bar()
1797
self.step('checking repository format')
1799
repo = self.bzrdir.open_repository()
1800
except errors.NoRepositoryPresent:
1803
if not isinstance(repo._format, self.target_format.repository_format.__class__):
1804
from brzlib.repository import CopyConverter
1805
ui.ui_factory.note(gettext('starting repository conversion'))
1806
converter = CopyConverter(self.target_format.repository_format)
1807
converter.convert(repo, pb)
1808
for branch in self.bzrdir.list_branches():
1809
# TODO: conversions of Branch and Tree should be done by
1810
# InterXFormat lookups/some sort of registry.
1811
# Avoid circular imports
1812
old = branch._format.__class__
1813
new = self.target_format.get_branch_format().__class__
1815
if (old == fullhistorybranch.BzrBranchFormat5 and
1816
new in (_mod_branch.BzrBranchFormat6,
1817
_mod_branch.BzrBranchFormat7,
1818
_mod_branch.BzrBranchFormat8)):
1819
branch_converter = _mod_branch.Converter5to6()
1820
elif (old == _mod_branch.BzrBranchFormat6 and
1821
new in (_mod_branch.BzrBranchFormat7,
1822
_mod_branch.BzrBranchFormat8)):
1823
branch_converter = _mod_branch.Converter6to7()
1824
elif (old == _mod_branch.BzrBranchFormat7 and
1825
new is _mod_branch.BzrBranchFormat8):
1826
branch_converter = _mod_branch.Converter7to8()
1828
raise errors.BadConversionTarget("No converter", new,
1830
branch_converter.convert(branch)
1831
branch = self.bzrdir.open_branch()
1764
1832
old = branch._format.__class__
1765
new = self.target_format.get_branch_format().__class__
1767
if (old == fullhistorybranch.BzrBranchFormat5
1768
and new in (_mod_bzrbranch.BzrBranchFormat6,
1769
_mod_bzrbranch.BzrBranchFormat7,
1770
_mod_bzrbranch.BzrBranchFormat8)):
1771
branch_converter = _mod_bzrbranch.Converter5to6()
1772
elif (old == _mod_bzrbranch.BzrBranchFormat6
1773
and new in (_mod_bzrbranch.BzrBranchFormat7,
1774
_mod_bzrbranch.BzrBranchFormat8)):
1775
branch_converter = _mod_bzrbranch.Converter6to7()
1776
elif (old == _mod_bzrbranch.BzrBranchFormat7
1777
and new is _mod_bzrbranch.BzrBranchFormat8):
1778
branch_converter = _mod_bzrbranch.Converter7to8()
1780
raise errors.BadConversionTarget("No converter", new,
1782
branch_converter.convert(branch)
1783
branch = self.controldir.open_branch()
1784
old = branch._format.__class__
1786
tree = self.controldir.open_workingtree(recommend_upgrade=False)
1787
except (errors.NoWorkingTree, errors.NotLocalUrl):
1790
# TODO: conversions of Branch and Tree should be done by
1791
# InterXFormat lookups
1792
if (isinstance(tree, workingtree_3.WorkingTree3)
1793
and not isinstance(tree, workingtree_4.DirStateWorkingTree)
1794
and isinstance(self.target_format.workingtree_format,
1795
workingtree_4.DirStateWorkingTreeFormat)):
1796
workingtree_4.Converter3to4().convert(tree)
1797
if (isinstance(tree, workingtree_4.DirStateWorkingTree)
1798
and not isinstance(tree, workingtree_4.WorkingTree5)
1799
and isinstance(self.target_format.workingtree_format,
1800
workingtree_4.WorkingTreeFormat5)):
1801
workingtree_4.Converter4to5().convert(tree)
1802
if (isinstance(tree, workingtree_4.DirStateWorkingTree)
1803
and not isinstance(tree, workingtree_4.WorkingTree6)
1804
and isinstance(self.target_format.workingtree_format,
1805
workingtree_4.WorkingTreeFormat6)):
1806
workingtree_4.Converter4or5to6().convert(tree)
1834
tree = self.bzrdir.open_workingtree(recommend_upgrade=False)
1835
except (errors.NoWorkingTree, errors.NotLocalUrl):
1838
# TODO: conversions of Branch and Tree should be done by
1839
# InterXFormat lookups
1840
if (isinstance(tree, workingtree_3.WorkingTree3) and
1841
not isinstance(tree, workingtree_4.DirStateWorkingTree) and
1842
isinstance(self.target_format.workingtree_format,
1843
workingtree_4.DirStateWorkingTreeFormat)):
1844
workingtree_4.Converter3to4().convert(tree)
1845
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and
1846
not isinstance(tree, workingtree_4.WorkingTree5) and
1847
isinstance(self.target_format.workingtree_format,
1848
workingtree_4.WorkingTreeFormat5)):
1849
workingtree_4.Converter4to5().convert(tree)
1850
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and
1851
not isinstance(tree, workingtree_4.WorkingTree6) and
1852
isinstance(self.target_format.workingtree_format,
1853
workingtree_4.WorkingTreeFormat6)):
1854
workingtree_4.Converter4or5to6().convert(tree)
1807
1856
return to_convert
1838
1887
def convert(self, to_convert, pb):
1839
1888
"""See Converter.convert()."""
1840
1889
to_convert.transport.put_bytes('branch-format',
1841
self.target_format.as_string())
1890
self.target_format.as_string())
1842
1891
return BzrDir.open_from_transport(to_convert.root_transport)
1845
class CreateRepository(controldir.RepositoryAcquisitionPolicy):
1894
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
1897
class RepositoryAcquisitionPolicy(object):
1898
"""Abstract base class for repository acquisition policies.
1900
A repository acquisition policy decides how a BzrDir acquires a repository
1901
for a branch that is being created. The most basic policy decision is
1902
whether to create a new repository or use an existing one.
1904
def __init__(self, stack_on, stack_on_pwd, require_stacking):
1907
:param stack_on: A location to stack on
1908
:param stack_on_pwd: If stack_on is relative, the location it is
1910
:param require_stacking: If True, it is a failure to not stack.
1912
self._stack_on = stack_on
1913
self._stack_on_pwd = stack_on_pwd
1914
self._require_stacking = require_stacking
1916
def configure_branch(self, branch):
1917
"""Apply any configuration data from this policy to the branch.
1919
Default implementation sets repository stacking.
1921
if self._stack_on is None:
1923
if self._stack_on_pwd is None:
1924
stack_on = self._stack_on
1927
stack_on = urlutils.rebase_url(self._stack_on,
1930
except errors.InvalidRebaseURLs:
1931
stack_on = self._get_full_stack_on()
1933
branch.set_stacked_on_url(stack_on)
1934
except (errors.UnstackableBranchFormat,
1935
errors.UnstackableRepositoryFormat):
1936
if self._require_stacking:
1939
def requires_stacking(self):
1940
"""Return True if this policy requires stacking."""
1941
return self._stack_on is not None and self._require_stacking
1943
def _get_full_stack_on(self):
1944
"""Get a fully-qualified URL for the stack_on location."""
1945
if self._stack_on is None:
1947
if self._stack_on_pwd is None:
1948
return self._stack_on
1950
return urlutils.join(self._stack_on_pwd, self._stack_on)
1952
def _add_fallback(self, repository, possible_transports=None):
1953
"""Add a fallback to the supplied repository, if stacking is set."""
1954
stack_on = self._get_full_stack_on()
1955
if stack_on is None:
1958
stacked_dir = BzrDir.open(stack_on,
1959
possible_transports=possible_transports)
1960
except errors.JailBreak:
1961
# We keep the stacking details, but we are in the server code so
1962
# actually stacking is not needed.
1965
stacked_repo = stacked_dir.open_branch().repository
1966
except errors.NotBranchError:
1967
stacked_repo = stacked_dir.open_repository()
1969
repository.add_fallback_repository(stacked_repo)
1970
except errors.UnstackableRepositoryFormat:
1971
if self._require_stacking:
1974
self._require_stacking = True
1976
def acquire_repository(self, make_working_trees=None, shared=False,
1977
possible_transports=None):
1978
"""Acquire a repository for this bzrdir.
1980
Implementations may create a new repository or use a pre-exising
1983
:param make_working_trees: If creating a repository, set
1984
make_working_trees to this value (if non-None)
1985
:param shared: If creating a repository, make it shared if True
1986
:return: A repository, is_new_flag (True if the repository was
1989
raise NotImplementedError(RepositoryAcquisitionPolicy.acquire_repository)
1992
class CreateRepository(RepositoryAcquisitionPolicy):
1846
1993
"""A policy of creating a new repository"""
1848
def __init__(self, controldir, stack_on=None, stack_on_pwd=None,
1995
def __init__(self, bzrdir, stack_on=None, stack_on_pwd=None,
1849
1996
require_stacking=False):
1850
1997
"""Constructor.
1852
:param controldir: The controldir to create the repository on.
1999
:param bzrdir: The bzrdir to create the repository on.
1853
2000
:param stack_on: A location to stack on
1854
2001
:param stack_on_pwd: If stack_on is relative, the location it is
1857
super(CreateRepository, self).__init__(
1858
stack_on, stack_on_pwd, require_stacking)
1859
self._controldir = controldir
2004
RepositoryAcquisitionPolicy.__init__(self, stack_on, stack_on_pwd,
2006
self._bzrdir = bzrdir
1861
2008
def acquire_repository(self, make_working_trees=None, shared=False,
1862
possible_transports=None):
2009
possible_transports=None):
1863
2010
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository
1865
Creates the desired repository in the controldir we already have.
2012
Creates the desired repository in the bzrdir we already have.
1867
2014
if possible_transports is None:
1868
2015
possible_transports = []
1870
2017
possible_transports = list(possible_transports)
1871
possible_transports.append(self._controldir.root_transport)
2018
possible_transports.append(self._bzrdir.root_transport)
1872
2019
stack_on = self._get_full_stack_on()
1874
format = self._controldir._format
2021
format = self._bzrdir._format
1875
2022
format.require_stacking(stack_on=stack_on,
1876
2023
possible_transports=possible_transports)
1877
2024
if not self._require_stacking:
1878
2025
# We have picked up automatic stacking somewhere.
1879
2026
note(gettext('Using default stacking branch {0} at {1}').format(
1880
2027
self._stack_on, self._stack_on_pwd))
1881
repository = self._controldir.create_repository(shared=shared)
2028
repository = self._bzrdir.create_repository(shared=shared)
1882
2029
self._add_fallback(repository,
1883
2030
possible_transports=possible_transports)
1884
2031
if make_working_trees is not None:
1912
2059
possible_transports = []
1914
2061
possible_transports = list(possible_transports)
1915
possible_transports.append(self._repository.controldir.transport)
2062
possible_transports.append(self._repository.bzrdir.transport)
1916
2063
self._add_fallback(self._repository,
1917
possible_transports=possible_transports)
2064
possible_transports=possible_transports)
1918
2065
return self._repository, False
1921
controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()
2068
def register_metadir(registry, key,
2069
repository_format, help, native=True, deprecated=False,
2074
alias=False, bzrdir_format=None):
2075
"""Register a metadir subformat.
2077
These all use a meta bzrdir, but can be parameterized by the
2078
Repository/Branch/WorkingTreeformats.
2080
:param repository_format: The fully-qualified repository format class
2082
:param branch_format: Fully-qualified branch format class name as
2084
:param tree_format: Fully-qualified tree format class name as
2087
if bzrdir_format is None:
2088
bzrdir_format = BzrDirMetaFormat1
2089
# This should be expanded to support setting WorkingTree and Branch
2090
# formats, once the API supports that.
2091
def _load(full_name):
2092
mod_name, factory_name = full_name.rsplit('.', 1)
2094
factory = pyutils.get_named_object(mod_name, factory_name)
2095
except ImportError, e:
2096
raise ImportError('failed to load %s: %s' % (full_name, e))
2097
except AttributeError:
2098
raise AttributeError('no factory %s in module %r'
2099
% (full_name, sys.modules[mod_name]))
2103
bd = bzrdir_format()
2104
if branch_format is not None:
2105
bd.set_branch_format(_load(branch_format))
2106
if tree_format is not None:
2107
bd.workingtree_format = _load(tree_format)
2108
if repository_format is not None:
2109
bd.repository_format = _load(repository_format)
2111
registry.register(key, helper, help, native, deprecated, hidden,
2112
experimental, alias)
2114
register_metadir(controldir.format_registry, 'knit',
2115
'brzlib.repofmt.knitrepo.RepositoryFormatKnit1',
2116
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
2117
branch_format='brzlib.branchfmt.fullhistory.BzrBranchFormat5',
2118
tree_format='brzlib.workingtree_3.WorkingTreeFormat3',
2121
register_metadir(controldir.format_registry, 'dirstate',
2122
'brzlib.repofmt.knitrepo.RepositoryFormatKnit1',
2123
help='Format using dirstate for working trees. '
2124
'Compatible with bzr 0.8 and '
2125
'above when accessed over the network. Introduced in bzr 0.15.',
2126
branch_format='brzlib.branchfmt.fullhistory.BzrBranchFormat5',
2127
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2130
register_metadir(controldir.format_registry, 'dirstate-tags',
2131
'brzlib.repofmt.knitrepo.RepositoryFormatKnit1',
2132
help='Variant of dirstate with support for tags. '
2133
'Introduced in bzr 0.15.',
2134
branch_format='brzlib.branch.BzrBranchFormat6',
2135
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2138
register_metadir(controldir.format_registry, 'rich-root',
2139
'brzlib.repofmt.knitrepo.RepositoryFormatKnit4',
2140
help='Variant of dirstate with better handling of tree roots. '
2141
'Introduced in bzr 1.0',
2142
branch_format='brzlib.branch.BzrBranchFormat6',
2143
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2146
register_metadir(controldir.format_registry, 'dirstate-with-subtree',
2147
'brzlib.repofmt.knitrepo.RepositoryFormatKnit3',
2148
help='Variant of dirstate with support for nested trees. '
2149
'Introduced in 0.15.',
2150
branch_format='brzlib.branch.BzrBranchFormat6',
2151
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2155
register_metadir(controldir.format_registry, 'pack-0.92',
2156
'brzlib.repofmt.knitpack_repo.RepositoryFormatKnitPack1',
2157
help='Pack-based format used in 1.x series. Introduced in 0.92. '
2158
'Interoperates with bzr repositories before 0.92 but cannot be '
2159
'read by bzr < 0.92. '
2161
branch_format='brzlib.branch.BzrBranchFormat6',
2162
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2165
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
2166
'brzlib.repofmt.knitpack_repo.RepositoryFormatKnitPack3',
2167
help='Pack-based format used in 1.x series, with subtree support. '
2168
'Introduced in 0.92. Interoperates with '
2169
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2171
branch_format='brzlib.branch.BzrBranchFormat6',
2172
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2177
register_metadir(controldir.format_registry, 'rich-root-pack',
2178
'brzlib.repofmt.knitpack_repo.RepositoryFormatKnitPack4',
2179
help='A variant of pack-0.92 that supports rich-root data '
2180
'(needed for bzr-svn and bzr-git). Introduced in 1.0.',
2181
branch_format='brzlib.branch.BzrBranchFormat6',
2182
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2186
register_metadir(controldir.format_registry, '1.6',
2187
'brzlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5',
2188
help='A format that allows a branch to indicate that there is another '
2189
'(stacked) repository that should be used to access data that is '
2190
'not present locally.',
2191
branch_format='brzlib.branch.BzrBranchFormat7',
2192
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2196
register_metadir(controldir.format_registry, '1.6.1-rich-root',
2197
'brzlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5RichRoot',
2198
help='A variant of 1.6 that supports rich-root data '
2199
'(needed for bzr-svn and bzr-git).',
2200
branch_format='brzlib.branch.BzrBranchFormat7',
2201
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2205
register_metadir(controldir.format_registry, '1.9',
2206
'brzlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
2207
help='A repository format using B+tree indexes. These indexes '
2208
'are smaller in size, have smarter caching and provide faster '
2209
'performance for most operations.',
2210
branch_format='brzlib.branch.BzrBranchFormat7',
2211
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2215
register_metadir(controldir.format_registry, '1.9-rich-root',
2216
'brzlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
2217
help='A variant of 1.9 that supports rich-root data '
2218
'(needed for bzr-svn and bzr-git).',
2219
branch_format='brzlib.branch.BzrBranchFormat7',
2220
tree_format='brzlib.workingtree_4.WorkingTreeFormat4',
2224
register_metadir(controldir.format_registry, '1.14',
2225
'brzlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
2226
help='A working-tree format that supports content filtering.',
2227
branch_format='brzlib.branch.BzrBranchFormat7',
2228
tree_format='brzlib.workingtree_4.WorkingTreeFormat5',
2232
register_metadir(controldir.format_registry, '1.14-rich-root',
2233
'brzlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
2234
help='A variant of 1.14 that supports rich-root data '
2235
'(needed for bzr-svn and bzr-git).',
2236
branch_format='brzlib.branch.BzrBranchFormat7',
2237
tree_format='brzlib.workingtree_4.WorkingTreeFormat5',
2241
# The following un-numbered 'development' formats should always just be aliases.
2242
register_metadir(controldir.format_registry, 'development-subtree',
2243
'brzlib.repofmt.groupcompress_repo.RepositoryFormat2aSubtree',
2244
help='Current development format, subtree variant. Can convert data to and '
2245
'from pack-0.92-subtree (and anything compatible with '
2246
'pack-0.92-subtree) format repositories. Repositories and branches in '
2247
'this format can only be read by bzr.dev. Please read '
2248
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
2250
branch_format='brzlib.branch.BzrBranchFormat7',
2251
tree_format='brzlib.workingtree_4.WorkingTreeFormat6',
2254
alias=False, # Restore to being an alias when an actual development subtree format is added
2255
# This current non-alias status is simply because we did not introduce a
2256
# chk based subtree format.
2258
register_metadir(controldir.format_registry, 'development5-subtree',
2259
'brzlib.repofmt.knitpack_repo.RepositoryFormatPackDevelopment2Subtree',
2260
help='Development format, subtree variant. Can convert data to and '
2261
'from pack-0.92-subtree (and anything compatible with '
2262
'pack-0.92-subtree) format repositories. Repositories and branches in '
2263
'this format can only be read by bzr.dev. Please read '
2264
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
2266
branch_format='brzlib.branch.BzrBranchFormat7',
2267
tree_format='brzlib.workingtree_4.WorkingTreeFormat6',
2273
register_metadir(controldir.format_registry, 'development-colo',
2274
'brzlib.repofmt.groupcompress_repo.RepositoryFormat2a',
2275
help='The 2a format with experimental support for colocated branches.\n',
2276
branch_format='brzlib.branch.BzrBranchFormat7',
2277
tree_format='brzlib.workingtree_4.WorkingTreeFormat6',
2279
bzrdir_format=BzrDirMetaFormat1Colo,
2283
# And the development formats above will have aliased one of the following:
2285
# Finally, the current format.
2286
register_metadir(controldir.format_registry, '2a',
2287
'brzlib.repofmt.groupcompress_repo.RepositoryFormat2a',
2288
help='Format for the bzr 2.0 series.\n'
2289
'Uses group-compress storage.\n'
2290
'Provides rich roots which are a one-way transition.\n',
2291
# 'storage in packs, 255-way hashed CHK inventory, bencode revision, group compress, '
2292
# 'rich roots. Supported by bzr 1.16 and later.',
2293
branch_format='brzlib.branch.BzrBranchFormat7',
2294
tree_format='brzlib.workingtree_4.WorkingTreeFormat6',
2298
# The following format should be an alias for the rich root equivalent
2299
# of the default format
2300
register_metadir(controldir.format_registry, 'default-rich-root',
2301
'brzlib.repofmt.groupcompress_repo.RepositoryFormat2a',
2302
branch_format='brzlib.branch.BzrBranchFormat7',
2303
tree_format='brzlib.workingtree_4.WorkingTreeFormat6',
2308
# The current format that is made on 'bzr init'.
2309
format_name = config.GlobalStack().get('default_format')
2310
controldir.format_registry.set_default(format_name)
2312
# XXX 2010-08-20 JRV: There is still a lot of code relying on
2313
# brzlib.bzrdir.format_registry existing. When BzrDir.create/BzrDir.open/etc
2314
# get changed to ControlDir.create/ControlDir.open/etc this should be removed.
2315
format_registry = controldir.format_registry