388
430
policy = self.determine_repository_policy(force_new_repo)
389
431
return policy.acquire_repository()[0]
391
def _find_source_repo(self, add_cleanup, source_branch):
392
"""Find the source branch and repo for a sprout operation.
394
This is helper intended for use by _sprout.
396
:returns: (source_branch, source_repository). Either or both may be
397
None. If not None, they will be read-locked (and their unlock(s)
398
scheduled via the add_cleanup param).
400
if source_branch is not None:
401
add_cleanup(source_branch.lock_read().unlock)
402
return source_branch, source_branch.repository
404
source_branch = self.open_branch()
405
source_repository = source_branch.repository
406
except errors.NotBranchError:
409
source_repository = self.open_repository()
410
except errors.NoRepositoryPresent:
411
source_repository = None
413
add_cleanup(source_repository.lock_read().unlock)
415
add_cleanup(source_branch.lock_read().unlock)
416
return source_branch, source_repository
418
def sprout(self, url, revision_id=None, force_new_repo=False,
419
recurse='down', possible_transports=None,
420
accelerator_tree=None, hardlink=False, stacked=False,
421
source_branch=None, create_tree_if_local=True):
422
"""Create a copy of this controldir prepared for use as a new line of
425
If url's last component does not exist, it will be created.
427
Attributes related to the identity of the source branch like
428
branch nickname will be cleaned, a working tree is created
429
whether one existed before or not; and a local branch is always
432
if revision_id is not None, then the clone operation may tune
433
itself to download less data.
434
:param accelerator_tree: A tree which can be used for retrieving file
435
contents more quickly than the revision tree, i.e. a workingtree.
436
The revision tree will be used for cases where accelerator_tree's
437
content is different.
438
:param hardlink: If true, hard-link files from accelerator_tree,
440
:param stacked: If true, create a stacked branch referring to the
441
location of this control directory.
442
:param create_tree_if_local: If true, a working-tree will be created
443
when working locally.
445
operation = cleanup.OperationWithCleanups(self._sprout)
446
return operation.run(url, revision_id=revision_id,
447
force_new_repo=force_new_repo, recurse=recurse,
448
possible_transports=possible_transports,
449
accelerator_tree=accelerator_tree, hardlink=hardlink,
450
stacked=stacked, source_branch=source_branch,
451
create_tree_if_local=create_tree_if_local)
453
def _sprout(self, op, url, revision_id=None, force_new_repo=False,
454
recurse='down', possible_transports=None,
455
accelerator_tree=None, hardlink=False, stacked=False,
456
source_branch=None, create_tree_if_local=True):
457
add_cleanup = op.add_cleanup
458
fetch_spec_factory = fetch.FetchSpecFactory()
459
if revision_id is not None:
460
fetch_spec_factory.add_revision_ids([revision_id])
461
fetch_spec_factory.source_branch_stop_revision_id = revision_id
462
target_transport = _mod_transport.get_transport(url,
464
target_transport.ensure_base()
465
cloning_format = self.cloning_metadir(stacked)
466
# Create/update the result branch
467
result = cloning_format.initialize_on_transport(target_transport)
468
source_branch, source_repository = self._find_source_repo(
469
add_cleanup, source_branch)
470
fetch_spec_factory.source_branch = source_branch
471
# if a stacked branch wasn't requested, we don't create one
472
# even if the origin was stacked
473
if stacked and source_branch is not None:
474
stacked_branch_url = self.root_transport.base
476
stacked_branch_url = None
477
repository_policy = result.determine_repository_policy(
478
force_new_repo, stacked_branch_url, require_stacking=stacked)
479
result_repo, is_new_repo = repository_policy.acquire_repository()
480
add_cleanup(result_repo.lock_write().unlock)
481
fetch_spec_factory.source_repo = source_repository
482
fetch_spec_factory.target_repo = result_repo
483
if stacked or (len(result_repo._fallback_repositories) != 0):
484
target_repo_kind = fetch.TargetRepoKinds.STACKED
486
target_repo_kind = fetch.TargetRepoKinds.EMPTY
488
target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
489
fetch_spec_factory.target_repo_kind = target_repo_kind
490
if source_repository is not None:
491
fetch_spec = fetch_spec_factory.make_fetch_spec()
492
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
494
if source_branch is None:
495
# this is for sprouting a controldir without a branch; is that
497
# Not especially, but it's part of the contract.
498
result_branch = result.create_branch()
500
result_branch = source_branch.sprout(result,
501
revision_id=revision_id, repository_policy=repository_policy,
502
repository=result_repo)
503
mutter("created new branch %r" % (result_branch,))
505
# Create/update the result working tree
506
if (create_tree_if_local and
507
isinstance(target_transport, local.LocalTransport) and
508
(result_repo is None or result_repo.make_working_trees())):
509
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
510
hardlink=hardlink, from_branch=result_branch)
513
if wt.path2id('') is None:
515
wt.set_root_id(self.open_workingtree.get_root_id())
516
except errors.NoWorkingTree:
522
if recurse == 'down':
525
basis = wt.basis_tree()
526
elif result_branch is not None:
527
basis = result_branch.basis_tree()
528
elif source_branch is not None:
529
basis = source_branch.basis_tree()
530
if basis is not None:
531
add_cleanup(basis.lock_read().unlock)
532
subtrees = basis.iter_references()
535
for path, file_id in subtrees:
536
target = urlutils.join(url, urlutils.escape(path))
537
sublocation = source_branch.reference_parent(file_id, path)
538
sublocation.bzrdir.sprout(target,
539
basis.get_reference_revision(file_id, path),
540
force_new_repo=force_new_repo, recurse=recurse,
547
434
def create_branch_convenience(base, force_new_repo=False,
548
435
force_new_tree=None, format=None,
983
class BzrDirPreSplitOut(BzrDir):
984
"""A common class for the all-in-one formats."""
986
def __init__(self, _transport, _format):
987
"""See BzrDir.__init__."""
988
super(BzrDirPreSplitOut, self).__init__(_transport, _format)
989
self._control_files = lockable_files.LockableFiles(
990
self.get_branch_transport(None),
991
self._format._lock_file_name,
992
self._format._lock_class)
994
def break_lock(self):
995
"""Pre-splitout bzrdirs do not suffer from stale locks."""
996
raise NotImplementedError(self.break_lock)
998
def cloning_metadir(self, require_stacking=False):
999
"""Produce a metadir suitable for cloning with."""
1000
if require_stacking:
1001
return controldir.format_registry.make_bzrdir('1.6')
1002
return self._format.__class__()
1004
def clone(self, url, revision_id=None, force_new_repo=False,
1005
preserve_stacking=False):
1006
"""See BzrDir.clone().
1008
force_new_repo has no effect, since this family of formats always
1009
require a new repository.
1010
preserve_stacking has no effect, since no source branch using this
1011
family of formats can be stacked, so there is no stacking to preserve.
1013
self._make_tail(url)
1014
result = self._format._initialize_for_clone(url)
1015
self.open_repository().clone(result, revision_id=revision_id)
1016
from_branch = self.open_branch()
1017
from_branch.clone(result, revision_id=revision_id)
1019
tree = self.open_workingtree()
1020
except errors.NotLocalUrl:
1021
# make a new one, this format always has to have one.
1022
result._init_workingtree()
1027
def create_branch(self, name=None):
1028
"""See BzrDir.create_branch."""
1029
return self._format.get_branch_format().initialize(self, name=name)
1031
def destroy_branch(self, name=None):
1032
"""See BzrDir.destroy_branch."""
1033
raise errors.UnsupportedOperation(self.destroy_branch, self)
1035
def create_repository(self, shared=False):
1036
"""See BzrDir.create_repository."""
1038
raise errors.IncompatibleFormat('shared repository', self._format)
1039
return self.open_repository()
1041
def destroy_repository(self):
1042
"""See BzrDir.destroy_repository."""
1043
raise errors.UnsupportedOperation(self.destroy_repository, self)
1045
def create_workingtree(self, revision_id=None, from_branch=None,
1046
accelerator_tree=None, hardlink=False):
1047
"""See BzrDir.create_workingtree."""
1048
# The workingtree is sometimes created when the bzrdir is created,
1049
# but not when cloning.
1051
# this looks buggy but is not -really-
1052
# because this format creates the workingtree when the bzrdir is
1054
# clone and sprout will have set the revision_id
1055
# and that will have set it for us, its only
1056
# specific uses of create_workingtree in isolation
1057
# that can do wonky stuff here, and that only
1058
# happens for creating checkouts, which cannot be
1059
# done on this format anyway. So - acceptable wart.
1061
warning("can't support hardlinked working trees in %r"
1064
result = self.open_workingtree(recommend_upgrade=False)
1065
except errors.NoSuchFile:
1066
result = self._init_workingtree()
1067
if revision_id is not None:
1068
if revision_id == _mod_revision.NULL_REVISION:
1069
result.set_parent_ids([])
1071
result.set_parent_ids([revision_id])
1074
def _init_workingtree(self):
1075
from bzrlib.workingtree import WorkingTreeFormat2
1077
return WorkingTreeFormat2().initialize(self)
1078
except errors.NotLocalUrl:
1079
# Even though we can't access the working tree, we need to
1080
# create its control files.
1081
return WorkingTreeFormat2()._stub_initialize_on_transport(
1082
self.transport, self._control_files._file_mode)
1084
def destroy_workingtree(self):
1085
"""See BzrDir.destroy_workingtree."""
1086
raise errors.UnsupportedOperation(self.destroy_workingtree, self)
1088
def destroy_workingtree_metadata(self):
1089
"""See BzrDir.destroy_workingtree_metadata."""
1090
raise errors.UnsupportedOperation(self.destroy_workingtree_metadata,
1093
def get_branch_transport(self, branch_format, name=None):
1094
"""See BzrDir.get_branch_transport()."""
1095
if name is not None:
1096
raise errors.NoColocatedBranchSupport(self)
1097
if branch_format is None:
1098
return self.transport
1100
branch_format.get_format_string()
1101
except NotImplementedError:
1102
return self.transport
1103
raise errors.IncompatibleFormat(branch_format, self._format)
1105
def get_repository_transport(self, repository_format):
1106
"""See BzrDir.get_repository_transport()."""
1107
if repository_format is None:
1108
return self.transport
1110
repository_format.get_format_string()
1111
except NotImplementedError:
1112
return self.transport
1113
raise errors.IncompatibleFormat(repository_format, self._format)
1115
def get_workingtree_transport(self, workingtree_format):
1116
"""See BzrDir.get_workingtree_transport()."""
1117
if workingtree_format is None:
1118
return self.transport
1120
workingtree_format.get_format_string()
1121
except NotImplementedError:
1122
return self.transport
1123
raise errors.IncompatibleFormat(workingtree_format, self._format)
1125
def needs_format_conversion(self, format=None):
1126
"""See BzrDir.needs_format_conversion()."""
1127
# if the format is not the same as the system default,
1128
# an upgrade is needed.
1130
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1131
% 'needs_format_conversion(format=None)')
1132
format = BzrDirFormat.get_default_format()
1133
return not isinstance(self._format, format.__class__)
1135
def open_branch(self, name=None, unsupported=False,
1136
ignore_fallbacks=False):
1137
"""See BzrDir.open_branch."""
1138
from bzrlib.branch import BzrBranchFormat4
1139
format = BzrBranchFormat4()
1140
self._check_supported(format, unsupported)
1141
return format.open(self, name, _found=True)
1143
def sprout(self, url, revision_id=None, force_new_repo=False,
1144
possible_transports=None, accelerator_tree=None,
1145
hardlink=False, stacked=False, create_tree_if_local=True,
1146
source_branch=None):
1147
"""See BzrDir.sprout()."""
1148
if source_branch is not None:
1149
my_branch = self.open_branch()
1150
if source_branch.base != my_branch.base:
1151
raise AssertionError(
1152
"source branch %r is not within %r with branch %r" %
1153
(source_branch, self, my_branch))
1155
raise errors.UnstackableBranchFormat(
1156
self._format, self.root_transport.base)
1157
if not create_tree_if_local:
1158
raise errors.MustHaveWorkingTree(
1159
self._format, self.root_transport.base)
1160
from bzrlib.workingtree import WorkingTreeFormat2
1161
self._make_tail(url)
1162
result = self._format._initialize_for_clone(url)
1164
self.open_repository().clone(result, revision_id=revision_id)
1165
except errors.NoRepositoryPresent:
1168
self.open_branch().sprout(result, revision_id=revision_id)
1169
except errors.NotBranchError:
1172
# we always want a working tree
1173
WorkingTreeFormat2().initialize(result,
1174
accelerator_tree=accelerator_tree,
1179
class BzrDir4(BzrDirPreSplitOut):
1180
"""A .bzr version 4 control object.
1182
This is a deprecated format and may be removed after sept 2006.
1185
def create_repository(self, shared=False):
1186
"""See BzrDir.create_repository."""
1187
return self._format.repository_format.initialize(self, shared)
1189
def needs_format_conversion(self, format=None):
1190
"""Format 4 dirs are always in need of conversion."""
1192
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1193
% 'needs_format_conversion(format=None)')
1196
def open_repository(self):
1197
"""See BzrDir.open_repository."""
1198
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1199
return RepositoryFormat4().open(self, _found=True)
1202
class BzrDir5(BzrDirPreSplitOut):
1203
"""A .bzr version 5 control object.
1205
This is a deprecated format and may be removed after sept 2006.
1208
def has_workingtree(self):
1209
"""See BzrDir.has_workingtree."""
1212
def open_repository(self):
1213
"""See BzrDir.open_repository."""
1214
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1215
return RepositoryFormat5().open(self, _found=True)
1217
def open_workingtree(self, _unsupported=False,
1218
recommend_upgrade=True):
1219
"""See BzrDir.create_workingtree."""
1220
from bzrlib.workingtree import WorkingTreeFormat2
1221
wt_format = WorkingTreeFormat2()
1222
# we don't warn here about upgrades; that ought to be handled for the
1224
return wt_format.open(self, _found=True)
1227
class BzrDir6(BzrDirPreSplitOut):
1228
"""A .bzr version 6 control object.
1230
This is a deprecated format and may be removed after sept 2006.
1233
def has_workingtree(self):
1234
"""See BzrDir.has_workingtree."""
1237
def open_repository(self):
1238
"""See BzrDir.open_repository."""
1239
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1240
return RepositoryFormat6().open(self, _found=True)
1242
def open_workingtree(self, _unsupported=False,
1243
recommend_upgrade=True):
1244
"""See BzrDir.create_workingtree."""
1245
# we don't warn here about upgrades; that ought to be handled for the
1247
from bzrlib.workingtree import WorkingTreeFormat2
1248
return WorkingTreeFormat2().open(self, _found=True)
1133
1251
class BzrDirMeta1(BzrDir):
1134
1252
"""A .bzr meta version 1 control object.
1720
def unregister_format(klass, format):
1721
BzrProber.unregister_bzrdir_format(format)
1722
controldir.ControlDirFormat.unregister_format(format)
1723
controldir.network_format_registry.remove(format.get_format_string())
1726
class BzrDirFormat4(BzrDirFormat):
1727
"""Bzr dir format 4.
1729
This format is a combined format for working tree, branch and repository.
1731
- Format 1 working trees [always]
1732
- Format 4 branches [always]
1733
- Format 4 repositories [always]
1735
This format is deprecated: it indexes texts using a text it which is
1736
removed in format 5; write support for this format has been removed.
1739
_lock_class = lockable_files.TransportLock
1741
def get_format_string(self):
1742
"""See BzrDirFormat.get_format_string()."""
1743
return "Bazaar-NG branch, format 0.0.4\n"
1745
def get_format_description(self):
1746
"""See BzrDirFormat.get_format_description()."""
1747
return "All-in-one format 4"
1749
def get_converter(self, format=None):
1750
"""See BzrDirFormat.get_converter()."""
1751
# there is one and only one upgrade path here.
1752
return ConvertBzrDir4To5()
1754
def initialize_on_transport(self, transport):
1755
"""Format 4 branches cannot be created."""
1756
raise errors.UninitializableFormat(self)
1758
def is_supported(self):
1759
"""Format 4 is not supported.
1761
It is not supported because the model changed from 4 to 5 and the
1762
conversion logic is expensive - so doing it on the fly was not
1767
def network_name(self):
1768
return self.get_format_string()
1770
def _open(self, transport):
1771
"""See BzrDirFormat._open."""
1772
return BzrDir4(transport, self)
1774
def __return_repository_format(self):
1775
"""Circular import protection."""
1776
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1777
return RepositoryFormat4()
1778
repository_format = property(__return_repository_format)
1781
class BzrDirFormatAllInOne(BzrDirFormat):
1782
"""Common class for formats before meta-dirs."""
1784
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
1785
create_prefix=False, force_new_repo=False, stacked_on=None,
1786
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
1788
"""See BzrDirFormat.initialize_on_transport_ex."""
1789
require_stacking = (stacked_on is not None)
1790
# Format 5 cannot stack, but we've been asked to - actually init
1792
if require_stacking:
1793
format = BzrDirMetaFormat1()
1794
return format.initialize_on_transport_ex(transport,
1795
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1796
force_new_repo=force_new_repo, stacked_on=stacked_on,
1797
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1798
make_working_trees=make_working_trees, shared_repo=shared_repo)
1799
return BzrDirFormat.initialize_on_transport_ex(self, transport,
1800
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1801
force_new_repo=force_new_repo, stacked_on=stacked_on,
1802
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1803
make_working_trees=make_working_trees, shared_repo=shared_repo)
1806
class BzrDirFormat5(BzrDirFormatAllInOne):
1807
"""Bzr control format 5.
1809
This format is a combined format for working tree, branch and repository.
1811
- Format 2 working trees [always]
1812
- Format 4 branches [always]
1813
- Format 5 repositories [always]
1814
Unhashed stores in the repository.
1817
_lock_class = lockable_files.TransportLock
1819
def get_format_string(self):
1820
"""See BzrDirFormat.get_format_string()."""
1821
return "Bazaar-NG branch, format 5\n"
1823
def get_branch_format(self):
1824
from bzrlib import branch
1825
return branch.BzrBranchFormat4()
1827
def get_format_description(self):
1828
"""See BzrDirFormat.get_format_description()."""
1829
return "All-in-one format 5"
1831
def get_converter(self, format=None):
1832
"""See BzrDirFormat.get_converter()."""
1833
# there is one and only one upgrade path here.
1834
return ConvertBzrDir5To6()
1836
def _initialize_for_clone(self, url):
1837
return self.initialize_on_transport(get_transport(url), _cloning=True)
1839
def initialize_on_transport(self, transport, _cloning=False):
1840
"""Format 5 dirs always have working tree, branch and repository.
1842
Except when they are being cloned.
1844
from bzrlib.branch import BzrBranchFormat4
1845
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1846
result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
1847
RepositoryFormat5().initialize(result, _internal=True)
1849
branch = BzrBranchFormat4().initialize(result)
1850
result._init_workingtree()
1853
def network_name(self):
1854
return self.get_format_string()
1856
def _open(self, transport):
1857
"""See BzrDirFormat._open."""
1858
return BzrDir5(transport, self)
1860
def __return_repository_format(self):
1861
"""Circular import protection."""
1862
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1863
return RepositoryFormat5()
1864
repository_format = property(__return_repository_format)
1867
class BzrDirFormat6(BzrDirFormatAllInOne):
1868
"""Bzr control format 6.
1870
This format is a combined format for working tree, branch and repository.
1872
- Format 2 working trees [always]
1873
- Format 4 branches [always]
1874
- Format 6 repositories [always]
1877
_lock_class = lockable_files.TransportLock
1879
def get_format_string(self):
1880
"""See BzrDirFormat.get_format_string()."""
1881
return "Bazaar-NG branch, format 6\n"
1883
def get_format_description(self):
1884
"""See BzrDirFormat.get_format_description()."""
1885
return "All-in-one format 6"
1887
def get_branch_format(self):
1888
from bzrlib import branch
1889
return branch.BzrBranchFormat4()
1891
def get_converter(self, format=None):
1892
"""See BzrDirFormat.get_converter()."""
1893
# there is one and only one upgrade path here.
1894
return ConvertBzrDir6ToMeta()
1896
def _initialize_for_clone(self, url):
1897
return self.initialize_on_transport(get_transport(url), _cloning=True)
1899
def initialize_on_transport(self, transport, _cloning=False):
1900
"""Format 6 dirs always have working tree, branch and repository.
1902
Except when they are being cloned.
1904
from bzrlib.branch import BzrBranchFormat4
1905
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1906
result = super(BzrDirFormat6, self).initialize_on_transport(transport)
1907
RepositoryFormat6().initialize(result, _internal=True)
1909
branch = BzrBranchFormat4().initialize(result)
1910
result._init_workingtree()
1913
def network_name(self):
1914
return self.get_format_string()
1916
def _open(self, transport):
1917
"""See BzrDirFormat._open."""
1918
return BzrDir6(transport, self)
1920
def __return_repository_format(self):
1921
"""Circular import protection."""
1922
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1923
return RepositoryFormat6()
1924
repository_format = property(__return_repository_format)
1610
1927
class BzrDirMetaFormat1(BzrDirFormat):
1611
1928
"""Bzr meta control format 1
1821
2132
# Register bzr formats
1822
BzrProber.formats.register(BzrDirMetaFormat1.get_format_string(),
1824
controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()
1827
class ConvertMetaToMeta(controldir.Converter):
2133
BzrDirFormat.register_format(BzrDirFormat4())
2134
BzrDirFormat.register_format(BzrDirFormat5())
2135
BzrDirFormat.register_format(BzrDirFormat6())
2136
__default_format = BzrDirMetaFormat1()
2137
BzrDirFormat.register_format(__default_format)
2138
controldir.ControlDirFormat._default_format = __default_format
2141
class Converter(object):
2142
"""Converts a disk format object from one format to another."""
2144
def convert(self, to_convert, pb):
2145
"""Perform the conversion of to_convert, giving feedback via pb.
2147
:param to_convert: The disk object to convert.
2148
:param pb: a progress bar to use for progress information.
2151
def step(self, message):
2152
"""Update the pb by a step."""
2154
self.pb.update(message, self.count, self.total)
2157
class ConvertBzrDir4To5(Converter):
2158
"""Converts format 4 bzr dirs to format 5."""
2161
super(ConvertBzrDir4To5, self).__init__()
2162
self.converted_revs = set()
2163
self.absent_revisions = set()
2167
def convert(self, to_convert, pb):
2168
"""See Converter.convert()."""
2169
self.bzrdir = to_convert
2171
warnings.warn("pb parameter to convert() is deprecated")
2172
self.pb = ui.ui_factory.nested_progress_bar()
2174
ui.ui_factory.note('starting upgrade from format 4 to 5')
2175
if isinstance(self.bzrdir.transport, local.LocalTransport):
2176
self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2177
self._convert_to_weaves()
2178
return BzrDir.open(self.bzrdir.user_url)
2182
def _convert_to_weaves(self):
2183
ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
2186
stat = self.bzrdir.transport.stat('weaves')
2187
if not S_ISDIR(stat.st_mode):
2188
self.bzrdir.transport.delete('weaves')
2189
self.bzrdir.transport.mkdir('weaves')
2190
except errors.NoSuchFile:
2191
self.bzrdir.transport.mkdir('weaves')
2192
# deliberately not a WeaveFile as we want to build it up slowly.
2193
self.inv_weave = Weave('inventory')
2194
# holds in-memory weaves for all files
2195
self.text_weaves = {}
2196
self.bzrdir.transport.delete('branch-format')
2197
self.branch = self.bzrdir.open_branch()
2198
self._convert_working_inv()
2199
rev_history = self.branch.revision_history()
2200
# to_read is a stack holding the revisions we still need to process;
2201
# appending to it adds new highest-priority revisions
2202
self.known_revisions = set(rev_history)
2203
self.to_read = rev_history[-1:]
2205
rev_id = self.to_read.pop()
2206
if (rev_id not in self.revisions
2207
and rev_id not in self.absent_revisions):
2208
self._load_one_rev(rev_id)
2210
to_import = self._make_order()
2211
for i, rev_id in enumerate(to_import):
2212
self.pb.update('converting revision', i, len(to_import))
2213
self._convert_one_rev(rev_id)
2215
self._write_all_weaves()
2216
self._write_all_revs()
2217
ui.ui_factory.note('upgraded to weaves:')
2218
ui.ui_factory.note(' %6d revisions and inventories' % len(self.revisions))
2219
ui.ui_factory.note(' %6d revisions not present' % len(self.absent_revisions))
2220
ui.ui_factory.note(' %6d texts' % self.text_count)
2221
self._cleanup_spare_files_after_format4()
2222
self.branch._transport.put_bytes(
2224
BzrDirFormat5().get_format_string(),
2225
mode=self.bzrdir._get_file_mode())
2227
def _cleanup_spare_files_after_format4(self):
2228
# FIXME working tree upgrade foo.
2229
for n in 'merged-patches', 'pending-merged-patches':
2231
## assert os.path.getsize(p) == 0
2232
self.bzrdir.transport.delete(n)
2233
except errors.NoSuchFile:
2235
self.bzrdir.transport.delete_tree('inventory-store')
2236
self.bzrdir.transport.delete_tree('text-store')
2238
def _convert_working_inv(self):
2239
inv = xml4.serializer_v4.read_inventory(
2240
self.branch._transport.get('inventory'))
2241
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv, working=True)
2242
self.branch._transport.put_bytes('inventory', new_inv_xml,
2243
mode=self.bzrdir._get_file_mode())
2245
def _write_all_weaves(self):
2246
controlweaves = WeaveStore(self.bzrdir.transport, prefixed=False)
2247
weave_transport = self.bzrdir.transport.clone('weaves')
2248
weaves = WeaveStore(weave_transport, prefixed=False)
2249
transaction = WriteTransaction()
2253
for file_id, file_weave in self.text_weaves.items():
2254
self.pb.update('writing weave', i, len(self.text_weaves))
2255
weaves._put_weave(file_id, file_weave, transaction)
2257
self.pb.update('inventory', 0, 1)
2258
controlweaves._put_weave('inventory', self.inv_weave, transaction)
2259
self.pb.update('inventory', 1, 1)
2263
def _write_all_revs(self):
2264
"""Write all revisions out in new form."""
2265
self.bzrdir.transport.delete_tree('revision-store')
2266
self.bzrdir.transport.mkdir('revision-store')
2267
revision_transport = self.bzrdir.transport.clone('revision-store')
2269
from bzrlib.xml5 import serializer_v5
2270
from bzrlib.repofmt.weaverepo import RevisionTextStore
2271
revision_store = RevisionTextStore(revision_transport,
2272
serializer_v5, False, versionedfile.PrefixMapper(),
2273
lambda:True, lambda:True)
2275
for i, rev_id in enumerate(self.converted_revs):
2276
self.pb.update('write revision', i, len(self.converted_revs))
2277
text = serializer_v5.write_revision_to_string(
2278
self.revisions[rev_id])
2280
revision_store.add_lines(key, None, osutils.split_lines(text))
2284
def _load_one_rev(self, rev_id):
2285
"""Load a revision object into memory.
2287
Any parents not either loaded or abandoned get queued to be
2289
self.pb.update('loading revision',
2290
len(self.revisions),
2291
len(self.known_revisions))
2292
if not self.branch.repository.has_revision(rev_id):
2294
ui.ui_factory.note('revision {%s} not present in branch; '
2295
'will be converted as a ghost' %
2297
self.absent_revisions.add(rev_id)
2299
rev = self.branch.repository.get_revision(rev_id)
2300
for parent_id in rev.parent_ids:
2301
self.known_revisions.add(parent_id)
2302
self.to_read.append(parent_id)
2303
self.revisions[rev_id] = rev
2305
def _load_old_inventory(self, rev_id):
2306
f = self.branch.repository.inventory_store.get(rev_id)
2308
old_inv_xml = f.read()
2311
inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
2312
inv.revision_id = rev_id
2313
rev = self.revisions[rev_id]
2316
def _load_updated_inventory(self, rev_id):
2317
inv_xml = self.inv_weave.get_text(rev_id)
2318
inv = xml5.serializer_v5.read_inventory_from_string(inv_xml, rev_id)
2321
def _convert_one_rev(self, rev_id):
2322
"""Convert revision and all referenced objects to new format."""
2323
rev = self.revisions[rev_id]
2324
inv = self._load_old_inventory(rev_id)
2325
present_parents = [p for p in rev.parent_ids
2326
if p not in self.absent_revisions]
2327
self._convert_revision_contents(rev, inv, present_parents)
2328
self._store_new_inv(rev, inv, present_parents)
2329
self.converted_revs.add(rev_id)
2331
def _store_new_inv(self, rev, inv, present_parents):
2332
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
2333
new_inv_sha1 = sha_string(new_inv_xml)
2334
self.inv_weave.add_lines(rev.revision_id,
2336
new_inv_xml.splitlines(True))
2337
rev.inventory_sha1 = new_inv_sha1
2339
def _convert_revision_contents(self, rev, inv, present_parents):
2340
"""Convert all the files within a revision.
2342
Also upgrade the inventory to refer to the text revision ids."""
2343
rev_id = rev.revision_id
2344
mutter('converting texts of revision {%s}',
2346
parent_invs = map(self._load_updated_inventory, present_parents)
2347
entries = inv.iter_entries()
2349
for path, ie in entries:
2350
self._convert_file_version(rev, ie, parent_invs)
2352
def _convert_file_version(self, rev, ie, parent_invs):
2353
"""Convert one version of one file.
2355
The file needs to be added into the weave if it is a merge
2356
of >=2 parents or if it's changed from its parent.
2358
file_id = ie.file_id
2359
rev_id = rev.revision_id
2360
w = self.text_weaves.get(file_id)
2363
self.text_weaves[file_id] = w
2364
text_changed = False
2365
parent_candiate_entries = ie.parent_candidates(parent_invs)
2366
heads = graph.Graph(self).heads(parent_candiate_entries.keys())
2367
# XXX: Note that this is unordered - and this is tolerable because
2368
# the previous code was also unordered.
2369
previous_entries = dict((head, parent_candiate_entries[head]) for head
2371
self.snapshot_ie(previous_entries, ie, w, rev_id)
2373
def get_parent_map(self, revision_ids):
2374
"""See graph.StackedParentsProvider.get_parent_map"""
2375
return dict((revision_id, self.revisions[revision_id])
2376
for revision_id in revision_ids
2377
if revision_id in self.revisions)
2379
def snapshot_ie(self, previous_revisions, ie, w, rev_id):
2380
# TODO: convert this logic, which is ~= snapshot to
2381
# a call to:. This needs the path figured out. rather than a work_tree
2382
# a v4 revision_tree can be given, or something that looks enough like
2383
# one to give the file content to the entry if it needs it.
2384
# and we need something that looks like a weave store for snapshot to
2386
#ie.snapshot(rev, PATH, previous_revisions, REVISION_TREE, InMemoryWeaveStore(self.text_weaves))
2387
if len(previous_revisions) == 1:
2388
previous_ie = previous_revisions.values()[0]
2389
if ie._unchanged(previous_ie):
2390
ie.revision = previous_ie.revision
2393
f = self.branch.repository._text_store.get(ie.text_id)
2395
file_lines = f.readlines()
2398
w.add_lines(rev_id, previous_revisions, file_lines)
2399
self.text_count += 1
2401
w.add_lines(rev_id, previous_revisions, [])
2402
ie.revision = rev_id
2404
def _make_order(self):
2405
"""Return a suitable order for importing revisions.
2407
The order must be such that an revision is imported after all
2408
its (present) parents.
2410
todo = set(self.revisions.keys())
2411
done = self.absent_revisions.copy()
2414
# scan through looking for a revision whose parents
2416
for rev_id in sorted(list(todo)):
2417
rev = self.revisions[rev_id]
2418
parent_ids = set(rev.parent_ids)
2419
if parent_ids.issubset(done):
2420
# can take this one now
2421
order.append(rev_id)
2427
class ConvertBzrDir5To6(Converter):
2428
"""Converts format 5 bzr dirs to format 6."""
2430
def convert(self, to_convert, pb):
2431
"""See Converter.convert()."""
2432
self.bzrdir = to_convert
2433
pb = ui.ui_factory.nested_progress_bar()
2435
ui.ui_factory.note('starting upgrade from format 5 to 6')
2436
self._convert_to_prefixed()
2437
return BzrDir.open(self.bzrdir.user_url)
2441
def _convert_to_prefixed(self):
2442
from bzrlib.store import TransportStore
2443
self.bzrdir.transport.delete('branch-format')
2444
for store_name in ["weaves", "revision-store"]:
2445
ui.ui_factory.note("adding prefixes to %s" % store_name)
2446
store_transport = self.bzrdir.transport.clone(store_name)
2447
store = TransportStore(store_transport, prefixed=True)
2448
for urlfilename in store_transport.list_dir('.'):
2449
filename = urlutils.unescape(urlfilename)
2450
if (filename.endswith(".weave") or
2451
filename.endswith(".gz") or
2452
filename.endswith(".sig")):
2453
file_id, suffix = os.path.splitext(filename)
2457
new_name = store._mapper.map((file_id,)) + suffix
2458
# FIXME keep track of the dirs made RBC 20060121
2460
store_transport.move(filename, new_name)
2461
except errors.NoSuchFile: # catches missing dirs strangely enough
2462
store_transport.mkdir(osutils.dirname(new_name))
2463
store_transport.move(filename, new_name)
2464
self.bzrdir.transport.put_bytes(
2466
BzrDirFormat6().get_format_string(),
2467
mode=self.bzrdir._get_file_mode())
2470
class ConvertBzrDir6ToMeta(Converter):
2471
"""Converts format 6 bzr dirs to metadirs."""
2473
def convert(self, to_convert, pb):
2474
"""See Converter.convert()."""
2475
from bzrlib.repofmt.weaverepo import RepositoryFormat7
2476
from bzrlib.branch import BzrBranchFormat5
2477
self.bzrdir = to_convert
2478
self.pb = ui.ui_factory.nested_progress_bar()
2480
self.total = 20 # the steps we know about
2481
self.garbage_inventories = []
2482
self.dir_mode = self.bzrdir._get_dir_mode()
2483
self.file_mode = self.bzrdir._get_file_mode()
2485
ui.ui_factory.note('starting upgrade from format 6 to metadir')
2486
self.bzrdir.transport.put_bytes(
2488
"Converting to format 6",
2489
mode=self.file_mode)
2490
# its faster to move specific files around than to open and use the apis...
2491
# first off, nuke ancestry.weave, it was never used.
2493
self.step('Removing ancestry.weave')
2494
self.bzrdir.transport.delete('ancestry.weave')
2495
except errors.NoSuchFile:
2497
# find out whats there
2498
self.step('Finding branch files')
2499
last_revision = self.bzrdir.open_branch().last_revision()
2500
bzrcontents = self.bzrdir.transport.list_dir('.')
2501
for name in bzrcontents:
2502
if name.startswith('basis-inventory.'):
2503
self.garbage_inventories.append(name)
2504
# create new directories for repository, working tree and branch
2505
repository_names = [('inventory.weave', True),
2506
('revision-store', True),
2508
self.step('Upgrading repository ')
2509
self.bzrdir.transport.mkdir('repository', mode=self.dir_mode)
2510
self.make_lock('repository')
2511
# we hard code the formats here because we are converting into
2512
# the meta format. The meta format upgrader can take this to a
2513
# future format within each component.
2514
self.put_format('repository', RepositoryFormat7())
2515
for entry in repository_names:
2516
self.move_entry('repository', entry)
2518
self.step('Upgrading branch ')
2519
self.bzrdir.transport.mkdir('branch', mode=self.dir_mode)
2520
self.make_lock('branch')
2521
self.put_format('branch', BzrBranchFormat5())
2522
branch_files = [('revision-history', True),
2523
('branch-name', True),
2525
for entry in branch_files:
2526
self.move_entry('branch', entry)
2528
checkout_files = [('pending-merges', True),
2529
('inventory', True),
2530
('stat-cache', False)]
2531
# If a mandatory checkout file is not present, the branch does not have
2532
# a functional checkout. Do not create a checkout in the converted
2534
for name, mandatory in checkout_files:
2535
if mandatory and name not in bzrcontents:
2536
has_checkout = False
2540
if not has_checkout:
2541
ui.ui_factory.note('No working tree.')
2542
# If some checkout files are there, we may as well get rid of them.
2543
for name, mandatory in checkout_files:
2544
if name in bzrcontents:
2545
self.bzrdir.transport.delete(name)
2547
from bzrlib.workingtree import WorkingTreeFormat3
2548
self.step('Upgrading working tree')
2549
self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
2550
self.make_lock('checkout')
2552
'checkout', WorkingTreeFormat3())
2553
self.bzrdir.transport.delete_multi(
2554
self.garbage_inventories, self.pb)
2555
for entry in checkout_files:
2556
self.move_entry('checkout', entry)
2557
if last_revision is not None:
2558
self.bzrdir.transport.put_bytes(
2559
'checkout/last-revision', last_revision)
2560
self.bzrdir.transport.put_bytes(
2562
BzrDirMetaFormat1().get_format_string(),
2563
mode=self.file_mode)
2565
return BzrDir.open(self.bzrdir.user_url)
2567
def make_lock(self, name):
2568
"""Make a lock for the new control dir name."""
2569
self.step('Make %s lock' % name)
2570
ld = lockdir.LockDir(self.bzrdir.transport,
2572
file_modebits=self.file_mode,
2573
dir_modebits=self.dir_mode)
2576
def move_entry(self, new_dir, entry):
2577
"""Move then entry name into new_dir."""
2579
mandatory = entry[1]
2580
self.step('Moving %s' % name)
2582
self.bzrdir.transport.move(name, '%s/%s' % (new_dir, name))
2583
except errors.NoSuchFile:
2587
def put_format(self, dirname, format):
2588
self.bzrdir.transport.put_bytes('%s/format' % dirname,
2589
format.get_format_string(),
2593
class ConvertMetaToMeta(Converter):
1828
2594
"""Converts the components of metadirs."""
1830
2596
def __init__(self, target_format):
1902
2669
return to_convert
2672
# This is not in remote.py because it's relatively small, and needs to be
2673
# registered. Putting it in remote.py creates a circular import problem.
2674
# we can make it a lazy object if the control formats is turned into something
2676
class RemoteBzrDirFormat(BzrDirMetaFormat1):
2677
"""Format representing bzrdirs accessed via a smart server"""
2679
supports_workingtrees = False
2682
BzrDirMetaFormat1.__init__(self)
2683
# XXX: It's a bit ugly that the network name is here, because we'd
2684
# like to believe that format objects are stateless or at least
2685
# immutable, However, we do at least avoid mutating the name after
2686
# it's returned. See <https://bugs.launchpad.net/bzr/+bug/504102>
2687
self._network_name = None
2690
return "%s(_network_name=%r)" % (self.__class__.__name__,
2693
def get_format_description(self):
2694
if self._network_name:
2695
real_format = controldir.network_format_registry.get(self._network_name)
2696
return 'Remote: ' + real_format.get_format_description()
2697
return 'bzr remote bzrdir'
2699
def get_format_string(self):
2700
raise NotImplementedError(self.get_format_string)
2702
def network_name(self):
2703
if self._network_name:
2704
return self._network_name
2706
raise AssertionError("No network name set.")
2708
def initialize_on_transport(self, transport):
2710
# hand off the request to the smart server
2711
client_medium = transport.get_smart_medium()
2712
except errors.NoSmartMedium:
2713
# TODO: lookup the local format from a server hint.
2714
local_dir_format = BzrDirMetaFormat1()
2715
return local_dir_format.initialize_on_transport(transport)
2716
client = _SmartClient(client_medium)
2717
path = client.remote_path_from_transport(transport)
2719
response = client.call('BzrDirFormat.initialize', path)
2720
except errors.ErrorFromSmartServer, err:
2721
remote._translate_error(err, path=path)
2722
if response[0] != 'ok':
2723
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2724
format = RemoteBzrDirFormat()
2725
self._supply_sub_formats_to(format)
2726
return remote.RemoteBzrDir(transport, format)
2728
def parse_NoneTrueFalse(self, arg):
2735
raise AssertionError("invalid arg %r" % arg)
2737
def _serialize_NoneTrueFalse(self, arg):
2744
def _serialize_NoneString(self, arg):
2747
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
2748
create_prefix=False, force_new_repo=False, stacked_on=None,
2749
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
2752
# hand off the request to the smart server
2753
client_medium = transport.get_smart_medium()
2754
except errors.NoSmartMedium:
2757
# Decline to open it if the server doesn't support our required
2758
# version (3) so that the VFS-based transport will do it.
2759
if client_medium.should_probe():
2761
server_version = client_medium.protocol_version()
2762
if server_version != '2':
2766
except errors.SmartProtocolError:
2767
# Apparently there's no usable smart server there, even though
2768
# the medium supports the smart protocol.
2773
client = _SmartClient(client_medium)
2774
path = client.remote_path_from_transport(transport)
2775
if client_medium._is_remote_before((1, 16)):
2778
# TODO: lookup the local format from a server hint.
2779
local_dir_format = BzrDirMetaFormat1()
2780
self._supply_sub_formats_to(local_dir_format)
2781
return local_dir_format.initialize_on_transport_ex(transport,
2782
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2783
force_new_repo=force_new_repo, stacked_on=stacked_on,
2784
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2785
make_working_trees=make_working_trees, shared_repo=shared_repo,
2787
return self._initialize_on_transport_ex_rpc(client, path, transport,
2788
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2789
stack_on_pwd, repo_format_name, make_working_trees, shared_repo)
2791
def _initialize_on_transport_ex_rpc(self, client, path, transport,
2792
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2793
stack_on_pwd, repo_format_name, make_working_trees, shared_repo):
2795
args.append(self._serialize_NoneTrueFalse(use_existing_dir))
2796
args.append(self._serialize_NoneTrueFalse(create_prefix))
2797
args.append(self._serialize_NoneTrueFalse(force_new_repo))
2798
args.append(self._serialize_NoneString(stacked_on))
2799
# stack_on_pwd is often/usually our transport
2802
stack_on_pwd = transport.relpath(stack_on_pwd)
2803
if not stack_on_pwd:
2805
except errors.PathNotChild:
2807
args.append(self._serialize_NoneString(stack_on_pwd))
2808
args.append(self._serialize_NoneString(repo_format_name))
2809
args.append(self._serialize_NoneTrueFalse(make_working_trees))
2810
args.append(self._serialize_NoneTrueFalse(shared_repo))
2811
request_network_name = self._network_name or \
2812
BzrDirFormat.get_default_format().network_name()
2814
response = client.call('BzrDirFormat.initialize_ex_1.16',
2815
request_network_name, path, *args)
2816
except errors.UnknownSmartMethod:
2817
client._medium._remember_remote_is_before((1,16))
2818
local_dir_format = BzrDirMetaFormat1()
2819
self._supply_sub_formats_to(local_dir_format)
2820
return local_dir_format.initialize_on_transport_ex(transport,
2821
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2822
force_new_repo=force_new_repo, stacked_on=stacked_on,
2823
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2824
make_working_trees=make_working_trees, shared_repo=shared_repo,
2826
except errors.ErrorFromSmartServer, err:
2827
remote._translate_error(err, path=path)
2828
repo_path = response[0]
2829
bzrdir_name = response[6]
2830
require_stacking = response[7]
2831
require_stacking = self.parse_NoneTrueFalse(require_stacking)
2832
format = RemoteBzrDirFormat()
2833
format._network_name = bzrdir_name
2834
self._supply_sub_formats_to(format)
2835
bzrdir = remote.RemoteBzrDir(transport, format, _client=client)
2837
repo_format = remote.response_tuple_to_repo_format(response[1:])
2838
if repo_path == '.':
2841
repo_bzrdir_format = RemoteBzrDirFormat()
2842
repo_bzrdir_format._network_name = response[5]
2843
repo_bzr = remote.RemoteBzrDir(transport.clone(repo_path),
2847
final_stack = response[8] or None
2848
final_stack_pwd = response[9] or None
2850
final_stack_pwd = urlutils.join(
2851
transport.base, final_stack_pwd)
2852
remote_repo = remote.RemoteRepository(repo_bzr, repo_format)
2853
if len(response) > 10:
2854
# Updated server verb that locks remotely.
2855
repo_lock_token = response[10] or None
2856
remote_repo.lock_write(repo_lock_token, _skip_rpc=True)
2858
remote_repo.dont_leave_lock_in_place()
2860
remote_repo.lock_write()
2861
policy = UseExistingRepository(remote_repo, final_stack,
2862
final_stack_pwd, require_stacking)
2863
policy.acquire_repository()
2867
bzrdir._format.set_branch_format(self.get_branch_format())
2868
if require_stacking:
2869
# The repo has already been created, but we need to make sure that
2870
# we'll make a stackable branch.
2871
bzrdir._format.require_stacking(_skip_repo=True)
2872
return remote_repo, bzrdir, require_stacking, policy
2874
def _open(self, transport):
2875
return remote.RemoteBzrDir(transport, self)
2877
def __eq__(self, other):
2878
if not isinstance(other, RemoteBzrDirFormat):
2880
return self.get_format_description() == other.get_format_description()
2882
def __return_repository_format(self):
2883
# Always return a RemoteRepositoryFormat object, but if a specific bzr
2884
# repository format has been asked for, tell the RemoteRepositoryFormat
2885
# that it should use that for init() etc.
2886
result = remote.RemoteRepositoryFormat()
2887
custom_format = getattr(self, '_repository_format', None)
2889
if isinstance(custom_format, remote.RemoteRepositoryFormat):
2890
return custom_format
2892
# We will use the custom format to create repositories over the
2893
# wire; expose its details like rich_root_data for code to
2895
result._custom_format = custom_format
2898
def get_branch_format(self):
2899
result = BzrDirMetaFormat1.get_branch_format(self)
2900
if not isinstance(result, remote.RemoteBranchFormat):
2901
new_result = remote.RemoteBranchFormat()
2902
new_result._custom_format = result
2904
self.set_branch_format(new_result)
2908
repository_format = property(__return_repository_format,
2909
BzrDirMetaFormat1._set_repository_format) #.im_func)
1905
2912
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
2144
3168
'network operations. Additionally adds support for versioning nested '
2145
3169
'bzr branches. Incompatible with bzr < 0.15.',
2146
3170
branch_format='bzrlib.branch.BzrBranchFormat6',
2147
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3171
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2148
3172
experimental=True,
2151
3175
register_metadir(controldir.format_registry, 'pack-0.92',
2152
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack1',
3176
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
2153
3177
help='New in 0.92: Pack-based format with data compatible with '
2154
3178
'dirstate-tags format repositories. Interoperates with '
2155
3179
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2157
3181
branch_format='bzrlib.branch.BzrBranchFormat6',
2158
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3182
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2160
3184
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
2161
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack3',
3185
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
2162
3186
help='New in 0.92: Pack-based format with data compatible with '
2163
3187
'dirstate-with-subtree format repositories. Interoperates with '
2164
3188
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2166
3190
branch_format='bzrlib.branch.BzrBranchFormat6',
2167
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3191
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2169
3193
experimental=True,
2171
3195
register_metadir(controldir.format_registry, 'rich-root-pack',
2172
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack4',
3196
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
2173
3197
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
2174
3198
'(needed for bzr-svn and bzr-git).',
2175
3199
branch_format='bzrlib.branch.BzrBranchFormat6',
2176
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3200
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2179
3203
register_metadir(controldir.format_registry, '1.6',
2180
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5',
3204
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
2181
3205
help='A format that allows a branch to indicate that there is another '
2182
3206
'(stacked) repository that should be used to access data that is '
2183
3207
'not present locally.',
2184
3208
branch_format='bzrlib.branch.BzrBranchFormat7',
2185
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3209
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2188
3212
register_metadir(controldir.format_registry, '1.6.1-rich-root',
2189
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5RichRoot',
3213
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
2190
3214
help='A variant of 1.6 that supports rich-root data '
2191
3215
'(needed for bzr-svn and bzr-git).',
2192
3216
branch_format='bzrlib.branch.BzrBranchFormat7',
2193
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3217
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2196
3220
register_metadir(controldir.format_registry, '1.9',
2197
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3221
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2198
3222
help='A repository format using B+tree indexes. These indexes '
2199
3223
'are smaller in size, have smarter caching and provide faster '
2200
3224
'performance for most operations.',
2201
3225
branch_format='bzrlib.branch.BzrBranchFormat7',
2202
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3226
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2205
3229
register_metadir(controldir.format_registry, '1.9-rich-root',
2206
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3230
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2207
3231
help='A variant of 1.9 that supports rich-root data '
2208
3232
'(needed for bzr-svn and bzr-git).',
2209
3233
branch_format='bzrlib.branch.BzrBranchFormat7',
2210
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3234
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2213
3237
register_metadir(controldir.format_registry, '1.14',
2214
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3238
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2215
3239
help='A working-tree format that supports content filtering.',
2216
3240
branch_format='bzrlib.branch.BzrBranchFormat7',
2217
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3241
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2219
3243
register_metadir(controldir.format_registry, '1.14-rich-root',
2220
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3244
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2221
3245
help='A variant of 1.14 that supports rich-root data '
2222
3246
'(needed for bzr-svn and bzr-git).',
2223
3247
branch_format='bzrlib.branch.BzrBranchFormat7',
2224
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3248
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2226
3250
# The following un-numbered 'development' formats should always just be aliases.
3251
register_metadir(controldir.format_registry, 'development-rich-root',
3252
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3253
help='Current development format. Supports rich roots. Can convert data '
3254
'to and from rich-root-pack (and anything compatible with '
3255
'rich-root-pack) format repositories. Repositories and branches in '
3256
'this format can only be read by bzr.dev. Please read '
3257
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3259
branch_format='bzrlib.branch.BzrBranchFormat7',
3260
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3265
register_metadir(controldir.format_registry, 'development5-subtree',
3266
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3267
help='Development format, subtree variant. Can convert data to and '
3268
'from pack-0.92-subtree (and anything compatible with '
3269
'pack-0.92-subtree) format repositories. Repositories and branches in '
3270
'this format can only be read by bzr.dev. Please read '
3271
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3273
branch_format='bzrlib.branch.BzrBranchFormat7',
3274
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
2227
3281
register_metadir(controldir.format_registry, 'development-subtree',
2228
3282
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2aSubtree',
2229
3283
help='Current development format, subtree variant. Can convert data to and '