389
434
policy = self.determine_repository_policy(force_new_repo)
390
435
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
438
def create_branch_convenience(base, force_new_repo=False,
550
439
force_new_tree=None, format=None,
985
class BzrDirPreSplitOut(BzrDir):
986
"""A common class for the all-in-one formats."""
988
def __init__(self, _transport, _format):
989
"""See BzrDir.__init__."""
990
super(BzrDirPreSplitOut, self).__init__(_transport, _format)
991
self._control_files = lockable_files.LockableFiles(
992
self.get_branch_transport(None),
993
self._format._lock_file_name,
994
self._format._lock_class)
996
def break_lock(self):
997
"""Pre-splitout bzrdirs do not suffer from stale locks."""
998
raise NotImplementedError(self.break_lock)
1000
def cloning_metadir(self, require_stacking=False):
1001
"""Produce a metadir suitable for cloning with."""
1002
if require_stacking:
1003
return controldir.format_registry.make_bzrdir('1.6')
1004
return self._format.__class__()
1006
def clone(self, url, revision_id=None, force_new_repo=False,
1007
preserve_stacking=False):
1008
"""See BzrDir.clone().
1010
force_new_repo has no effect, since this family of formats always
1011
require a new repository.
1012
preserve_stacking has no effect, since no source branch using this
1013
family of formats can be stacked, so there is no stacking to preserve.
1015
self._make_tail(url)
1016
result = self._format._initialize_for_clone(url)
1017
self.open_repository().clone(result, revision_id=revision_id)
1018
from_branch = self.open_branch()
1019
from_branch.clone(result, revision_id=revision_id)
1021
tree = self.open_workingtree()
1022
except errors.NotLocalUrl:
1023
# make a new one, this format always has to have one.
1024
result._init_workingtree()
1029
def create_branch(self, name=None, repository=None):
1030
"""See BzrDir.create_branch."""
1031
if repository is not None:
1032
raise NotImplementedError(
1033
"create_branch(repository=<not None>) on %r" % (self,))
1034
return self._format.get_branch_format().initialize(self, name=name)
1036
def destroy_branch(self, name=None):
1037
"""See BzrDir.destroy_branch."""
1038
raise errors.UnsupportedOperation(self.destroy_branch, self)
1040
def create_repository(self, shared=False):
1041
"""See BzrDir.create_repository."""
1043
raise errors.IncompatibleFormat('shared repository', self._format)
1044
return self.open_repository()
1046
def destroy_repository(self):
1047
"""See BzrDir.destroy_repository."""
1048
raise errors.UnsupportedOperation(self.destroy_repository, self)
1050
def create_workingtree(self, revision_id=None, from_branch=None,
1051
accelerator_tree=None, hardlink=False):
1052
"""See BzrDir.create_workingtree."""
1053
# The workingtree is sometimes created when the bzrdir is created,
1054
# but not when cloning.
1056
# this looks buggy but is not -really-
1057
# because this format creates the workingtree when the bzrdir is
1059
# clone and sprout will have set the revision_id
1060
# and that will have set it for us, its only
1061
# specific uses of create_workingtree in isolation
1062
# that can do wonky stuff here, and that only
1063
# happens for creating checkouts, which cannot be
1064
# done on this format anyway. So - acceptable wart.
1066
warning("can't support hardlinked working trees in %r"
1069
result = self.open_workingtree(recommend_upgrade=False)
1070
except errors.NoSuchFile:
1071
result = self._init_workingtree()
1072
if revision_id is not None:
1073
if revision_id == _mod_revision.NULL_REVISION:
1074
result.set_parent_ids([])
1076
result.set_parent_ids([revision_id])
1079
def _init_workingtree(self):
1080
from bzrlib.workingtree import WorkingTreeFormat2
1082
return WorkingTreeFormat2().initialize(self)
1083
except errors.NotLocalUrl:
1084
# Even though we can't access the working tree, we need to
1085
# create its control files.
1086
return WorkingTreeFormat2()._stub_initialize_on_transport(
1087
self.transport, self._control_files._file_mode)
1089
def destroy_workingtree(self):
1090
"""See BzrDir.destroy_workingtree."""
1091
raise errors.UnsupportedOperation(self.destroy_workingtree, self)
1093
def destroy_workingtree_metadata(self):
1094
"""See BzrDir.destroy_workingtree_metadata."""
1095
raise errors.UnsupportedOperation(self.destroy_workingtree_metadata,
1098
def get_branch_transport(self, branch_format, name=None):
1099
"""See BzrDir.get_branch_transport()."""
1100
if name is not None:
1101
raise errors.NoColocatedBranchSupport(self)
1102
if branch_format is None:
1103
return self.transport
1105
branch_format.get_format_string()
1106
except NotImplementedError:
1107
return self.transport
1108
raise errors.IncompatibleFormat(branch_format, self._format)
1110
def get_repository_transport(self, repository_format):
1111
"""See BzrDir.get_repository_transport()."""
1112
if repository_format is None:
1113
return self.transport
1115
repository_format.get_format_string()
1116
except NotImplementedError:
1117
return self.transport
1118
raise errors.IncompatibleFormat(repository_format, self._format)
1120
def get_workingtree_transport(self, workingtree_format):
1121
"""See BzrDir.get_workingtree_transport()."""
1122
if workingtree_format is None:
1123
return self.transport
1125
workingtree_format.get_format_string()
1126
except NotImplementedError:
1127
return self.transport
1128
raise errors.IncompatibleFormat(workingtree_format, self._format)
1130
def needs_format_conversion(self, format=None):
1131
"""See BzrDir.needs_format_conversion()."""
1132
# if the format is not the same as the system default,
1133
# an upgrade is needed.
1135
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1136
% 'needs_format_conversion(format=None)')
1137
format = BzrDirFormat.get_default_format()
1138
return not isinstance(self._format, format.__class__)
1140
def open_branch(self, name=None, unsupported=False,
1141
ignore_fallbacks=False):
1142
"""See BzrDir.open_branch."""
1143
from bzrlib.branch import BzrBranchFormat4
1144
format = BzrBranchFormat4()
1145
self._check_supported(format, unsupported)
1146
return format.open(self, name, _found=True)
1148
def sprout(self, url, revision_id=None, force_new_repo=False,
1149
possible_transports=None, accelerator_tree=None,
1150
hardlink=False, stacked=False, create_tree_if_local=True,
1151
source_branch=None):
1152
"""See BzrDir.sprout()."""
1153
if source_branch is not None:
1154
my_branch = self.open_branch()
1155
if source_branch.base != my_branch.base:
1156
raise AssertionError(
1157
"source branch %r is not within %r with branch %r" %
1158
(source_branch, self, my_branch))
1160
raise errors.UnstackableBranchFormat(
1161
self._format, self.root_transport.base)
1162
if not create_tree_if_local:
1163
raise errors.MustHaveWorkingTree(
1164
self._format, self.root_transport.base)
1165
from bzrlib.workingtree import WorkingTreeFormat2
1166
self._make_tail(url)
1167
result = self._format._initialize_for_clone(url)
1169
self.open_repository().clone(result, revision_id=revision_id)
1170
except errors.NoRepositoryPresent:
1173
self.open_branch().sprout(result, revision_id=revision_id)
1174
except errors.NotBranchError:
1177
# we always want a working tree
1178
WorkingTreeFormat2().initialize(result,
1179
accelerator_tree=accelerator_tree,
1184
class BzrDir4(BzrDirPreSplitOut):
1185
"""A .bzr version 4 control object.
1187
This is a deprecated format and may be removed after sept 2006.
1190
def create_repository(self, shared=False):
1191
"""See BzrDir.create_repository."""
1192
return self._format.repository_format.initialize(self, shared)
1194
def needs_format_conversion(self, format=None):
1195
"""Format 4 dirs are always in need of conversion."""
1197
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1198
% 'needs_format_conversion(format=None)')
1201
def open_repository(self):
1202
"""See BzrDir.open_repository."""
1203
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1204
return RepositoryFormat4().open(self, _found=True)
1207
class BzrDir5(BzrDirPreSplitOut):
1208
"""A .bzr version 5 control object.
1210
This is a deprecated format and may be removed after sept 2006.
1213
def has_workingtree(self):
1214
"""See BzrDir.has_workingtree."""
1217
def open_repository(self):
1218
"""See BzrDir.open_repository."""
1219
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1220
return RepositoryFormat5().open(self, _found=True)
1222
def open_workingtree(self, _unsupported=False,
1223
recommend_upgrade=True):
1224
"""See BzrDir.create_workingtree."""
1225
from bzrlib.workingtree import WorkingTreeFormat2
1226
wt_format = WorkingTreeFormat2()
1227
# we don't warn here about upgrades; that ought to be handled for the
1229
return wt_format.open(self, _found=True)
1232
class BzrDir6(BzrDirPreSplitOut):
1233
"""A .bzr version 6 control object.
1235
This is a deprecated format and may be removed after sept 2006.
1238
def has_workingtree(self):
1239
"""See BzrDir.has_workingtree."""
1242
def open_repository(self):
1243
"""See BzrDir.open_repository."""
1244
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1245
return RepositoryFormat6().open(self, _found=True)
1247
def open_workingtree(self, _unsupported=False,
1248
recommend_upgrade=True):
1249
"""See BzrDir.create_workingtree."""
1250
# we don't warn here about upgrades; that ought to be handled for the
1252
from bzrlib.workingtree import WorkingTreeFormat2
1253
return WorkingTreeFormat2().open(self, _found=True)
1136
1256
class BzrDirMeta1(BzrDir):
1137
1257
"""A .bzr meta version 1 control object.
1729
def unregister_format(klass, format):
1730
BzrProber.unregister_bzrdir_format(format)
1731
controldir.ControlDirFormat.unregister_format(format)
1732
controldir.network_format_registry.remove(format.get_format_string())
1735
class BzrDirFormat4(BzrDirFormat):
1736
"""Bzr dir format 4.
1738
This format is a combined format for working tree, branch and repository.
1740
- Format 1 working trees [always]
1741
- Format 4 branches [always]
1742
- Format 4 repositories [always]
1744
This format is deprecated: it indexes texts using a text it which is
1745
removed in format 5; write support for this format has been removed.
1748
_lock_class = lockable_files.TransportLock
1750
def get_format_string(self):
1751
"""See BzrDirFormat.get_format_string()."""
1752
return "Bazaar-NG branch, format 0.0.4\n"
1754
def get_format_description(self):
1755
"""See BzrDirFormat.get_format_description()."""
1756
return "All-in-one format 4"
1758
def get_converter(self, format=None):
1759
"""See BzrDirFormat.get_converter()."""
1760
# there is one and only one upgrade path here.
1761
return ConvertBzrDir4To5()
1763
def initialize_on_transport(self, transport):
1764
"""Format 4 branches cannot be created."""
1765
raise errors.UninitializableFormat(self)
1767
def is_supported(self):
1768
"""Format 4 is not supported.
1770
It is not supported because the model changed from 4 to 5 and the
1771
conversion logic is expensive - so doing it on the fly was not
1776
def network_name(self):
1777
return self.get_format_string()
1779
def _open(self, transport):
1780
"""See BzrDirFormat._open."""
1781
return BzrDir4(transport, self)
1783
def __return_repository_format(self):
1784
"""Circular import protection."""
1785
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1786
return RepositoryFormat4()
1787
repository_format = property(__return_repository_format)
1790
class BzrDirFormatAllInOne(BzrDirFormat):
1791
"""Common class for formats before meta-dirs."""
1793
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
1794
create_prefix=False, force_new_repo=False, stacked_on=None,
1795
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
1797
"""See BzrDirFormat.initialize_on_transport_ex."""
1798
require_stacking = (stacked_on is not None)
1799
# Format 5 cannot stack, but we've been asked to - actually init
1801
if require_stacking:
1802
format = BzrDirMetaFormat1()
1803
return format.initialize_on_transport_ex(transport,
1804
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1805
force_new_repo=force_new_repo, stacked_on=stacked_on,
1806
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1807
make_working_trees=make_working_trees, shared_repo=shared_repo)
1808
return BzrDirFormat.initialize_on_transport_ex(self, transport,
1809
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1810
force_new_repo=force_new_repo, stacked_on=stacked_on,
1811
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1812
make_working_trees=make_working_trees, shared_repo=shared_repo)
1815
class BzrDirFormat5(BzrDirFormatAllInOne):
1816
"""Bzr control format 5.
1818
This format is a combined format for working tree, branch and repository.
1820
- Format 2 working trees [always]
1821
- Format 4 branches [always]
1822
- Format 5 repositories [always]
1823
Unhashed stores in the repository.
1826
_lock_class = lockable_files.TransportLock
1828
def get_format_string(self):
1829
"""See BzrDirFormat.get_format_string()."""
1830
return "Bazaar-NG branch, format 5\n"
1832
def get_branch_format(self):
1833
from bzrlib import branch
1834
return branch.BzrBranchFormat4()
1836
def get_format_description(self):
1837
"""See BzrDirFormat.get_format_description()."""
1838
return "All-in-one format 5"
1840
def get_converter(self, format=None):
1841
"""See BzrDirFormat.get_converter()."""
1842
# there is one and only one upgrade path here.
1843
return ConvertBzrDir5To6()
1845
def _initialize_for_clone(self, url):
1846
return self.initialize_on_transport(get_transport(url), _cloning=True)
1848
def initialize_on_transport(self, transport, _cloning=False):
1849
"""Format 5 dirs always have working tree, branch and repository.
1851
Except when they are being cloned.
1853
from bzrlib.branch import BzrBranchFormat4
1854
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1855
result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
1856
RepositoryFormat5().initialize(result, _internal=True)
1858
branch = BzrBranchFormat4().initialize(result)
1859
result._init_workingtree()
1862
def network_name(self):
1863
return self.get_format_string()
1865
def _open(self, transport):
1866
"""See BzrDirFormat._open."""
1867
return BzrDir5(transport, self)
1869
def __return_repository_format(self):
1870
"""Circular import protection."""
1871
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1872
return RepositoryFormat5()
1873
repository_format = property(__return_repository_format)
1876
class BzrDirFormat6(BzrDirFormatAllInOne):
1877
"""Bzr control format 6.
1879
This format is a combined format for working tree, branch and repository.
1881
- Format 2 working trees [always]
1882
- Format 4 branches [always]
1883
- Format 6 repositories [always]
1886
_lock_class = lockable_files.TransportLock
1888
def get_format_string(self):
1889
"""See BzrDirFormat.get_format_string()."""
1890
return "Bazaar-NG branch, format 6\n"
1892
def get_format_description(self):
1893
"""See BzrDirFormat.get_format_description()."""
1894
return "All-in-one format 6"
1896
def get_branch_format(self):
1897
from bzrlib import branch
1898
return branch.BzrBranchFormat4()
1900
def get_converter(self, format=None):
1901
"""See BzrDirFormat.get_converter()."""
1902
# there is one and only one upgrade path here.
1903
return ConvertBzrDir6ToMeta()
1905
def _initialize_for_clone(self, url):
1906
return self.initialize_on_transport(get_transport(url), _cloning=True)
1908
def initialize_on_transport(self, transport, _cloning=False):
1909
"""Format 6 dirs always have working tree, branch and repository.
1911
Except when they are being cloned.
1913
from bzrlib.branch import BzrBranchFormat4
1914
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1915
result = super(BzrDirFormat6, self).initialize_on_transport(transport)
1916
RepositoryFormat6().initialize(result, _internal=True)
1918
branch = BzrBranchFormat4().initialize(result)
1919
result._init_workingtree()
1922
def network_name(self):
1923
return self.get_format_string()
1925
def _open(self, transport):
1926
"""See BzrDirFormat._open."""
1927
return BzrDir6(transport, self)
1929
def __return_repository_format(self):
1930
"""Circular import protection."""
1931
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1932
return RepositoryFormat6()
1933
repository_format = property(__return_repository_format)
1613
1936
class BzrDirMetaFormat1(BzrDirFormat):
1614
1937
"""Bzr meta control format 1
1616
1939
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]
1942
- Format 3 working trees [optional]
1943
- Format 5 branches [optional]
1944
- Format 7 repositories [optional]
1626
1947
_lock_class = lockdir.LockDir
1628
fixed_components = False
1630
1949
def __init__(self):
1631
1950
self._workingtree_format = None
1632
1951
self._branch_format = None
1826
2141
# Register bzr formats
1827
BzrProber.formats.register(BzrDirMetaFormat1.get_format_string(),
1829
controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()
1832
class ConvertMetaToMeta(controldir.Converter):
2142
BzrDirFormat.register_format(BzrDirFormat4())
2143
BzrDirFormat.register_format(BzrDirFormat5())
2144
BzrDirFormat.register_format(BzrDirFormat6())
2145
__default_format = BzrDirMetaFormat1()
2146
BzrDirFormat.register_format(__default_format)
2147
controldir.ControlDirFormat._default_format = __default_format
2150
class Converter(object):
2151
"""Converts a disk format object from one format to another."""
2153
def convert(self, to_convert, pb):
2154
"""Perform the conversion of to_convert, giving feedback via pb.
2156
:param to_convert: The disk object to convert.
2157
:param pb: a progress bar to use for progress information.
2160
def step(self, message):
2161
"""Update the pb by a step."""
2163
self.pb.update(message, self.count, self.total)
2166
class ConvertBzrDir4To5(Converter):
2167
"""Converts format 4 bzr dirs to format 5."""
2170
super(ConvertBzrDir4To5, self).__init__()
2171
self.converted_revs = set()
2172
self.absent_revisions = set()
2176
def convert(self, to_convert, pb):
2177
"""See Converter.convert()."""
2178
self.bzrdir = to_convert
2180
warnings.warn("pb parameter to convert() is deprecated")
2181
self.pb = ui.ui_factory.nested_progress_bar()
2183
ui.ui_factory.note('starting upgrade from format 4 to 5')
2184
if isinstance(self.bzrdir.transport, local.LocalTransport):
2185
self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2186
self._convert_to_weaves()
2187
return BzrDir.open(self.bzrdir.user_url)
2191
def _convert_to_weaves(self):
2192
ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
2195
stat = self.bzrdir.transport.stat('weaves')
2196
if not S_ISDIR(stat.st_mode):
2197
self.bzrdir.transport.delete('weaves')
2198
self.bzrdir.transport.mkdir('weaves')
2199
except errors.NoSuchFile:
2200
self.bzrdir.transport.mkdir('weaves')
2201
# deliberately not a WeaveFile as we want to build it up slowly.
2202
self.inv_weave = Weave('inventory')
2203
# holds in-memory weaves for all files
2204
self.text_weaves = {}
2205
self.bzrdir.transport.delete('branch-format')
2206
self.branch = self.bzrdir.open_branch()
2207
self._convert_working_inv()
2208
rev_history = self.branch.revision_history()
2209
# to_read is a stack holding the revisions we still need to process;
2210
# appending to it adds new highest-priority revisions
2211
self.known_revisions = set(rev_history)
2212
self.to_read = rev_history[-1:]
2214
rev_id = self.to_read.pop()
2215
if (rev_id not in self.revisions
2216
and rev_id not in self.absent_revisions):
2217
self._load_one_rev(rev_id)
2219
to_import = self._make_order()
2220
for i, rev_id in enumerate(to_import):
2221
self.pb.update('converting revision', i, len(to_import))
2222
self._convert_one_rev(rev_id)
2224
self._write_all_weaves()
2225
self._write_all_revs()
2226
ui.ui_factory.note('upgraded to weaves:')
2227
ui.ui_factory.note(' %6d revisions and inventories' % len(self.revisions))
2228
ui.ui_factory.note(' %6d revisions not present' % len(self.absent_revisions))
2229
ui.ui_factory.note(' %6d texts' % self.text_count)
2230
self._cleanup_spare_files_after_format4()
2231
self.branch._transport.put_bytes(
2233
BzrDirFormat5().get_format_string(),
2234
mode=self.bzrdir._get_file_mode())
2236
def _cleanup_spare_files_after_format4(self):
2237
# FIXME working tree upgrade foo.
2238
for n in 'merged-patches', 'pending-merged-patches':
2240
## assert os.path.getsize(p) == 0
2241
self.bzrdir.transport.delete(n)
2242
except errors.NoSuchFile:
2244
self.bzrdir.transport.delete_tree('inventory-store')
2245
self.bzrdir.transport.delete_tree('text-store')
2247
def _convert_working_inv(self):
2248
inv = xml4.serializer_v4.read_inventory(
2249
self.branch._transport.get('inventory'))
2250
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv, working=True)
2251
self.branch._transport.put_bytes('inventory', new_inv_xml,
2252
mode=self.bzrdir._get_file_mode())
2254
def _write_all_weaves(self):
2255
controlweaves = WeaveStore(self.bzrdir.transport, prefixed=False)
2256
weave_transport = self.bzrdir.transport.clone('weaves')
2257
weaves = WeaveStore(weave_transport, prefixed=False)
2258
transaction = WriteTransaction()
2262
for file_id, file_weave in self.text_weaves.items():
2263
self.pb.update('writing weave', i, len(self.text_weaves))
2264
weaves._put_weave(file_id, file_weave, transaction)
2266
self.pb.update('inventory', 0, 1)
2267
controlweaves._put_weave('inventory', self.inv_weave, transaction)
2268
self.pb.update('inventory', 1, 1)
2272
def _write_all_revs(self):
2273
"""Write all revisions out in new form."""
2274
self.bzrdir.transport.delete_tree('revision-store')
2275
self.bzrdir.transport.mkdir('revision-store')
2276
revision_transport = self.bzrdir.transport.clone('revision-store')
2278
from bzrlib.xml5 import serializer_v5
2279
from bzrlib.repofmt.weaverepo import RevisionTextStore
2280
revision_store = RevisionTextStore(revision_transport,
2281
serializer_v5, False, versionedfile.PrefixMapper(),
2282
lambda:True, lambda:True)
2284
for i, rev_id in enumerate(self.converted_revs):
2285
self.pb.update('write revision', i, len(self.converted_revs))
2286
text = serializer_v5.write_revision_to_string(
2287
self.revisions[rev_id])
2289
revision_store.add_lines(key, None, osutils.split_lines(text))
2293
def _load_one_rev(self, rev_id):
2294
"""Load a revision object into memory.
2296
Any parents not either loaded or abandoned get queued to be
2298
self.pb.update('loading revision',
2299
len(self.revisions),
2300
len(self.known_revisions))
2301
if not self.branch.repository.has_revision(rev_id):
2303
ui.ui_factory.note('revision {%s} not present in branch; '
2304
'will be converted as a ghost' %
2306
self.absent_revisions.add(rev_id)
2308
rev = self.branch.repository.get_revision(rev_id)
2309
for parent_id in rev.parent_ids:
2310
self.known_revisions.add(parent_id)
2311
self.to_read.append(parent_id)
2312
self.revisions[rev_id] = rev
2314
def _load_old_inventory(self, rev_id):
2315
f = self.branch.repository.inventory_store.get(rev_id)
2317
old_inv_xml = f.read()
2320
inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
2321
inv.revision_id = rev_id
2322
rev = self.revisions[rev_id]
2325
def _load_updated_inventory(self, rev_id):
2326
inv_xml = self.inv_weave.get_text(rev_id)
2327
inv = xml5.serializer_v5.read_inventory_from_string(inv_xml, rev_id)
2330
def _convert_one_rev(self, rev_id):
2331
"""Convert revision and all referenced objects to new format."""
2332
rev = self.revisions[rev_id]
2333
inv = self._load_old_inventory(rev_id)
2334
present_parents = [p for p in rev.parent_ids
2335
if p not in self.absent_revisions]
2336
self._convert_revision_contents(rev, inv, present_parents)
2337
self._store_new_inv(rev, inv, present_parents)
2338
self.converted_revs.add(rev_id)
2340
def _store_new_inv(self, rev, inv, present_parents):
2341
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
2342
new_inv_sha1 = sha_string(new_inv_xml)
2343
self.inv_weave.add_lines(rev.revision_id,
2345
new_inv_xml.splitlines(True))
2346
rev.inventory_sha1 = new_inv_sha1
2348
def _convert_revision_contents(self, rev, inv, present_parents):
2349
"""Convert all the files within a revision.
2351
Also upgrade the inventory to refer to the text revision ids."""
2352
rev_id = rev.revision_id
2353
mutter('converting texts of revision {%s}',
2355
parent_invs = map(self._load_updated_inventory, present_parents)
2356
entries = inv.iter_entries()
2358
for path, ie in entries:
2359
self._convert_file_version(rev, ie, parent_invs)
2361
def _convert_file_version(self, rev, ie, parent_invs):
2362
"""Convert one version of one file.
2364
The file needs to be added into the weave if it is a merge
2365
of >=2 parents or if it's changed from its parent.
2367
file_id = ie.file_id
2368
rev_id = rev.revision_id
2369
w = self.text_weaves.get(file_id)
2372
self.text_weaves[file_id] = w
2373
text_changed = False
2374
parent_candiate_entries = ie.parent_candidates(parent_invs)
2375
heads = graph.Graph(self).heads(parent_candiate_entries.keys())
2376
# XXX: Note that this is unordered - and this is tolerable because
2377
# the previous code was also unordered.
2378
previous_entries = dict((head, parent_candiate_entries[head]) for head
2380
self.snapshot_ie(previous_entries, ie, w, rev_id)
2382
def get_parent_map(self, revision_ids):
2383
"""See graph.StackedParentsProvider.get_parent_map"""
2384
return dict((revision_id, self.revisions[revision_id])
2385
for revision_id in revision_ids
2386
if revision_id in self.revisions)
2388
def snapshot_ie(self, previous_revisions, ie, w, rev_id):
2389
# TODO: convert this logic, which is ~= snapshot to
2390
# a call to:. This needs the path figured out. rather than a work_tree
2391
# a v4 revision_tree can be given, or something that looks enough like
2392
# one to give the file content to the entry if it needs it.
2393
# and we need something that looks like a weave store for snapshot to
2395
#ie.snapshot(rev, PATH, previous_revisions, REVISION_TREE, InMemoryWeaveStore(self.text_weaves))
2396
if len(previous_revisions) == 1:
2397
previous_ie = previous_revisions.values()[0]
2398
if ie._unchanged(previous_ie):
2399
ie.revision = previous_ie.revision
2402
f = self.branch.repository._text_store.get(ie.text_id)
2404
file_lines = f.readlines()
2407
w.add_lines(rev_id, previous_revisions, file_lines)
2408
self.text_count += 1
2410
w.add_lines(rev_id, previous_revisions, [])
2411
ie.revision = rev_id
2413
def _make_order(self):
2414
"""Return a suitable order for importing revisions.
2416
The order must be such that an revision is imported after all
2417
its (present) parents.
2419
todo = set(self.revisions.keys())
2420
done = self.absent_revisions.copy()
2423
# scan through looking for a revision whose parents
2425
for rev_id in sorted(list(todo)):
2426
rev = self.revisions[rev_id]
2427
parent_ids = set(rev.parent_ids)
2428
if parent_ids.issubset(done):
2429
# can take this one now
2430
order.append(rev_id)
2436
class ConvertBzrDir5To6(Converter):
2437
"""Converts format 5 bzr dirs to format 6."""
2439
def convert(self, to_convert, pb):
2440
"""See Converter.convert()."""
2441
self.bzrdir = to_convert
2442
pb = ui.ui_factory.nested_progress_bar()
2444
ui.ui_factory.note('starting upgrade from format 5 to 6')
2445
self._convert_to_prefixed()
2446
return BzrDir.open(self.bzrdir.user_url)
2450
def _convert_to_prefixed(self):
2451
from bzrlib.store import TransportStore
2452
self.bzrdir.transport.delete('branch-format')
2453
for store_name in ["weaves", "revision-store"]:
2454
ui.ui_factory.note("adding prefixes to %s" % store_name)
2455
store_transport = self.bzrdir.transport.clone(store_name)
2456
store = TransportStore(store_transport, prefixed=True)
2457
for urlfilename in store_transport.list_dir('.'):
2458
filename = urlutils.unescape(urlfilename)
2459
if (filename.endswith(".weave") or
2460
filename.endswith(".gz") or
2461
filename.endswith(".sig")):
2462
file_id, suffix = os.path.splitext(filename)
2466
new_name = store._mapper.map((file_id,)) + suffix
2467
# FIXME keep track of the dirs made RBC 20060121
2469
store_transport.move(filename, new_name)
2470
except errors.NoSuchFile: # catches missing dirs strangely enough
2471
store_transport.mkdir(osutils.dirname(new_name))
2472
store_transport.move(filename, new_name)
2473
self.bzrdir.transport.put_bytes(
2475
BzrDirFormat6().get_format_string(),
2476
mode=self.bzrdir._get_file_mode())
2479
class ConvertBzrDir6ToMeta(Converter):
2480
"""Converts format 6 bzr dirs to metadirs."""
2482
def convert(self, to_convert, pb):
2483
"""See Converter.convert()."""
2484
from bzrlib.repofmt.weaverepo import RepositoryFormat7
2485
from bzrlib.branch import BzrBranchFormat5
2486
self.bzrdir = to_convert
2487
self.pb = ui.ui_factory.nested_progress_bar()
2489
self.total = 20 # the steps we know about
2490
self.garbage_inventories = []
2491
self.dir_mode = self.bzrdir._get_dir_mode()
2492
self.file_mode = self.bzrdir._get_file_mode()
2494
ui.ui_factory.note('starting upgrade from format 6 to metadir')
2495
self.bzrdir.transport.put_bytes(
2497
"Converting to format 6",
2498
mode=self.file_mode)
2499
# its faster to move specific files around than to open and use the apis...
2500
# first off, nuke ancestry.weave, it was never used.
2502
self.step('Removing ancestry.weave')
2503
self.bzrdir.transport.delete('ancestry.weave')
2504
except errors.NoSuchFile:
2506
# find out whats there
2507
self.step('Finding branch files')
2508
last_revision = self.bzrdir.open_branch().last_revision()
2509
bzrcontents = self.bzrdir.transport.list_dir('.')
2510
for name in bzrcontents:
2511
if name.startswith('basis-inventory.'):
2512
self.garbage_inventories.append(name)
2513
# create new directories for repository, working tree and branch
2514
repository_names = [('inventory.weave', True),
2515
('revision-store', True),
2517
self.step('Upgrading repository ')
2518
self.bzrdir.transport.mkdir('repository', mode=self.dir_mode)
2519
self.make_lock('repository')
2520
# we hard code the formats here because we are converting into
2521
# the meta format. The meta format upgrader can take this to a
2522
# future format within each component.
2523
self.put_format('repository', RepositoryFormat7())
2524
for entry in repository_names:
2525
self.move_entry('repository', entry)
2527
self.step('Upgrading branch ')
2528
self.bzrdir.transport.mkdir('branch', mode=self.dir_mode)
2529
self.make_lock('branch')
2530
self.put_format('branch', BzrBranchFormat5())
2531
branch_files = [('revision-history', True),
2532
('branch-name', True),
2534
for entry in branch_files:
2535
self.move_entry('branch', entry)
2537
checkout_files = [('pending-merges', True),
2538
('inventory', True),
2539
('stat-cache', False)]
2540
# If a mandatory checkout file is not present, the branch does not have
2541
# a functional checkout. Do not create a checkout in the converted
2543
for name, mandatory in checkout_files:
2544
if mandatory and name not in bzrcontents:
2545
has_checkout = False
2549
if not has_checkout:
2550
ui.ui_factory.note('No working tree.')
2551
# If some checkout files are there, we may as well get rid of them.
2552
for name, mandatory in checkout_files:
2553
if name in bzrcontents:
2554
self.bzrdir.transport.delete(name)
2556
from bzrlib.workingtree import WorkingTreeFormat3
2557
self.step('Upgrading working tree')
2558
self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
2559
self.make_lock('checkout')
2561
'checkout', WorkingTreeFormat3())
2562
self.bzrdir.transport.delete_multi(
2563
self.garbage_inventories, self.pb)
2564
for entry in checkout_files:
2565
self.move_entry('checkout', entry)
2566
if last_revision is not None:
2567
self.bzrdir.transport.put_bytes(
2568
'checkout/last-revision', last_revision)
2569
self.bzrdir.transport.put_bytes(
2571
BzrDirMetaFormat1().get_format_string(),
2572
mode=self.file_mode)
2574
return BzrDir.open(self.bzrdir.user_url)
2576
def make_lock(self, name):
2577
"""Make a lock for the new control dir name."""
2578
self.step('Make %s lock' % name)
2579
ld = lockdir.LockDir(self.bzrdir.transport,
2581
file_modebits=self.file_mode,
2582
dir_modebits=self.dir_mode)
2585
def move_entry(self, new_dir, entry):
2586
"""Move then entry name into new_dir."""
2588
mandatory = entry[1]
2589
self.step('Moving %s' % name)
2591
self.bzrdir.transport.move(name, '%s/%s' % (new_dir, name))
2592
except errors.NoSuchFile:
2596
def put_format(self, dirname, format):
2597
self.bzrdir.transport.put_bytes('%s/format' % dirname,
2598
format.get_format_string(),
2602
class ConvertMetaToMeta(Converter):
1833
2603
"""Converts the components of metadirs."""
1835
2605
def __init__(self, target_format):
1907
2678
return to_convert
2681
# This is not in remote.py because it's relatively small, and needs to be
2682
# registered. Putting it in remote.py creates a circular import problem.
2683
# we can make it a lazy object if the control formats is turned into something
2685
class RemoteBzrDirFormat(BzrDirMetaFormat1):
2686
"""Format representing bzrdirs accessed via a smart server"""
2688
supports_workingtrees = False
2691
BzrDirMetaFormat1.__init__(self)
2692
# XXX: It's a bit ugly that the network name is here, because we'd
2693
# like to believe that format objects are stateless or at least
2694
# immutable, However, we do at least avoid mutating the name after
2695
# it's returned. See <https://bugs.launchpad.net/bzr/+bug/504102>
2696
self._network_name = None
2699
return "%s(_network_name=%r)" % (self.__class__.__name__,
2702
def get_format_description(self):
2703
if self._network_name:
2704
real_format = controldir.network_format_registry.get(self._network_name)
2705
return 'Remote: ' + real_format.get_format_description()
2706
return 'bzr remote bzrdir'
2708
def get_format_string(self):
2709
raise NotImplementedError(self.get_format_string)
2711
def network_name(self):
2712
if self._network_name:
2713
return self._network_name
2715
raise AssertionError("No network name set.")
2717
def initialize_on_transport(self, transport):
2719
# hand off the request to the smart server
2720
client_medium = transport.get_smart_medium()
2721
except errors.NoSmartMedium:
2722
# TODO: lookup the local format from a server hint.
2723
local_dir_format = BzrDirMetaFormat1()
2724
return local_dir_format.initialize_on_transport(transport)
2725
client = _SmartClient(client_medium)
2726
path = client.remote_path_from_transport(transport)
2728
response = client.call('BzrDirFormat.initialize', path)
2729
except errors.ErrorFromSmartServer, err:
2730
remote._translate_error(err, path=path)
2731
if response[0] != 'ok':
2732
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2733
format = RemoteBzrDirFormat()
2734
self._supply_sub_formats_to(format)
2735
return remote.RemoteBzrDir(transport, format)
2737
def parse_NoneTrueFalse(self, arg):
2744
raise AssertionError("invalid arg %r" % arg)
2746
def _serialize_NoneTrueFalse(self, arg):
2753
def _serialize_NoneString(self, arg):
2756
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
2757
create_prefix=False, force_new_repo=False, stacked_on=None,
2758
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
2761
# hand off the request to the smart server
2762
client_medium = transport.get_smart_medium()
2763
except errors.NoSmartMedium:
2766
# Decline to open it if the server doesn't support our required
2767
# version (3) so that the VFS-based transport will do it.
2768
if client_medium.should_probe():
2770
server_version = client_medium.protocol_version()
2771
if server_version != '2':
2775
except errors.SmartProtocolError:
2776
# Apparently there's no usable smart server there, even though
2777
# the medium supports the smart protocol.
2782
client = _SmartClient(client_medium)
2783
path = client.remote_path_from_transport(transport)
2784
if client_medium._is_remote_before((1, 16)):
2787
# TODO: lookup the local format from a server hint.
2788
local_dir_format = BzrDirMetaFormat1()
2789
self._supply_sub_formats_to(local_dir_format)
2790
return local_dir_format.initialize_on_transport_ex(transport,
2791
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2792
force_new_repo=force_new_repo, stacked_on=stacked_on,
2793
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2794
make_working_trees=make_working_trees, shared_repo=shared_repo,
2796
return self._initialize_on_transport_ex_rpc(client, path, transport,
2797
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2798
stack_on_pwd, repo_format_name, make_working_trees, shared_repo)
2800
def _initialize_on_transport_ex_rpc(self, client, path, transport,
2801
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2802
stack_on_pwd, repo_format_name, make_working_trees, shared_repo):
2804
args.append(self._serialize_NoneTrueFalse(use_existing_dir))
2805
args.append(self._serialize_NoneTrueFalse(create_prefix))
2806
args.append(self._serialize_NoneTrueFalse(force_new_repo))
2807
args.append(self._serialize_NoneString(stacked_on))
2808
# stack_on_pwd is often/usually our transport
2811
stack_on_pwd = transport.relpath(stack_on_pwd)
2812
if not stack_on_pwd:
2814
except errors.PathNotChild:
2816
args.append(self._serialize_NoneString(stack_on_pwd))
2817
args.append(self._serialize_NoneString(repo_format_name))
2818
args.append(self._serialize_NoneTrueFalse(make_working_trees))
2819
args.append(self._serialize_NoneTrueFalse(shared_repo))
2820
request_network_name = self._network_name or \
2821
BzrDirFormat.get_default_format().network_name()
2823
response = client.call('BzrDirFormat.initialize_ex_1.16',
2824
request_network_name, path, *args)
2825
except errors.UnknownSmartMethod:
2826
client._medium._remember_remote_is_before((1,16))
2827
local_dir_format = BzrDirMetaFormat1()
2828
self._supply_sub_formats_to(local_dir_format)
2829
return local_dir_format.initialize_on_transport_ex(transport,
2830
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2831
force_new_repo=force_new_repo, stacked_on=stacked_on,
2832
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2833
make_working_trees=make_working_trees, shared_repo=shared_repo,
2835
except errors.ErrorFromSmartServer, err:
2836
remote._translate_error(err, path=path)
2837
repo_path = response[0]
2838
bzrdir_name = response[6]
2839
require_stacking = response[7]
2840
require_stacking = self.parse_NoneTrueFalse(require_stacking)
2841
format = RemoteBzrDirFormat()
2842
format._network_name = bzrdir_name
2843
self._supply_sub_formats_to(format)
2844
bzrdir = remote.RemoteBzrDir(transport, format, _client=client)
2846
repo_format = remote.response_tuple_to_repo_format(response[1:])
2847
if repo_path == '.':
2850
repo_bzrdir_format = RemoteBzrDirFormat()
2851
repo_bzrdir_format._network_name = response[5]
2852
repo_bzr = remote.RemoteBzrDir(transport.clone(repo_path),
2856
final_stack = response[8] or None
2857
final_stack_pwd = response[9] or None
2859
final_stack_pwd = urlutils.join(
2860
transport.base, final_stack_pwd)
2861
remote_repo = remote.RemoteRepository(repo_bzr, repo_format)
2862
if len(response) > 10:
2863
# Updated server verb that locks remotely.
2864
repo_lock_token = response[10] or None
2865
remote_repo.lock_write(repo_lock_token, _skip_rpc=True)
2867
remote_repo.dont_leave_lock_in_place()
2869
remote_repo.lock_write()
2870
policy = UseExistingRepository(remote_repo, final_stack,
2871
final_stack_pwd, require_stacking)
2872
policy.acquire_repository()
2876
bzrdir._format.set_branch_format(self.get_branch_format())
2877
if require_stacking:
2878
# The repo has already been created, but we need to make sure that
2879
# we'll make a stackable branch.
2880
bzrdir._format.require_stacking(_skip_repo=True)
2881
return remote_repo, bzrdir, require_stacking, policy
2883
def _open(self, transport):
2884
return remote.RemoteBzrDir(transport, self)
2886
def __eq__(self, other):
2887
if not isinstance(other, RemoteBzrDirFormat):
2889
return self.get_format_description() == other.get_format_description()
2891
def __return_repository_format(self):
2892
# Always return a RemoteRepositoryFormat object, but if a specific bzr
2893
# repository format has been asked for, tell the RemoteRepositoryFormat
2894
# that it should use that for init() etc.
2895
result = remote.RemoteRepositoryFormat()
2896
custom_format = getattr(self, '_repository_format', None)
2898
if isinstance(custom_format, remote.RemoteRepositoryFormat):
2899
return custom_format
2901
# We will use the custom format to create repositories over the
2902
# wire; expose its details like rich_root_data for code to
2904
result._custom_format = custom_format
2907
def get_branch_format(self):
2908
result = BzrDirMetaFormat1.get_branch_format(self)
2909
if not isinstance(result, remote.RemoteBranchFormat):
2910
new_result = remote.RemoteBranchFormat()
2911
new_result._custom_format = result
2913
self.set_branch_format(new_result)
2917
repository_format = property(__return_repository_format,
2918
BzrDirMetaFormat1._set_repository_format) #.im_func)
1910
2921
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
2150
3177
'network operations. Additionally adds support for versioning nested '
2151
3178
'bzr branches. Incompatible with bzr < 0.15.',
2152
3179
branch_format='bzrlib.branch.BzrBranchFormat6',
2153
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3180
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2154
3181
experimental=True,
2157
3184
register_metadir(controldir.format_registry, 'pack-0.92',
2158
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack1',
3185
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
2159
3186
help='New in 0.92: Pack-based format with data compatible with '
2160
3187
'dirstate-tags format repositories. Interoperates with '
2161
3188
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2163
3190
branch_format='bzrlib.branch.BzrBranchFormat6',
2164
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3191
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2166
3193
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
2167
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack3',
3194
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
2168
3195
help='New in 0.92: Pack-based format with data compatible with '
2169
3196
'dirstate-with-subtree format repositories. Interoperates with '
2170
3197
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2172
3199
branch_format='bzrlib.branch.BzrBranchFormat6',
2173
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3200
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2175
3202
experimental=True,
2177
3204
register_metadir(controldir.format_registry, 'rich-root-pack',
2178
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack4',
3205
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
2179
3206
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
2180
3207
'(needed for bzr-svn and bzr-git).',
2181
3208
branch_format='bzrlib.branch.BzrBranchFormat6',
2182
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3209
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2185
3212
register_metadir(controldir.format_registry, '1.6',
2186
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5',
3213
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
2187
3214
help='A format that allows a branch to indicate that there is another '
2188
3215
'(stacked) repository that should be used to access data that is '
2189
3216
'not present locally.',
2190
3217
branch_format='bzrlib.branch.BzrBranchFormat7',
2191
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3218
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2194
3221
register_metadir(controldir.format_registry, '1.6.1-rich-root',
2195
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5RichRoot',
3222
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
2196
3223
help='A variant of 1.6 that supports rich-root data '
2197
3224
'(needed for bzr-svn and bzr-git).',
2198
3225
branch_format='bzrlib.branch.BzrBranchFormat7',
2199
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3226
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2202
3229
register_metadir(controldir.format_registry, '1.9',
2203
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3230
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2204
3231
help='A repository format using B+tree indexes. These indexes '
2205
3232
'are smaller in size, have smarter caching and provide faster '
2206
3233
'performance for most operations.',
2207
3234
branch_format='bzrlib.branch.BzrBranchFormat7',
2208
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3235
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2211
3238
register_metadir(controldir.format_registry, '1.9-rich-root',
2212
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3239
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2213
3240
help='A variant of 1.9 that supports rich-root data '
2214
3241
'(needed for bzr-svn and bzr-git).',
2215
3242
branch_format='bzrlib.branch.BzrBranchFormat7',
2216
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3243
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2219
3246
register_metadir(controldir.format_registry, '1.14',
2220
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3247
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2221
3248
help='A working-tree format that supports content filtering.',
2222
3249
branch_format='bzrlib.branch.BzrBranchFormat7',
2223
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3250
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2225
3252
register_metadir(controldir.format_registry, '1.14-rich-root',
2226
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3253
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2227
3254
help='A variant of 1.14 that supports rich-root data '
2228
3255
'(needed for bzr-svn and bzr-git).',
2229
3256
branch_format='bzrlib.branch.BzrBranchFormat7',
2230
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3257
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2232
3259
# The following un-numbered 'development' formats should always just be aliases.
2233
3260
register_metadir(controldir.format_registry, 'development-subtree',