389
429
policy = self.determine_repository_policy(force_new_repo)
390
430
return policy.acquire_repository()[0]
392
def _find_source_repo(self, add_cleanup, source_branch):
393
"""Find the source branch and repo for a sprout operation.
395
This is helper intended for use by _sprout.
397
:returns: (source_branch, source_repository). Either or both may be
398
None. If not None, they will be read-locked (and their unlock(s)
399
scheduled via the add_cleanup param).
401
if source_branch is not None:
402
add_cleanup(source_branch.lock_read().unlock)
403
return source_branch, source_branch.repository
405
source_branch = self.open_branch()
406
source_repository = source_branch.repository
407
except errors.NotBranchError:
410
source_repository = self.open_repository()
411
except errors.NoRepositoryPresent:
412
source_repository = None
414
add_cleanup(source_repository.lock_read().unlock)
416
add_cleanup(source_branch.lock_read().unlock)
417
return source_branch, source_repository
419
def sprout(self, url, revision_id=None, force_new_repo=False,
420
recurse='down', possible_transports=None,
421
accelerator_tree=None, hardlink=False, stacked=False,
422
source_branch=None, create_tree_if_local=True):
423
"""Create a copy of this controldir prepared for use as a new line of
426
If url's last component does not exist, it will be created.
428
Attributes related to the identity of the source branch like
429
branch nickname will be cleaned, a working tree is created
430
whether one existed before or not; and a local branch is always
433
if revision_id is not None, then the clone operation may tune
434
itself to download less data.
436
:param accelerator_tree: A tree which can be used for retrieving file
437
contents more quickly than the revision tree, i.e. a workingtree.
438
The revision tree will be used for cases where accelerator_tree's
439
content is different.
440
:param hardlink: If true, hard-link files from accelerator_tree,
442
:param stacked: If true, create a stacked branch referring to the
443
location of this control directory.
444
:param create_tree_if_local: If true, a working-tree will be created
445
when working locally.
447
operation = cleanup.OperationWithCleanups(self._sprout)
448
return operation.run(url, revision_id=revision_id,
449
force_new_repo=force_new_repo, recurse=recurse,
450
possible_transports=possible_transports,
451
accelerator_tree=accelerator_tree, hardlink=hardlink,
452
stacked=stacked, source_branch=source_branch,
453
create_tree_if_local=create_tree_if_local)
455
def _sprout(self, op, url, revision_id=None, force_new_repo=False,
456
recurse='down', possible_transports=None,
457
accelerator_tree=None, hardlink=False, stacked=False,
458
source_branch=None, create_tree_if_local=True):
459
add_cleanup = op.add_cleanup
460
fetch_spec_factory = fetch.FetchSpecFactory()
461
if revision_id is not None:
462
fetch_spec_factory.add_revision_ids([revision_id])
463
fetch_spec_factory.source_branch_stop_revision_id = revision_id
464
target_transport = _mod_transport.get_transport(url,
466
target_transport.ensure_base()
467
cloning_format = self.cloning_metadir(stacked)
468
# Create/update the result branch
469
result = cloning_format.initialize_on_transport(target_transport)
470
source_branch, source_repository = self._find_source_repo(
471
add_cleanup, source_branch)
472
fetch_spec_factory.source_branch = source_branch
473
# if a stacked branch wasn't requested, we don't create one
474
# even if the origin was stacked
475
if stacked and source_branch is not None:
476
stacked_branch_url = self.root_transport.base
478
stacked_branch_url = None
479
repository_policy = result.determine_repository_policy(
480
force_new_repo, stacked_branch_url, require_stacking=stacked)
481
result_repo, is_new_repo = repository_policy.acquire_repository()
482
add_cleanup(result_repo.lock_write().unlock)
483
fetch_spec_factory.source_repo = source_repository
484
fetch_spec_factory.target_repo = result_repo
485
if stacked or (len(result_repo._fallback_repositories) != 0):
486
target_repo_kind = fetch.TargetRepoKinds.STACKED
488
target_repo_kind = fetch.TargetRepoKinds.EMPTY
490
target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
491
fetch_spec_factory.target_repo_kind = target_repo_kind
492
if source_repository is not None:
493
fetch_spec = fetch_spec_factory.make_fetch_spec()
494
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
496
if source_branch is None:
497
# this is for sprouting a controldir without a branch; is that
499
# Not especially, but it's part of the contract.
500
result_branch = result.create_branch()
502
result_branch = source_branch.sprout(result,
503
revision_id=revision_id, repository_policy=repository_policy,
504
repository=result_repo)
505
mutter("created new branch %r" % (result_branch,))
507
# Create/update the result working tree
508
if (create_tree_if_local and
509
isinstance(target_transport, local.LocalTransport) and
510
(result_repo is None or result_repo.make_working_trees())):
511
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
512
hardlink=hardlink, from_branch=result_branch)
515
if wt.path2id('') is None:
517
wt.set_root_id(self.open_workingtree.get_root_id())
518
except errors.NoWorkingTree:
524
if recurse == 'down':
527
basis = wt.basis_tree()
528
elif result_branch is not None:
529
basis = result_branch.basis_tree()
530
elif source_branch is not None:
531
basis = source_branch.basis_tree()
532
if basis is not None:
533
add_cleanup(basis.lock_read().unlock)
534
subtrees = basis.iter_references()
537
for path, file_id in subtrees:
538
target = urlutils.join(url, urlutils.escape(path))
539
sublocation = source_branch.reference_parent(file_id, path)
540
sublocation.bzrdir.sprout(target,
541
basis.get_reference_revision(file_id, path),
542
force_new_repo=force_new_repo, recurse=recurse,
549
433
def create_branch_convenience(base, force_new_repo=False,
550
434
force_new_tree=None, format=None,
982
class BzrDirPreSplitOut(BzrDir):
983
"""A common class for the all-in-one formats."""
985
def __init__(self, _transport, _format):
986
"""See BzrDir.__init__."""
987
super(BzrDirPreSplitOut, self).__init__(_transport, _format)
988
self._control_files = lockable_files.LockableFiles(
989
self.get_branch_transport(None),
990
self._format._lock_file_name,
991
self._format._lock_class)
993
def break_lock(self):
994
"""Pre-splitout bzrdirs do not suffer from stale locks."""
995
raise NotImplementedError(self.break_lock)
997
def cloning_metadir(self, require_stacking=False):
998
"""Produce a metadir suitable for cloning with."""
1000
return controldir.format_registry.make_bzrdir('1.6')
1001
return self._format.__class__()
1003
def clone(self, url, revision_id=None, force_new_repo=False,
1004
preserve_stacking=False):
1005
"""See BzrDir.clone().
1007
force_new_repo has no effect, since this family of formats always
1008
require a new repository.
1009
preserve_stacking has no effect, since no source branch using this
1010
family of formats can be stacked, so there is no stacking to preserve.
1012
self._make_tail(url)
1013
result = self._format._initialize_for_clone(url)
1014
self.open_repository().clone(result, revision_id=revision_id)
1015
from_branch = self.open_branch()
1016
from_branch.clone(result, revision_id=revision_id)
1018
tree = self.open_workingtree()
1019
except errors.NotLocalUrl:
1020
# make a new one, this format always has to have one.
1021
result._init_workingtree()
1026
def create_branch(self, name=None):
1027
"""See BzrDir.create_branch."""
1028
return self._format.get_branch_format().initialize(self, name=name)
1030
def destroy_branch(self, name=None):
1031
"""See BzrDir.destroy_branch."""
1032
raise errors.UnsupportedOperation(self.destroy_branch, self)
1034
def create_repository(self, shared=False):
1035
"""See BzrDir.create_repository."""
1037
raise errors.IncompatibleFormat('shared repository', self._format)
1038
return self.open_repository()
1040
def destroy_repository(self):
1041
"""See BzrDir.destroy_repository."""
1042
raise errors.UnsupportedOperation(self.destroy_repository, self)
1044
def create_workingtree(self, revision_id=None, from_branch=None,
1045
accelerator_tree=None, hardlink=False):
1046
"""See BzrDir.create_workingtree."""
1047
# The workingtree is sometimes created when the bzrdir is created,
1048
# but not when cloning.
1050
# this looks buggy but is not -really-
1051
# because this format creates the workingtree when the bzrdir is
1053
# clone and sprout will have set the revision_id
1054
# and that will have set it for us, its only
1055
# specific uses of create_workingtree in isolation
1056
# that can do wonky stuff here, and that only
1057
# happens for creating checkouts, which cannot be
1058
# done on this format anyway. So - acceptable wart.
1060
warning("can't support hardlinked working trees in %r"
1063
result = self.open_workingtree(recommend_upgrade=False)
1064
except errors.NoSuchFile:
1065
result = self._init_workingtree()
1066
if revision_id is not None:
1067
if revision_id == _mod_revision.NULL_REVISION:
1068
result.set_parent_ids([])
1070
result.set_parent_ids([revision_id])
1073
def _init_workingtree(self):
1074
from bzrlib.workingtree import WorkingTreeFormat2
1076
return WorkingTreeFormat2().initialize(self)
1077
except errors.NotLocalUrl:
1078
# Even though we can't access the working tree, we need to
1079
# create its control files.
1080
return WorkingTreeFormat2()._stub_initialize_on_transport(
1081
self.transport, self._control_files._file_mode)
1083
def destroy_workingtree(self):
1084
"""See BzrDir.destroy_workingtree."""
1085
raise errors.UnsupportedOperation(self.destroy_workingtree, self)
1087
def destroy_workingtree_metadata(self):
1088
"""See BzrDir.destroy_workingtree_metadata."""
1089
raise errors.UnsupportedOperation(self.destroy_workingtree_metadata,
1092
def get_branch_transport(self, branch_format, name=None):
1093
"""See BzrDir.get_branch_transport()."""
1094
if name is not None:
1095
raise errors.NoColocatedBranchSupport(self)
1096
if branch_format is None:
1097
return self.transport
1099
branch_format.get_format_string()
1100
except NotImplementedError:
1101
return self.transport
1102
raise errors.IncompatibleFormat(branch_format, self._format)
1104
def get_repository_transport(self, repository_format):
1105
"""See BzrDir.get_repository_transport()."""
1106
if repository_format is None:
1107
return self.transport
1109
repository_format.get_format_string()
1110
except NotImplementedError:
1111
return self.transport
1112
raise errors.IncompatibleFormat(repository_format, self._format)
1114
def get_workingtree_transport(self, workingtree_format):
1115
"""See BzrDir.get_workingtree_transport()."""
1116
if workingtree_format is None:
1117
return self.transport
1119
workingtree_format.get_format_string()
1120
except NotImplementedError:
1121
return self.transport
1122
raise errors.IncompatibleFormat(workingtree_format, self._format)
1124
def needs_format_conversion(self, format=None):
1125
"""See BzrDir.needs_format_conversion()."""
1126
# if the format is not the same as the system default,
1127
# an upgrade is needed.
1129
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1130
% 'needs_format_conversion(format=None)')
1131
format = BzrDirFormat.get_default_format()
1132
return not isinstance(self._format, format.__class__)
1134
def open_branch(self, name=None, unsupported=False,
1135
ignore_fallbacks=False):
1136
"""See BzrDir.open_branch."""
1137
from bzrlib.branch import BzrBranchFormat4
1138
format = BzrBranchFormat4()
1139
self._check_supported(format, unsupported)
1140
return format.open(self, name, _found=True)
1142
def sprout(self, url, revision_id=None, force_new_repo=False,
1143
possible_transports=None, accelerator_tree=None,
1144
hardlink=False, stacked=False, create_tree_if_local=True,
1145
source_branch=None):
1146
"""See BzrDir.sprout()."""
1147
if source_branch is not None:
1148
my_branch = self.open_branch()
1149
if source_branch.base != my_branch.base:
1150
raise AssertionError(
1151
"source branch %r is not within %r with branch %r" %
1152
(source_branch, self, my_branch))
1154
raise errors.UnstackableBranchFormat(
1155
self._format, self.root_transport.base)
1156
if not create_tree_if_local:
1157
raise errors.MustHaveWorkingTree(
1158
self._format, self.root_transport.base)
1159
from bzrlib.workingtree import WorkingTreeFormat2
1160
self._make_tail(url)
1161
result = self._format._initialize_for_clone(url)
1163
self.open_repository().clone(result, revision_id=revision_id)
1164
except errors.NoRepositoryPresent:
1167
self.open_branch().sprout(result, revision_id=revision_id)
1168
except errors.NotBranchError:
1171
# we always want a working tree
1172
WorkingTreeFormat2().initialize(result,
1173
accelerator_tree=accelerator_tree,
1178
class BzrDir4(BzrDirPreSplitOut):
1179
"""A .bzr version 4 control object.
1181
This is a deprecated format and may be removed after sept 2006.
1184
def create_repository(self, shared=False):
1185
"""See BzrDir.create_repository."""
1186
return self._format.repository_format.initialize(self, shared)
1188
def needs_format_conversion(self, format=None):
1189
"""Format 4 dirs are always in need of conversion."""
1191
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1192
% 'needs_format_conversion(format=None)')
1195
def open_repository(self):
1196
"""See BzrDir.open_repository."""
1197
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1198
return RepositoryFormat4().open(self, _found=True)
1201
class BzrDir5(BzrDirPreSplitOut):
1202
"""A .bzr version 5 control object.
1204
This is a deprecated format and may be removed after sept 2006.
1207
def has_workingtree(self):
1208
"""See BzrDir.has_workingtree."""
1211
def open_repository(self):
1212
"""See BzrDir.open_repository."""
1213
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1214
return RepositoryFormat5().open(self, _found=True)
1216
def open_workingtree(self, _unsupported=False,
1217
recommend_upgrade=True):
1218
"""See BzrDir.create_workingtree."""
1219
from bzrlib.workingtree import WorkingTreeFormat2
1220
wt_format = WorkingTreeFormat2()
1221
# we don't warn here about upgrades; that ought to be handled for the
1223
return wt_format.open(self, _found=True)
1226
class BzrDir6(BzrDirPreSplitOut):
1227
"""A .bzr version 6 control object.
1229
This is a deprecated format and may be removed after sept 2006.
1232
def has_workingtree(self):
1233
"""See BzrDir.has_workingtree."""
1236
def open_repository(self):
1237
"""See BzrDir.open_repository."""
1238
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1239
return RepositoryFormat6().open(self, _found=True)
1241
def open_workingtree(self, _unsupported=False,
1242
recommend_upgrade=True):
1243
"""See BzrDir.create_workingtree."""
1244
# we don't warn here about upgrades; that ought to be handled for the
1246
from bzrlib.workingtree import WorkingTreeFormat2
1247
return WorkingTreeFormat2().open(self, _found=True)
1136
1250
class BzrDirMeta1(BzrDir):
1137
1251
"""A .bzr meta version 1 control object.
1719
def unregister_format(klass, format):
1720
BzrProber.unregister_bzrdir_format(format)
1721
controldir.ControlDirFormat.unregister_format(format)
1722
controldir.network_format_registry.remove(format.get_format_string())
1725
class BzrDirFormat4(BzrDirFormat):
1726
"""Bzr dir format 4.
1728
This format is a combined format for working tree, branch and repository.
1730
- Format 1 working trees [always]
1731
- Format 4 branches [always]
1732
- Format 4 repositories [always]
1734
This format is deprecated: it indexes texts using a text it which is
1735
removed in format 5; write support for this format has been removed.
1738
_lock_class = lockable_files.TransportLock
1740
def get_format_string(self):
1741
"""See BzrDirFormat.get_format_string()."""
1742
return "Bazaar-NG branch, format 0.0.4\n"
1744
def get_format_description(self):
1745
"""See BzrDirFormat.get_format_description()."""
1746
return "All-in-one format 4"
1748
def get_converter(self, format=None):
1749
"""See BzrDirFormat.get_converter()."""
1750
# there is one and only one upgrade path here.
1751
return ConvertBzrDir4To5()
1753
def initialize_on_transport(self, transport):
1754
"""Format 4 branches cannot be created."""
1755
raise errors.UninitializableFormat(self)
1757
def is_supported(self):
1758
"""Format 4 is not supported.
1760
It is not supported because the model changed from 4 to 5 and the
1761
conversion logic is expensive - so doing it on the fly was not
1766
def network_name(self):
1767
return self.get_format_string()
1769
def _open(self, transport):
1770
"""See BzrDirFormat._open."""
1771
return BzrDir4(transport, self)
1773
def __return_repository_format(self):
1774
"""Circular import protection."""
1775
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1776
return RepositoryFormat4()
1777
repository_format = property(__return_repository_format)
1780
class BzrDirFormatAllInOne(BzrDirFormat):
1781
"""Common class for formats before meta-dirs."""
1783
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
1784
create_prefix=False, force_new_repo=False, stacked_on=None,
1785
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
1787
"""See BzrDirFormat.initialize_on_transport_ex."""
1788
require_stacking = (stacked_on is not None)
1789
# Format 5 cannot stack, but we've been asked to - actually init
1791
if require_stacking:
1792
format = BzrDirMetaFormat1()
1793
return format.initialize_on_transport_ex(transport,
1794
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1795
force_new_repo=force_new_repo, stacked_on=stacked_on,
1796
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1797
make_working_trees=make_working_trees, shared_repo=shared_repo)
1798
return BzrDirFormat.initialize_on_transport_ex(self, transport,
1799
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1800
force_new_repo=force_new_repo, stacked_on=stacked_on,
1801
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1802
make_working_trees=make_working_trees, shared_repo=shared_repo)
1805
class BzrDirFormat5(BzrDirFormatAllInOne):
1806
"""Bzr control format 5.
1808
This format is a combined format for working tree, branch and repository.
1810
- Format 2 working trees [always]
1811
- Format 4 branches [always]
1812
- Format 5 repositories [always]
1813
Unhashed stores in the repository.
1816
_lock_class = lockable_files.TransportLock
1818
def get_format_string(self):
1819
"""See BzrDirFormat.get_format_string()."""
1820
return "Bazaar-NG branch, format 5\n"
1822
def get_branch_format(self):
1823
from bzrlib import branch
1824
return branch.BzrBranchFormat4()
1826
def get_format_description(self):
1827
"""See BzrDirFormat.get_format_description()."""
1828
return "All-in-one format 5"
1830
def get_converter(self, format=None):
1831
"""See BzrDirFormat.get_converter()."""
1832
# there is one and only one upgrade path here.
1833
return ConvertBzrDir5To6()
1835
def _initialize_for_clone(self, url):
1836
return self.initialize_on_transport(get_transport(url), _cloning=True)
1838
def initialize_on_transport(self, transport, _cloning=False):
1839
"""Format 5 dirs always have working tree, branch and repository.
1841
Except when they are being cloned.
1843
from bzrlib.branch import BzrBranchFormat4
1844
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1845
result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
1846
RepositoryFormat5().initialize(result, _internal=True)
1848
branch = BzrBranchFormat4().initialize(result)
1849
result._init_workingtree()
1852
def network_name(self):
1853
return self.get_format_string()
1855
def _open(self, transport):
1856
"""See BzrDirFormat._open."""
1857
return BzrDir5(transport, self)
1859
def __return_repository_format(self):
1860
"""Circular import protection."""
1861
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1862
return RepositoryFormat5()
1863
repository_format = property(__return_repository_format)
1866
class BzrDirFormat6(BzrDirFormatAllInOne):
1867
"""Bzr control format 6.
1869
This format is a combined format for working tree, branch and repository.
1871
- Format 2 working trees [always]
1872
- Format 4 branches [always]
1873
- Format 6 repositories [always]
1876
_lock_class = lockable_files.TransportLock
1878
def get_format_string(self):
1879
"""See BzrDirFormat.get_format_string()."""
1880
return "Bazaar-NG branch, format 6\n"
1882
def get_format_description(self):
1883
"""See BzrDirFormat.get_format_description()."""
1884
return "All-in-one format 6"
1886
def get_branch_format(self):
1887
from bzrlib import branch
1888
return branch.BzrBranchFormat4()
1890
def get_converter(self, format=None):
1891
"""See BzrDirFormat.get_converter()."""
1892
# there is one and only one upgrade path here.
1893
return ConvertBzrDir6ToMeta()
1895
def _initialize_for_clone(self, url):
1896
return self.initialize_on_transport(get_transport(url), _cloning=True)
1898
def initialize_on_transport(self, transport, _cloning=False):
1899
"""Format 6 dirs always have working tree, branch and repository.
1901
Except when they are being cloned.
1903
from bzrlib.branch import BzrBranchFormat4
1904
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1905
result = super(BzrDirFormat6, self).initialize_on_transport(transport)
1906
RepositoryFormat6().initialize(result, _internal=True)
1908
branch = BzrBranchFormat4().initialize(result)
1909
result._init_workingtree()
1912
def network_name(self):
1913
return self.get_format_string()
1915
def _open(self, transport):
1916
"""See BzrDirFormat._open."""
1917
return BzrDir6(transport, self)
1919
def __return_repository_format(self):
1920
"""Circular import protection."""
1921
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1922
return RepositoryFormat6()
1923
repository_format = property(__return_repository_format)
1613
1926
class BzrDirMetaFormat1(BzrDirFormat):
1614
1927
"""Bzr meta control format 1
1616
1929
This is the first format with split out working tree, branch and repository
1621
- Format 3 working trees [optional]
1622
- Format 5 branches [optional]
1623
- Format 7 repositories [optional]
1932
- Format 3 working trees [optional]
1933
- Format 5 branches [optional]
1934
- Format 7 repositories [optional]
1626
1937
_lock_class = lockdir.LockDir
1628
fixed_components = False
1630
1939
def __init__(self):
1631
1940
self._workingtree_format = None
1632
1941
self._branch_format = None
1826
2131
# Register bzr formats
1827
BzrProber.formats.register(BzrDirMetaFormat1.get_format_string(),
1829
controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()
1832
class ConvertMetaToMeta(controldir.Converter):
2132
BzrDirFormat.register_format(BzrDirFormat4())
2133
BzrDirFormat.register_format(BzrDirFormat5())
2134
BzrDirFormat.register_format(BzrDirFormat6())
2135
__default_format = BzrDirMetaFormat1()
2136
BzrDirFormat.register_format(__default_format)
2137
controldir.ControlDirFormat._default_format = __default_format
2140
class Converter(object):
2141
"""Converts a disk format object from one format to another."""
2143
def convert(self, to_convert, pb):
2144
"""Perform the conversion of to_convert, giving feedback via pb.
2146
:param to_convert: The disk object to convert.
2147
:param pb: a progress bar to use for progress information.
2150
def step(self, message):
2151
"""Update the pb by a step."""
2153
self.pb.update(message, self.count, self.total)
2156
class ConvertBzrDir4To5(Converter):
2157
"""Converts format 4 bzr dirs to format 5."""
2160
super(ConvertBzrDir4To5, self).__init__()
2161
self.converted_revs = set()
2162
self.absent_revisions = set()
2166
def convert(self, to_convert, pb):
2167
"""See Converter.convert()."""
2168
self.bzrdir = to_convert
2170
warnings.warn("pb parameter to convert() is deprecated")
2171
self.pb = ui.ui_factory.nested_progress_bar()
2173
ui.ui_factory.note('starting upgrade from format 4 to 5')
2174
if isinstance(self.bzrdir.transport, local.LocalTransport):
2175
self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2176
self._convert_to_weaves()
2177
return BzrDir.open(self.bzrdir.user_url)
2181
def _convert_to_weaves(self):
2182
ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
2185
stat = self.bzrdir.transport.stat('weaves')
2186
if not S_ISDIR(stat.st_mode):
2187
self.bzrdir.transport.delete('weaves')
2188
self.bzrdir.transport.mkdir('weaves')
2189
except errors.NoSuchFile:
2190
self.bzrdir.transport.mkdir('weaves')
2191
# deliberately not a WeaveFile as we want to build it up slowly.
2192
self.inv_weave = Weave('inventory')
2193
# holds in-memory weaves for all files
2194
self.text_weaves = {}
2195
self.bzrdir.transport.delete('branch-format')
2196
self.branch = self.bzrdir.open_branch()
2197
self._convert_working_inv()
2198
rev_history = self.branch.revision_history()
2199
# to_read is a stack holding the revisions we still need to process;
2200
# appending to it adds new highest-priority revisions
2201
self.known_revisions = set(rev_history)
2202
self.to_read = rev_history[-1:]
2204
rev_id = self.to_read.pop()
2205
if (rev_id not in self.revisions
2206
and rev_id not in self.absent_revisions):
2207
self._load_one_rev(rev_id)
2209
to_import = self._make_order()
2210
for i, rev_id in enumerate(to_import):
2211
self.pb.update('converting revision', i, len(to_import))
2212
self._convert_one_rev(rev_id)
2214
self._write_all_weaves()
2215
self._write_all_revs()
2216
ui.ui_factory.note('upgraded to weaves:')
2217
ui.ui_factory.note(' %6d revisions and inventories' % len(self.revisions))
2218
ui.ui_factory.note(' %6d revisions not present' % len(self.absent_revisions))
2219
ui.ui_factory.note(' %6d texts' % self.text_count)
2220
self._cleanup_spare_files_after_format4()
2221
self.branch._transport.put_bytes(
2223
BzrDirFormat5().get_format_string(),
2224
mode=self.bzrdir._get_file_mode())
2226
def _cleanup_spare_files_after_format4(self):
2227
# FIXME working tree upgrade foo.
2228
for n in 'merged-patches', 'pending-merged-patches':
2230
## assert os.path.getsize(p) == 0
2231
self.bzrdir.transport.delete(n)
2232
except errors.NoSuchFile:
2234
self.bzrdir.transport.delete_tree('inventory-store')
2235
self.bzrdir.transport.delete_tree('text-store')
2237
def _convert_working_inv(self):
2238
inv = xml4.serializer_v4.read_inventory(
2239
self.branch._transport.get('inventory'))
2240
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv, working=True)
2241
self.branch._transport.put_bytes('inventory', new_inv_xml,
2242
mode=self.bzrdir._get_file_mode())
2244
def _write_all_weaves(self):
2245
controlweaves = WeaveStore(self.bzrdir.transport, prefixed=False)
2246
weave_transport = self.bzrdir.transport.clone('weaves')
2247
weaves = WeaveStore(weave_transport, prefixed=False)
2248
transaction = WriteTransaction()
2252
for file_id, file_weave in self.text_weaves.items():
2253
self.pb.update('writing weave', i, len(self.text_weaves))
2254
weaves._put_weave(file_id, file_weave, transaction)
2256
self.pb.update('inventory', 0, 1)
2257
controlweaves._put_weave('inventory', self.inv_weave, transaction)
2258
self.pb.update('inventory', 1, 1)
2262
def _write_all_revs(self):
2263
"""Write all revisions out in new form."""
2264
self.bzrdir.transport.delete_tree('revision-store')
2265
self.bzrdir.transport.mkdir('revision-store')
2266
revision_transport = self.bzrdir.transport.clone('revision-store')
2268
from bzrlib.xml5 import serializer_v5
2269
from bzrlib.repofmt.weaverepo import RevisionTextStore
2270
revision_store = RevisionTextStore(revision_transport,
2271
serializer_v5, False, versionedfile.PrefixMapper(),
2272
lambda:True, lambda:True)
2274
for i, rev_id in enumerate(self.converted_revs):
2275
self.pb.update('write revision', i, len(self.converted_revs))
2276
text = serializer_v5.write_revision_to_string(
2277
self.revisions[rev_id])
2279
revision_store.add_lines(key, None, osutils.split_lines(text))
2283
def _load_one_rev(self, rev_id):
2284
"""Load a revision object into memory.
2286
Any parents not either loaded or abandoned get queued to be
2288
self.pb.update('loading revision',
2289
len(self.revisions),
2290
len(self.known_revisions))
2291
if not self.branch.repository.has_revision(rev_id):
2293
ui.ui_factory.note('revision {%s} not present in branch; '
2294
'will be converted as a ghost' %
2296
self.absent_revisions.add(rev_id)
2298
rev = self.branch.repository.get_revision(rev_id)
2299
for parent_id in rev.parent_ids:
2300
self.known_revisions.add(parent_id)
2301
self.to_read.append(parent_id)
2302
self.revisions[rev_id] = rev
2304
def _load_old_inventory(self, rev_id):
2305
f = self.branch.repository.inventory_store.get(rev_id)
2307
old_inv_xml = f.read()
2310
inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
2311
inv.revision_id = rev_id
2312
rev = self.revisions[rev_id]
2315
def _load_updated_inventory(self, rev_id):
2316
inv_xml = self.inv_weave.get_text(rev_id)
2317
inv = xml5.serializer_v5.read_inventory_from_string(inv_xml, rev_id)
2320
def _convert_one_rev(self, rev_id):
2321
"""Convert revision and all referenced objects to new format."""
2322
rev = self.revisions[rev_id]
2323
inv = self._load_old_inventory(rev_id)
2324
present_parents = [p for p in rev.parent_ids
2325
if p not in self.absent_revisions]
2326
self._convert_revision_contents(rev, inv, present_parents)
2327
self._store_new_inv(rev, inv, present_parents)
2328
self.converted_revs.add(rev_id)
2330
def _store_new_inv(self, rev, inv, present_parents):
2331
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
2332
new_inv_sha1 = sha_string(new_inv_xml)
2333
self.inv_weave.add_lines(rev.revision_id,
2335
new_inv_xml.splitlines(True))
2336
rev.inventory_sha1 = new_inv_sha1
2338
def _convert_revision_contents(self, rev, inv, present_parents):
2339
"""Convert all the files within a revision.
2341
Also upgrade the inventory to refer to the text revision ids."""
2342
rev_id = rev.revision_id
2343
mutter('converting texts of revision {%s}',
2345
parent_invs = map(self._load_updated_inventory, present_parents)
2346
entries = inv.iter_entries()
2348
for path, ie in entries:
2349
self._convert_file_version(rev, ie, parent_invs)
2351
def _convert_file_version(self, rev, ie, parent_invs):
2352
"""Convert one version of one file.
2354
The file needs to be added into the weave if it is a merge
2355
of >=2 parents or if it's changed from its parent.
2357
file_id = ie.file_id
2358
rev_id = rev.revision_id
2359
w = self.text_weaves.get(file_id)
2362
self.text_weaves[file_id] = w
2363
text_changed = False
2364
parent_candiate_entries = ie.parent_candidates(parent_invs)
2365
heads = graph.Graph(self).heads(parent_candiate_entries.keys())
2366
# XXX: Note that this is unordered - and this is tolerable because
2367
# the previous code was also unordered.
2368
previous_entries = dict((head, parent_candiate_entries[head]) for head
2370
self.snapshot_ie(previous_entries, ie, w, rev_id)
2372
def get_parent_map(self, revision_ids):
2373
"""See graph.StackedParentsProvider.get_parent_map"""
2374
return dict((revision_id, self.revisions[revision_id])
2375
for revision_id in revision_ids
2376
if revision_id in self.revisions)
2378
def snapshot_ie(self, previous_revisions, ie, w, rev_id):
2379
# TODO: convert this logic, which is ~= snapshot to
2380
# a call to:. This needs the path figured out. rather than a work_tree
2381
# a v4 revision_tree can be given, or something that looks enough like
2382
# one to give the file content to the entry if it needs it.
2383
# and we need something that looks like a weave store for snapshot to
2385
#ie.snapshot(rev, PATH, previous_revisions, REVISION_TREE, InMemoryWeaveStore(self.text_weaves))
2386
if len(previous_revisions) == 1:
2387
previous_ie = previous_revisions.values()[0]
2388
if ie._unchanged(previous_ie):
2389
ie.revision = previous_ie.revision
2392
f = self.branch.repository._text_store.get(ie.text_id)
2394
file_lines = f.readlines()
2397
w.add_lines(rev_id, previous_revisions, file_lines)
2398
self.text_count += 1
2400
w.add_lines(rev_id, previous_revisions, [])
2401
ie.revision = rev_id
2403
def _make_order(self):
2404
"""Return a suitable order for importing revisions.
2406
The order must be such that an revision is imported after all
2407
its (present) parents.
2409
todo = set(self.revisions.keys())
2410
done = self.absent_revisions.copy()
2413
# scan through looking for a revision whose parents
2415
for rev_id in sorted(list(todo)):
2416
rev = self.revisions[rev_id]
2417
parent_ids = set(rev.parent_ids)
2418
if parent_ids.issubset(done):
2419
# can take this one now
2420
order.append(rev_id)
2426
class ConvertBzrDir5To6(Converter):
2427
"""Converts format 5 bzr dirs to format 6."""
2429
def convert(self, to_convert, pb):
2430
"""See Converter.convert()."""
2431
self.bzrdir = to_convert
2432
pb = ui.ui_factory.nested_progress_bar()
2434
ui.ui_factory.note('starting upgrade from format 5 to 6')
2435
self._convert_to_prefixed()
2436
return BzrDir.open(self.bzrdir.user_url)
2440
def _convert_to_prefixed(self):
2441
from bzrlib.store import TransportStore
2442
self.bzrdir.transport.delete('branch-format')
2443
for store_name in ["weaves", "revision-store"]:
2444
ui.ui_factory.note("adding prefixes to %s" % store_name)
2445
store_transport = self.bzrdir.transport.clone(store_name)
2446
store = TransportStore(store_transport, prefixed=True)
2447
for urlfilename in store_transport.list_dir('.'):
2448
filename = urlutils.unescape(urlfilename)
2449
if (filename.endswith(".weave") or
2450
filename.endswith(".gz") or
2451
filename.endswith(".sig")):
2452
file_id, suffix = os.path.splitext(filename)
2456
new_name = store._mapper.map((file_id,)) + suffix
2457
# FIXME keep track of the dirs made RBC 20060121
2459
store_transport.move(filename, new_name)
2460
except errors.NoSuchFile: # catches missing dirs strangely enough
2461
store_transport.mkdir(osutils.dirname(new_name))
2462
store_transport.move(filename, new_name)
2463
self.bzrdir.transport.put_bytes(
2465
BzrDirFormat6().get_format_string(),
2466
mode=self.bzrdir._get_file_mode())
2469
class ConvertBzrDir6ToMeta(Converter):
2470
"""Converts format 6 bzr dirs to metadirs."""
2472
def convert(self, to_convert, pb):
2473
"""See Converter.convert()."""
2474
from bzrlib.repofmt.weaverepo import RepositoryFormat7
2475
from bzrlib.branch import BzrBranchFormat5
2476
self.bzrdir = to_convert
2477
self.pb = ui.ui_factory.nested_progress_bar()
2479
self.total = 20 # the steps we know about
2480
self.garbage_inventories = []
2481
self.dir_mode = self.bzrdir._get_dir_mode()
2482
self.file_mode = self.bzrdir._get_file_mode()
2484
ui.ui_factory.note('starting upgrade from format 6 to metadir')
2485
self.bzrdir.transport.put_bytes(
2487
"Converting to format 6",
2488
mode=self.file_mode)
2489
# its faster to move specific files around than to open and use the apis...
2490
# first off, nuke ancestry.weave, it was never used.
2492
self.step('Removing ancestry.weave')
2493
self.bzrdir.transport.delete('ancestry.weave')
2494
except errors.NoSuchFile:
2496
# find out whats there
2497
self.step('Finding branch files')
2498
last_revision = self.bzrdir.open_branch().last_revision()
2499
bzrcontents = self.bzrdir.transport.list_dir('.')
2500
for name in bzrcontents:
2501
if name.startswith('basis-inventory.'):
2502
self.garbage_inventories.append(name)
2503
# create new directories for repository, working tree and branch
2504
repository_names = [('inventory.weave', True),
2505
('revision-store', True),
2507
self.step('Upgrading repository ')
2508
self.bzrdir.transport.mkdir('repository', mode=self.dir_mode)
2509
self.make_lock('repository')
2510
# we hard code the formats here because we are converting into
2511
# the meta format. The meta format upgrader can take this to a
2512
# future format within each component.
2513
self.put_format('repository', RepositoryFormat7())
2514
for entry in repository_names:
2515
self.move_entry('repository', entry)
2517
self.step('Upgrading branch ')
2518
self.bzrdir.transport.mkdir('branch', mode=self.dir_mode)
2519
self.make_lock('branch')
2520
self.put_format('branch', BzrBranchFormat5())
2521
branch_files = [('revision-history', True),
2522
('branch-name', True),
2524
for entry in branch_files:
2525
self.move_entry('branch', entry)
2527
checkout_files = [('pending-merges', True),
2528
('inventory', True),
2529
('stat-cache', False)]
2530
# If a mandatory checkout file is not present, the branch does not have
2531
# a functional checkout. Do not create a checkout in the converted
2533
for name, mandatory in checkout_files:
2534
if mandatory and name not in bzrcontents:
2535
has_checkout = False
2539
if not has_checkout:
2540
ui.ui_factory.note('No working tree.')
2541
# If some checkout files are there, we may as well get rid of them.
2542
for name, mandatory in checkout_files:
2543
if name in bzrcontents:
2544
self.bzrdir.transport.delete(name)
2546
from bzrlib.workingtree import WorkingTreeFormat3
2547
self.step('Upgrading working tree')
2548
self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
2549
self.make_lock('checkout')
2551
'checkout', WorkingTreeFormat3())
2552
self.bzrdir.transport.delete_multi(
2553
self.garbage_inventories, self.pb)
2554
for entry in checkout_files:
2555
self.move_entry('checkout', entry)
2556
if last_revision is not None:
2557
self.bzrdir.transport.put_bytes(
2558
'checkout/last-revision', last_revision)
2559
self.bzrdir.transport.put_bytes(
2561
BzrDirMetaFormat1().get_format_string(),
2562
mode=self.file_mode)
2564
return BzrDir.open(self.bzrdir.user_url)
2566
def make_lock(self, name):
2567
"""Make a lock for the new control dir name."""
2568
self.step('Make %s lock' % name)
2569
ld = lockdir.LockDir(self.bzrdir.transport,
2571
file_modebits=self.file_mode,
2572
dir_modebits=self.dir_mode)
2575
def move_entry(self, new_dir, entry):
2576
"""Move then entry name into new_dir."""
2578
mandatory = entry[1]
2579
self.step('Moving %s' % name)
2581
self.bzrdir.transport.move(name, '%s/%s' % (new_dir, name))
2582
except errors.NoSuchFile:
2586
def put_format(self, dirname, format):
2587
self.bzrdir.transport.put_bytes('%s/format' % dirname,
2588
format.get_format_string(),
2592
class ConvertMetaToMeta(Converter):
1833
2593
"""Converts the components of metadirs."""
1835
2595
def __init__(self, target_format):
1907
2668
return to_convert
2671
# This is not in remote.py because it's relatively small, and needs to be
2672
# registered. Putting it in remote.py creates a circular import problem.
2673
# we can make it a lazy object if the control formats is turned into something
2675
class RemoteBzrDirFormat(BzrDirMetaFormat1):
2676
"""Format representing bzrdirs accessed via a smart server"""
2678
supports_workingtrees = False
2681
BzrDirMetaFormat1.__init__(self)
2682
# XXX: It's a bit ugly that the network name is here, because we'd
2683
# like to believe that format objects are stateless or at least
2684
# immutable, However, we do at least avoid mutating the name after
2685
# it's returned. See <https://bugs.launchpad.net/bzr/+bug/504102>
2686
self._network_name = None
2689
return "%s(_network_name=%r)" % (self.__class__.__name__,
2692
def get_format_description(self):
2693
if self._network_name:
2694
real_format = controldir.network_format_registry.get(self._network_name)
2695
return 'Remote: ' + real_format.get_format_description()
2696
return 'bzr remote bzrdir'
2698
def get_format_string(self):
2699
raise NotImplementedError(self.get_format_string)
2701
def network_name(self):
2702
if self._network_name:
2703
return self._network_name
2705
raise AssertionError("No network name set.")
2707
def initialize_on_transport(self, transport):
2709
# hand off the request to the smart server
2710
client_medium = transport.get_smart_medium()
2711
except errors.NoSmartMedium:
2712
# TODO: lookup the local format from a server hint.
2713
local_dir_format = BzrDirMetaFormat1()
2714
return local_dir_format.initialize_on_transport(transport)
2715
client = _SmartClient(client_medium)
2716
path = client.remote_path_from_transport(transport)
2718
response = client.call('BzrDirFormat.initialize', path)
2719
except errors.ErrorFromSmartServer, err:
2720
remote._translate_error(err, path=path)
2721
if response[0] != 'ok':
2722
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2723
format = RemoteBzrDirFormat()
2724
self._supply_sub_formats_to(format)
2725
return remote.RemoteBzrDir(transport, format)
2727
def parse_NoneTrueFalse(self, arg):
2734
raise AssertionError("invalid arg %r" % arg)
2736
def _serialize_NoneTrueFalse(self, arg):
2743
def _serialize_NoneString(self, arg):
2746
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
2747
create_prefix=False, force_new_repo=False, stacked_on=None,
2748
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
2751
# hand off the request to the smart server
2752
client_medium = transport.get_smart_medium()
2753
except errors.NoSmartMedium:
2756
# Decline to open it if the server doesn't support our required
2757
# version (3) so that the VFS-based transport will do it.
2758
if client_medium.should_probe():
2760
server_version = client_medium.protocol_version()
2761
if server_version != '2':
2765
except errors.SmartProtocolError:
2766
# Apparently there's no usable smart server there, even though
2767
# the medium supports the smart protocol.
2772
client = _SmartClient(client_medium)
2773
path = client.remote_path_from_transport(transport)
2774
if client_medium._is_remote_before((1, 16)):
2777
# TODO: lookup the local format from a server hint.
2778
local_dir_format = BzrDirMetaFormat1()
2779
self._supply_sub_formats_to(local_dir_format)
2780
return local_dir_format.initialize_on_transport_ex(transport,
2781
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2782
force_new_repo=force_new_repo, stacked_on=stacked_on,
2783
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2784
make_working_trees=make_working_trees, shared_repo=shared_repo,
2786
return self._initialize_on_transport_ex_rpc(client, path, transport,
2787
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2788
stack_on_pwd, repo_format_name, make_working_trees, shared_repo)
2790
def _initialize_on_transport_ex_rpc(self, client, path, transport,
2791
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2792
stack_on_pwd, repo_format_name, make_working_trees, shared_repo):
2794
args.append(self._serialize_NoneTrueFalse(use_existing_dir))
2795
args.append(self._serialize_NoneTrueFalse(create_prefix))
2796
args.append(self._serialize_NoneTrueFalse(force_new_repo))
2797
args.append(self._serialize_NoneString(stacked_on))
2798
# stack_on_pwd is often/usually our transport
2801
stack_on_pwd = transport.relpath(stack_on_pwd)
2802
if not stack_on_pwd:
2804
except errors.PathNotChild:
2806
args.append(self._serialize_NoneString(stack_on_pwd))
2807
args.append(self._serialize_NoneString(repo_format_name))
2808
args.append(self._serialize_NoneTrueFalse(make_working_trees))
2809
args.append(self._serialize_NoneTrueFalse(shared_repo))
2810
request_network_name = self._network_name or \
2811
BzrDirFormat.get_default_format().network_name()
2813
response = client.call('BzrDirFormat.initialize_ex_1.16',
2814
request_network_name, path, *args)
2815
except errors.UnknownSmartMethod:
2816
client._medium._remember_remote_is_before((1,16))
2817
local_dir_format = BzrDirMetaFormat1()
2818
self._supply_sub_formats_to(local_dir_format)
2819
return local_dir_format.initialize_on_transport_ex(transport,
2820
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2821
force_new_repo=force_new_repo, stacked_on=stacked_on,
2822
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2823
make_working_trees=make_working_trees, shared_repo=shared_repo,
2825
except errors.ErrorFromSmartServer, err:
2826
remote._translate_error(err, path=path)
2827
repo_path = response[0]
2828
bzrdir_name = response[6]
2829
require_stacking = response[7]
2830
require_stacking = self.parse_NoneTrueFalse(require_stacking)
2831
format = RemoteBzrDirFormat()
2832
format._network_name = bzrdir_name
2833
self._supply_sub_formats_to(format)
2834
bzrdir = remote.RemoteBzrDir(transport, format, _client=client)
2836
repo_format = remote.response_tuple_to_repo_format(response[1:])
2837
if repo_path == '.':
2840
repo_bzrdir_format = RemoteBzrDirFormat()
2841
repo_bzrdir_format._network_name = response[5]
2842
repo_bzr = remote.RemoteBzrDir(transport.clone(repo_path),
2846
final_stack = response[8] or None
2847
final_stack_pwd = response[9] or None
2849
final_stack_pwd = urlutils.join(
2850
transport.base, final_stack_pwd)
2851
remote_repo = remote.RemoteRepository(repo_bzr, repo_format)
2852
if len(response) > 10:
2853
# Updated server verb that locks remotely.
2854
repo_lock_token = response[10] or None
2855
remote_repo.lock_write(repo_lock_token, _skip_rpc=True)
2857
remote_repo.dont_leave_lock_in_place()
2859
remote_repo.lock_write()
2860
policy = UseExistingRepository(remote_repo, final_stack,
2861
final_stack_pwd, require_stacking)
2862
policy.acquire_repository()
2866
bzrdir._format.set_branch_format(self.get_branch_format())
2867
if require_stacking:
2868
# The repo has already been created, but we need to make sure that
2869
# we'll make a stackable branch.
2870
bzrdir._format.require_stacking(_skip_repo=True)
2871
return remote_repo, bzrdir, require_stacking, policy
2873
def _open(self, transport):
2874
return remote.RemoteBzrDir(transport, self)
2876
def __eq__(self, other):
2877
if not isinstance(other, RemoteBzrDirFormat):
2879
return self.get_format_description() == other.get_format_description()
2881
def __return_repository_format(self):
2882
# Always return a RemoteRepositoryFormat object, but if a specific bzr
2883
# repository format has been asked for, tell the RemoteRepositoryFormat
2884
# that it should use that for init() etc.
2885
result = remote.RemoteRepositoryFormat()
2886
custom_format = getattr(self, '_repository_format', None)
2888
if isinstance(custom_format, remote.RemoteRepositoryFormat):
2889
return custom_format
2891
# We will use the custom format to create repositories over the
2892
# wire; expose its details like rich_root_data for code to
2894
result._custom_format = custom_format
2897
def get_branch_format(self):
2898
result = BzrDirMetaFormat1.get_branch_format(self)
2899
if not isinstance(result, remote.RemoteBranchFormat):
2900
new_result = remote.RemoteBranchFormat()
2901
new_result._custom_format = result
2903
self.set_branch_format(new_result)
2907
repository_format = property(__return_repository_format,
2908
BzrDirMetaFormat1._set_repository_format) #.im_func)
1910
2911
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
2150
3170
'network operations. Additionally adds support for versioning nested '
2151
3171
'bzr branches. Incompatible with bzr < 0.15.',
2152
3172
branch_format='bzrlib.branch.BzrBranchFormat6',
2153
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3173
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2154
3174
experimental=True,
2157
3177
register_metadir(controldir.format_registry, 'pack-0.92',
2158
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack1',
3178
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
2159
3179
help='New in 0.92: Pack-based format with data compatible with '
2160
3180
'dirstate-tags format repositories. Interoperates with '
2161
3181
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2163
3183
branch_format='bzrlib.branch.BzrBranchFormat6',
2164
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3184
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2166
3186
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
2167
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack3',
3187
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
2168
3188
help='New in 0.92: Pack-based format with data compatible with '
2169
3189
'dirstate-with-subtree format repositories. Interoperates with '
2170
3190
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2172
3192
branch_format='bzrlib.branch.BzrBranchFormat6',
2173
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3193
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2175
3195
experimental=True,
2177
3197
register_metadir(controldir.format_registry, 'rich-root-pack',
2178
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack4',
3198
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
2179
3199
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
2180
3200
'(needed for bzr-svn and bzr-git).',
2181
3201
branch_format='bzrlib.branch.BzrBranchFormat6',
2182
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3202
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2185
3205
register_metadir(controldir.format_registry, '1.6',
2186
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5',
3206
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
2187
3207
help='A format that allows a branch to indicate that there is another '
2188
3208
'(stacked) repository that should be used to access data that is '
2189
3209
'not present locally.',
2190
3210
branch_format='bzrlib.branch.BzrBranchFormat7',
2191
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3211
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2194
3214
register_metadir(controldir.format_registry, '1.6.1-rich-root',
2195
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5RichRoot',
3215
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
2196
3216
help='A variant of 1.6 that supports rich-root data '
2197
3217
'(needed for bzr-svn and bzr-git).',
2198
3218
branch_format='bzrlib.branch.BzrBranchFormat7',
2199
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3219
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2202
3222
register_metadir(controldir.format_registry, '1.9',
2203
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3223
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2204
3224
help='A repository format using B+tree indexes. These indexes '
2205
3225
'are smaller in size, have smarter caching and provide faster '
2206
3226
'performance for most operations.',
2207
3227
branch_format='bzrlib.branch.BzrBranchFormat7',
2208
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3228
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2211
3231
register_metadir(controldir.format_registry, '1.9-rich-root',
2212
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3232
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2213
3233
help='A variant of 1.9 that supports rich-root data '
2214
3234
'(needed for bzr-svn and bzr-git).',
2215
3235
branch_format='bzrlib.branch.BzrBranchFormat7',
2216
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3236
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2219
3239
register_metadir(controldir.format_registry, '1.14',
2220
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3240
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2221
3241
help='A working-tree format that supports content filtering.',
2222
3242
branch_format='bzrlib.branch.BzrBranchFormat7',
2223
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3243
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2225
3245
register_metadir(controldir.format_registry, '1.14-rich-root',
2226
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3246
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2227
3247
help='A variant of 1.14 that supports rich-root data '
2228
3248
'(needed for bzr-svn and bzr-git).',
2229
3249
branch_format='bzrlib.branch.BzrBranchFormat7',
2230
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3250
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2232
3252
# The following un-numbered 'development' formats should always just be aliases.
3253
register_metadir(controldir.format_registry, 'development-rich-root',
3254
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3255
help='Current development format. Supports rich roots. Can convert data '
3256
'to and from rich-root-pack (and anything compatible with '
3257
'rich-root-pack) format repositories. Repositories and branches in '
3258
'this format can only be read by bzr.dev. Please read '
3259
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3261
branch_format='bzrlib.branch.BzrBranchFormat7',
3262
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3267
register_metadir(controldir.format_registry, 'development5-subtree',
3268
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3269
help='Development format, subtree variant. Can convert data to and '
3270
'from pack-0.92-subtree (and anything compatible with '
3271
'pack-0.92-subtree) format repositories. Repositories and branches in '
3272
'this format can only be read by bzr.dev. Please read '
3273
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3275
branch_format='bzrlib.branch.BzrBranchFormat7',
3276
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
2233
3283
register_metadir(controldir.format_registry, 'development-subtree',
2234
3284
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2aSubtree',
2235
3285
help='Current development format, subtree variant. Can convert data to and '