448
301
policy = self.determine_repository_policy(force_new_repo)
449
302
return policy.acquire_repository()[0]
452
def create_branch_convenience(base, force_new_repo=False,
453
force_new_tree=None, format=None,
454
possible_transports=None):
455
"""Create a new BzrDir, Branch and Repository at the url 'base'.
457
This is a convenience function - it will use an existing repository
458
if possible, can be told explicitly whether to create a working tree or
461
This will use the current default BzrDirFormat unless one is
462
specified, and use whatever
463
repository format that that uses via bzrdir.create_branch and
464
create_repository. If a shared repository is available that is used
465
preferentially. Whatever repository is used, its tree creation policy
468
The created Branch object is returned.
469
If a working tree cannot be made due to base not being a file:// url,
470
no error is raised unless force_new_tree is True, in which case no
471
data is created on disk and NotLocalUrl is raised.
473
:param base: The URL to create the branch at.
474
:param force_new_repo: If True a new repository is always created.
475
:param force_new_tree: If True or False force creation of a tree or
476
prevent such creation respectively.
477
:param format: Override for the bzrdir format to create.
478
:param possible_transports: An optional reusable transports list.
481
# check for non local urls
482
t = get_transport(base, possible_transports)
483
if not isinstance(t, local.LocalTransport):
484
raise errors.NotLocalUrl(base)
485
bzrdir = BzrDir.create(base, format, possible_transports)
486
repo = bzrdir._find_or_create_repository(force_new_repo)
487
result = bzrdir.create_branch()
488
if force_new_tree or (repo.make_working_trees() and
489
force_new_tree is None):
491
bzrdir.create_workingtree()
492
except errors.NotLocalUrl:
304
def _find_source_repo(self, add_cleanup, source_branch):
305
"""Find the source branch and repo for a sprout operation.
307
This is helper intended for use by _sprout.
309
:returns: (source_branch, source_repository). Either or both may be
310
None. If not None, they will be read-locked (and their unlock(s)
311
scheduled via the add_cleanup param).
313
if source_branch is not None:
314
add_cleanup(source_branch.lock_read().unlock)
315
return source_branch, source_branch.repository
317
source_branch = self.open_branch()
318
source_repository = source_branch.repository
319
except errors.NotBranchError:
322
source_repository = self.open_repository()
323
except errors.NoRepositoryPresent:
324
source_repository = None
326
add_cleanup(source_repository.lock_read().unlock)
328
add_cleanup(source_branch.lock_read().unlock)
329
return source_branch, source_repository
331
def sprout(self, url, revision_id=None, force_new_repo=False,
332
recurse='down', possible_transports=None,
333
accelerator_tree=None, hardlink=False, stacked=False,
334
source_branch=None, create_tree_if_local=True):
335
"""Create a copy of this controldir prepared for use as a new line of
338
If url's last component does not exist, it will be created.
340
Attributes related to the identity of the source branch like
341
branch nickname will be cleaned, a working tree is created
342
whether one existed before or not; and a local branch is always
345
if revision_id is not None, then the clone operation may tune
346
itself to download less data.
348
:param accelerator_tree: A tree which can be used for retrieving file
349
contents more quickly than the revision tree, i.e. a workingtree.
350
The revision tree will be used for cases where accelerator_tree's
351
content is different.
352
:param hardlink: If true, hard-link files from accelerator_tree,
354
:param stacked: If true, create a stacked branch referring to the
355
location of this control directory.
356
:param create_tree_if_local: If true, a working-tree will be created
357
when working locally.
358
:return: The created control directory
360
operation = cleanup.OperationWithCleanups(self._sprout)
361
return operation.run(url, revision_id=revision_id,
362
force_new_repo=force_new_repo, recurse=recurse,
363
possible_transports=possible_transports,
364
accelerator_tree=accelerator_tree, hardlink=hardlink,
365
stacked=stacked, source_branch=source_branch,
366
create_tree_if_local=create_tree_if_local)
368
def _sprout(self, op, url, revision_id=None, force_new_repo=False,
369
recurse='down', possible_transports=None,
370
accelerator_tree=None, hardlink=False, stacked=False,
371
source_branch=None, create_tree_if_local=True):
372
add_cleanup = op.add_cleanup
373
fetch_spec_factory = fetch.FetchSpecFactory()
374
if revision_id is not None:
375
fetch_spec_factory.add_revision_ids([revision_id])
376
fetch_spec_factory.source_branch_stop_revision_id = revision_id
377
if possible_transports is None:
378
possible_transports = []
380
possible_transports = list(possible_transports) + [
382
target_transport = _mod_transport.get_transport(url,
384
target_transport.ensure_base()
385
cloning_format = self.cloning_metadir(stacked)
386
# Create/update the result branch
388
result = controldir.ControlDir.open_from_transport(target_transport)
389
except errors.NotBranchError:
390
result = cloning_format.initialize_on_transport(target_transport)
391
source_branch, source_repository = self._find_source_repo(
392
add_cleanup, source_branch)
393
fetch_spec_factory.source_branch = source_branch
394
# if a stacked branch wasn't requested, we don't create one
395
# even if the origin was stacked
396
if stacked and source_branch is not None:
397
stacked_branch_url = self.root_transport.base
399
stacked_branch_url = None
400
repository_policy = result.determine_repository_policy(
401
force_new_repo, stacked_branch_url, require_stacking=stacked)
402
result_repo, is_new_repo = repository_policy.acquire_repository(
403
possible_transports=possible_transports)
404
add_cleanup(result_repo.lock_write().unlock)
405
fetch_spec_factory.source_repo = source_repository
406
fetch_spec_factory.target_repo = result_repo
407
if stacked or (len(result_repo._fallback_repositories) != 0):
408
target_repo_kind = fetch.TargetRepoKinds.STACKED
410
target_repo_kind = fetch.TargetRepoKinds.EMPTY
412
target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
413
fetch_spec_factory.target_repo_kind = target_repo_kind
414
if source_repository is not None:
415
fetch_spec = fetch_spec_factory.make_fetch_spec()
416
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
418
if source_branch is None:
419
# this is for sprouting a controldir without a branch; is that
421
# Not especially, but it's part of the contract.
422
result_branch = result.create_branch()
424
result_branch = source_branch.sprout(result,
425
revision_id=revision_id, repository_policy=repository_policy,
426
repository=result_repo)
427
mutter("created new branch %r" % (result_branch,))
429
# Create/update the result working tree
430
if (create_tree_if_local and not result.has_workingtree() and
431
isinstance(target_transport, local.LocalTransport) and
432
(result_repo is None or result_repo.make_working_trees())):
433
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
434
hardlink=hardlink, from_branch=result_branch)
437
if wt.path2id('') is None:
439
wt.set_root_id(self.open_workingtree.get_root_id())
440
except errors.NoWorkingTree:
446
if recurse == 'down':
449
basis = wt.basis_tree()
450
elif result_branch is not None:
451
basis = result_branch.basis_tree()
452
elif source_branch is not None:
453
basis = source_branch.basis_tree()
454
if basis is not None:
455
add_cleanup(basis.lock_read().unlock)
456
subtrees = basis.iter_references()
459
for path, file_id in subtrees:
460
target = urlutils.join(url, urlutils.escape(path))
461
sublocation = source_branch.reference_parent(file_id, path)
462
sublocation.bzrdir.sprout(target,
463
basis.get_reference_revision(file_id, path),
464
force_new_repo=force_new_repo, recurse=recurse,
497
def create_standalone_workingtree(base, format=None):
498
"""Create a new BzrDir, WorkingTree, Branch and Repository at 'base'.
500
'base' must be a local path or a file:// url.
502
This will use the current default BzrDirFormat unless one is
503
specified, and use whatever
504
repository format that that uses for bzrdirformat.create_workingtree,
505
create_branch and create_repository.
507
:param format: Override for the bzrdir format to create.
508
:return: The WorkingTree object.
510
t = get_transport(base)
511
if not isinstance(t, local.LocalTransport):
512
raise errors.NotLocalUrl(base)
513
bzrdir = BzrDir.create_branch_and_repo(base,
515
format=format).bzrdir
516
return bzrdir.create_workingtree()
468
@deprecated_method(deprecated_in((2, 3, 0)))
518
469
def generate_backup_name(self, base):
519
"""Generate a non-existing backup file name based on base."""
521
name = "%s.~%d~" % (base, counter)
522
while self.root_transport.has(name):
524
name = "%s.~%d~" % (base, counter)
470
return self._available_backup_name(base)
472
def _available_backup_name(self, base):
473
"""Find a non-existing backup file name based on base.
475
See bzrlib.osutils.available_backup_name about race conditions.
477
return osutils.available_backup_name(base, self.root_transport.has)
527
479
def backup_bzrdir(self):
528
480
"""Backup this bzr control directory.
717
667
# add new tests for it to the appropriate place.
718
668
return filename == '.bzr' or filename.startswith('.bzr/')
721
def open_unsupported(base):
722
"""Open a branch which is not supported."""
723
return BzrDir.open(base, _unsupported=True)
726
def open(base, _unsupported=False, possible_transports=None):
727
"""Open an existing bzrdir, rooted at 'base' (url).
729
:param _unsupported: a private parameter to the BzrDir class.
731
t = get_transport(base, possible_transports=possible_transports)
732
return BzrDir.open_from_transport(t, _unsupported=_unsupported)
735
def open_from_transport(transport, _unsupported=False,
736
_server_formats=True):
737
"""Open a bzrdir within a particular directory.
739
:param transport: Transport containing the bzrdir.
740
:param _unsupported: private.
742
for hook in BzrDir.hooks['pre_open']:
744
# Keep initial base since 'transport' may be modified while following
746
base = transport.base
747
def find_format(transport):
748
return transport, controldir.ControlDirFormat.find_format(
749
transport, _server_formats=_server_formats)
751
def redirected(transport, e, redirection_notice):
752
redirected_transport = transport._redirected_to(e.source, e.target)
753
if redirected_transport is None:
754
raise errors.NotBranchError(base)
755
note('%s is%s redirected to %s',
756
transport.base, e.permanently, redirected_transport.base)
757
return redirected_transport
760
transport, format = do_catching_redirections(find_format,
763
except errors.TooManyRedirections:
764
raise errors.NotBranchError(base)
766
BzrDir._check_supported(format, _unsupported)
767
return format.open(transport, _found=True)
770
def open_containing(url, possible_transports=None):
771
"""Open an existing branch which contains url.
773
:param url: url to search from.
774
See open_containing_from_transport for more detail.
776
transport = get_transport(url, possible_transports)
777
return BzrDir.open_containing_from_transport(transport)
780
def open_containing_from_transport(a_transport):
781
"""Open an existing branch which contains a_transport.base.
783
This probes for a branch at a_transport, and searches upwards from there.
785
Basically we keep looking up until we find the control directory or
786
run into the root. If there isn't one, raises NotBranchError.
787
If there is one and it is either an unrecognised format or an unsupported
788
format, UnknownFormatError or UnsupportedFormatError are raised.
789
If there is one, it is returned, along with the unused portion of url.
791
:return: The BzrDir that contains the path, and a Unicode path
792
for the rest of the URL.
794
# this gets the normalised url back. I.e. '.' -> the full path.
795
url = a_transport.base
798
result = BzrDir.open_from_transport(a_transport)
799
return result, urlutils.unescape(a_transport.relpath(url))
800
except errors.NotBranchError, e:
803
new_t = a_transport.clone('..')
804
except errors.InvalidURLJoin:
805
# reached the root, whatever that may be
806
raise errors.NotBranchError(path=url)
807
if new_t.base == a_transport.base:
808
# reached the root, whatever that may be
809
raise errors.NotBranchError(path=url)
813
def open_tree_or_branch(klass, location):
814
"""Return the branch and working tree at a location.
816
If there is no tree at the location, tree will be None.
817
If there is no branch at the location, an exception will be
819
:return: (tree, branch)
821
bzrdir = klass.open(location)
822
return bzrdir._get_tree_branch()
825
def open_containing_tree_or_branch(klass, location):
826
"""Return the branch and working tree contained by a location.
828
Returns (tree, branch, relpath).
829
If there is no tree at containing the location, tree will be None.
830
If there is no branch containing the location, an exception will be
832
relpath is the portion of the path that is contained by the branch.
834
bzrdir, relpath = klass.open_containing(location)
835
tree, branch = bzrdir._get_tree_branch()
836
return tree, branch, relpath
839
def open_containing_tree_branch_or_repository(klass, location):
840
"""Return the working tree, branch and repo contained by a location.
842
Returns (tree, branch, repository, relpath).
843
If there is no tree containing the location, tree will be None.
844
If there is no branch containing the location, branch will be None.
845
If there is no repository containing the location, repository will be
847
relpath is the portion of the path that is contained by the innermost
850
If no tree, branch or repository is found, a NotBranchError is raised.
852
bzrdir, relpath = klass.open_containing(location)
854
tree, branch = bzrdir._get_tree_branch()
855
except errors.NotBranchError:
857
repo = bzrdir.find_repository()
858
return None, None, repo, relpath
859
except (errors.NoRepositoryPresent):
860
raise errors.NotBranchError(location)
861
return tree, branch, branch.repository, relpath
863
670
def _cloning_metadir(self):
864
671
"""Produce a metadir suitable for cloning with.
933
779
can be reused to share a remote connection.
935
781
if cls is not BzrDir:
936
raise AssertionError("BzrDir.create always creates the"
782
raise AssertionError("BzrDir.create always creates the "
937
783
"default format, not one of %r" % cls)
938
t = get_transport(base, possible_transports)
941
format = controldir.ControlDirFormat.get_default_format()
942
return format.initialize_on_transport(t)
946
class BzrDirHooks(hooks.Hooks):
947
"""Hooks for BzrDir operations."""
950
"""Create the default hooks."""
951
hooks.Hooks.__init__(self)
952
self.create_hook(hooks.HookPoint('pre_open',
953
"Invoked before attempting to open a BzrDir with the transport "
954
"that the open will use.", (1, 14), None))
955
self.create_hook(hooks.HookPoint('post_repo_init',
956
"Invoked after a repository has been initialized. "
957
"post_repo_init is called with a "
958
"bzrlib.bzrdir.RepoInitHookParams.",
961
# install the default hooks
962
BzrDir.hooks = BzrDirHooks()
965
class RepoInitHookParams(object):
966
"""Object holding parameters passed to *_repo_init hooks.
968
There are 4 fields that hooks may wish to access:
970
:ivar repository: Repository created
971
:ivar format: Repository format
972
:ivar bzrdir: The bzrdir for the repository
973
:ivar shared: The repository is shared
976
def __init__(self, repository, format, a_bzrdir, shared):
977
"""Create a group of RepoInitHook parameters.
979
:param repository: Repository created
980
:param format: Repository format
981
:param bzrdir: The bzrdir for the repository
982
:param shared: The repository is shared
984
self.repository = repository
986
self.bzrdir = a_bzrdir
989
def __eq__(self, other):
990
return self.__dict__ == other.__dict__
784
return controldir.ControlDir.create(base, format=format,
785
possible_transports=possible_transports)
992
787
def __repr__(self):
994
return "<%s for %s>" % (self.__class__.__name__,
997
return "<%s for %s>" % (self.__class__.__name__,
1001
class BzrDirPreSplitOut(BzrDir):
1002
"""A common class for the all-in-one formats."""
1004
def __init__(self, _transport, _format):
1005
"""See BzrDir.__init__."""
1006
super(BzrDirPreSplitOut, self).__init__(_transport, _format)
1007
self._control_files = lockable_files.LockableFiles(
1008
self.get_branch_transport(None),
1009
self._format._lock_file_name,
1010
self._format._lock_class)
1012
def break_lock(self):
1013
"""Pre-splitout bzrdirs do not suffer from stale locks."""
1014
raise NotImplementedError(self.break_lock)
1016
def cloning_metadir(self, require_stacking=False):
1017
"""Produce a metadir suitable for cloning with."""
1018
if require_stacking:
1019
return controldir.format_registry.make_bzrdir('1.6')
1020
return self._format.__class__()
1022
def clone(self, url, revision_id=None, force_new_repo=False,
1023
preserve_stacking=False):
1024
"""See BzrDir.clone().
1026
force_new_repo has no effect, since this family of formats always
1027
require a new repository.
1028
preserve_stacking has no effect, since no source branch using this
1029
family of formats can be stacked, so there is no stacking to preserve.
788
return "<%s at %r>" % (self.__class__.__name__, self.user_url)
790
def update_feature_flags(self, updated_flags):
791
"""Update the features required by this bzrdir.
793
:param updated_flags: Dictionary mapping feature names to necessities
794
A necessity can be None to indicate the feature should be removed
1031
self._make_tail(url)
1032
result = self._format._initialize_for_clone(url)
1033
self.open_repository().clone(result, revision_id=revision_id)
1034
from_branch = self.open_branch()
1035
from_branch.clone(result, revision_id=revision_id)
1037
tree = self.open_workingtree()
1038
except errors.NotLocalUrl:
1039
# make a new one, this format always has to have one.
1040
result._init_workingtree()
1045
def create_branch(self, name=None):
1046
"""See BzrDir.create_branch."""
1047
return self._format.get_branch_format().initialize(self, name=name)
1049
def destroy_branch(self, name=None):
1050
"""See BzrDir.destroy_branch."""
1051
raise errors.UnsupportedOperation(self.destroy_branch, self)
1053
def create_repository(self, shared=False):
1054
"""See BzrDir.create_repository."""
1056
raise errors.IncompatibleFormat('shared repository', self._format)
1057
return self.open_repository()
1059
def destroy_repository(self):
1060
"""See BzrDir.destroy_repository."""
1061
raise errors.UnsupportedOperation(self.destroy_repository, self)
1063
def create_workingtree(self, revision_id=None, from_branch=None,
1064
accelerator_tree=None, hardlink=False):
1065
"""See BzrDir.create_workingtree."""
1066
# The workingtree is sometimes created when the bzrdir is created,
1067
# but not when cloning.
1069
# this looks buggy but is not -really-
1070
# because this format creates the workingtree when the bzrdir is
1072
# clone and sprout will have set the revision_id
1073
# and that will have set it for us, its only
1074
# specific uses of create_workingtree in isolation
1075
# that can do wonky stuff here, and that only
1076
# happens for creating checkouts, which cannot be
1077
# done on this format anyway. So - acceptable wart.
1079
warning("can't support hardlinked working trees in %r"
1082
result = self.open_workingtree(recommend_upgrade=False)
1083
except errors.NoSuchFile:
1084
result = self._init_workingtree()
1085
if revision_id is not None:
1086
if revision_id == _mod_revision.NULL_REVISION:
1087
result.set_parent_ids([])
1089
result.set_parent_ids([revision_id])
1092
def _init_workingtree(self):
1093
from bzrlib.workingtree import WorkingTreeFormat2
1095
return WorkingTreeFormat2().initialize(self)
1096
except errors.NotLocalUrl:
1097
# Even though we can't access the working tree, we need to
1098
# create its control files.
1099
return WorkingTreeFormat2()._stub_initialize_on_transport(
1100
self.transport, self._control_files._file_mode)
1102
def destroy_workingtree(self):
1103
"""See BzrDir.destroy_workingtree."""
1104
raise errors.UnsupportedOperation(self.destroy_workingtree, self)
1106
def destroy_workingtree_metadata(self):
1107
"""See BzrDir.destroy_workingtree_metadata."""
1108
raise errors.UnsupportedOperation(self.destroy_workingtree_metadata,
1111
def get_branch_transport(self, branch_format, name=None):
1112
"""See BzrDir.get_branch_transport()."""
1113
if name is not None:
1114
raise errors.NoColocatedBranchSupport(self)
1115
if branch_format is None:
1116
return self.transport
1118
branch_format.get_format_string()
1119
except NotImplementedError:
1120
return self.transport
1121
raise errors.IncompatibleFormat(branch_format, self._format)
1123
def get_repository_transport(self, repository_format):
1124
"""See BzrDir.get_repository_transport()."""
1125
if repository_format is None:
1126
return self.transport
1128
repository_format.get_format_string()
1129
except NotImplementedError:
1130
return self.transport
1131
raise errors.IncompatibleFormat(repository_format, self._format)
1133
def get_workingtree_transport(self, workingtree_format):
1134
"""See BzrDir.get_workingtree_transport()."""
1135
if workingtree_format is None:
1136
return self.transport
1138
workingtree_format.get_format_string()
1139
except NotImplementedError:
1140
return self.transport
1141
raise errors.IncompatibleFormat(workingtree_format, self._format)
1143
def needs_format_conversion(self, format=None):
1144
"""See BzrDir.needs_format_conversion()."""
1145
# if the format is not the same as the system default,
1146
# an upgrade is needed.
1148
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1149
% 'needs_format_conversion(format=None)')
1150
format = BzrDirFormat.get_default_format()
1151
return not isinstance(self._format, format.__class__)
1153
def open_branch(self, name=None, unsupported=False,
1154
ignore_fallbacks=False):
1155
"""See BzrDir.open_branch."""
1156
from bzrlib.branch import BzrBranchFormat4
1157
format = BzrBranchFormat4()
1158
self._check_supported(format, unsupported)
1159
return format.open(self, name, _found=True)
1161
def sprout(self, url, revision_id=None, force_new_repo=False,
1162
possible_transports=None, accelerator_tree=None,
1163
hardlink=False, stacked=False, create_tree_if_local=True,
1164
source_branch=None):
1165
"""See BzrDir.sprout()."""
1166
if source_branch is not None:
1167
my_branch = self.open_branch()
1168
if source_branch.base != my_branch.base:
1169
raise AssertionError(
1170
"source branch %r is not within %r with branch %r" %
1171
(source_branch, self, my_branch))
1173
raise errors.UnstackableBranchFormat(
1174
self._format, self.root_transport.base)
1175
if not create_tree_if_local:
1176
raise errors.MustHaveWorkingTree(
1177
self._format, self.root_transport.base)
1178
from bzrlib.workingtree import WorkingTreeFormat2
1179
self._make_tail(url)
1180
result = self._format._initialize_for_clone(url)
1182
self.open_repository().clone(result, revision_id=revision_id)
1183
except errors.NoRepositoryPresent:
1186
self.open_branch().sprout(result, revision_id=revision_id)
1187
except errors.NotBranchError:
1190
# we always want a working tree
1191
WorkingTreeFormat2().initialize(result,
1192
accelerator_tree=accelerator_tree,
1197
class BzrDir4(BzrDirPreSplitOut):
1198
"""A .bzr version 4 control object.
1200
This is a deprecated format and may be removed after sept 2006.
1203
def create_repository(self, shared=False):
1204
"""See BzrDir.create_repository."""
1205
return self._format.repository_format.initialize(self, shared)
1207
def needs_format_conversion(self, format=None):
1208
"""Format 4 dirs are always in need of conversion."""
1210
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1211
% 'needs_format_conversion(format=None)')
1214
def open_repository(self):
1215
"""See BzrDir.open_repository."""
1216
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1217
return RepositoryFormat4().open(self, _found=True)
1220
class BzrDir5(BzrDirPreSplitOut):
1221
"""A .bzr version 5 control object.
1223
This is a deprecated format and may be removed after sept 2006.
1226
def has_workingtree(self):
1227
"""See BzrDir.has_workingtree."""
1230
def open_repository(self):
1231
"""See BzrDir.open_repository."""
1232
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1233
return RepositoryFormat5().open(self, _found=True)
1235
def open_workingtree(self, _unsupported=False,
1236
recommend_upgrade=True):
1237
"""See BzrDir.create_workingtree."""
1238
from bzrlib.workingtree import WorkingTreeFormat2
1239
wt_format = WorkingTreeFormat2()
1240
# we don't warn here about upgrades; that ought to be handled for the
1242
return wt_format.open(self, _found=True)
1245
class BzrDir6(BzrDirPreSplitOut):
1246
"""A .bzr version 6 control object.
1248
This is a deprecated format and may be removed after sept 2006.
1251
def has_workingtree(self):
1252
"""See BzrDir.has_workingtree."""
1255
def open_repository(self):
1256
"""See BzrDir.open_repository."""
1257
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1258
return RepositoryFormat6().open(self, _found=True)
1260
def open_workingtree(self, _unsupported=False,
1261
recommend_upgrade=True):
1262
"""See BzrDir.create_workingtree."""
1263
# we don't warn here about upgrades; that ought to be handled for the
1265
from bzrlib.workingtree import WorkingTreeFormat2
1266
return WorkingTreeFormat2().open(self, _found=True)
796
self.control_files.lock_write()
798
self._format._update_feature_flags(updated_flags)
799
self.transport.put_bytes('branch-format', self._format.as_string())
801
self.control_files.unlock()
1269
804
class BzrDirMeta1(BzrDir):
1459
1101
return config.TransportConfig(self.transport, 'control.conf')
1104
class BzrFormat(object):
1105
"""Base class for all formats of things living in metadirs.
1107
This class manages the format string that is stored in the 'format'
1108
or 'branch-format' file.
1110
All classes for (branch-, repository-, workingtree-) formats that
1111
live in meta directories and have their own 'format' file
1112
(i.e. different from .bzr/branch-format) derive from this class,
1113
as well as the relevant base class for their kind
1114
(BranchFormat, WorkingTreeFormat, RepositoryFormat).
1116
Each format is identified by a "format" or "branch-format" file with a
1117
single line containing the base format name and then an optional list of
1120
Feature flags are supported as of bzr 2.5. Setting feature flags on formats
1121
will render them inaccessible to older versions of bzr.
1123
:ivar features: Dictionary mapping feature names to their necessity
1126
_present_features = set()
1132
def register_feature(cls, name):
1133
"""Register a feature as being present.
1135
:param name: Name of the feature
1138
raise ValueError("spaces are not allowed in feature names")
1139
if name in cls._present_features:
1140
raise errors.FeatureAlreadyRegistered(name)
1141
cls._present_features.add(name)
1144
def unregister_feature(cls, name):
1145
"""Unregister a feature."""
1146
cls._present_features.remove(name)
1148
def check_support_status(self, allow_unsupported, recommend_upgrade=True,
1150
for name, necessity in self.features.iteritems():
1151
if name in self._present_features:
1153
if necessity == "optional":
1154
mutter("ignoring optional missing feature %s", name)
1156
elif necessity == "required":
1157
raise errors.MissingFeature(name)
1159
mutter("treating unknown necessity as require for %s",
1161
raise errors.MissingFeature(name)
1164
def get_format_string(cls):
1165
"""Return the ASCII format string that identifies this format."""
1166
raise NotImplementedError(cls.get_format_string)
1169
def from_string(cls, text):
1170
format_string = cls.get_format_string()
1171
if not text.startswith(format_string):
1172
raise AssertionError("Invalid format header %r for %r" % (text, cls))
1173
lines = text[len(format_string):].splitlines()
1175
for lineno, line in enumerate(lines):
1177
(necessity, feature) = line.split(" ", 1)
1179
raise errors.ParseFormatError(format=cls, lineno=lineno+2,
1180
line=line, text=text)
1181
ret.features[feature] = necessity
1184
def as_string(self):
1185
"""Return the string representation of this format.
1187
lines = [self.get_format_string()]
1188
lines.extend([("%s %s\n" % (item[1], item[0])) for item in
1189
self.features.iteritems()])
1190
return "".join(lines)
1193
def _find_format(klass, registry, kind, format_string):
1195
first_line = format_string[:format_string.index("\n")+1]
1197
first_line = format_string
1199
cls = registry.get(first_line)
1201
raise errors.UnknownFormatError(format=first_line, kind=kind)
1202
return cls.from_string(format_string)
1204
def network_name(self):
1205
"""A simple byte string uniquely identifying this format for RPC calls.
1207
Metadir branch formats use their format string.
1209
return self.as_string()
1211
def __eq__(self, other):
1212
return (self.__class__ is other.__class__ and
1213
self.features == other.features)
1215
def _update_feature_flags(self, updated_flags):
1216
"""Update the feature flags in this format.
1218
:param updated_flags: Updated feature flags
1220
for name, necessity in updated_flags.iteritems():
1221
if necessity is None:
1223
del self.features[name]
1227
self.features[name] = necessity
1462
1230
class BzrProber(controldir.Prober):
1463
1231
"""Prober for formats that use a .bzr/ control directory."""
1233
formats = registry.FormatRegistry(controldir.network_format_registry)
1466
1234
"""The known .bzr formats."""
1237
@deprecated_method(deprecated_in((2, 4, 0)))
1469
1238
def register_bzrdir_format(klass, format):
1470
klass._formats[format.get_format_string()] = format
1239
klass.formats.register(format.get_format_string(), format)
1242
@deprecated_method(deprecated_in((2, 4, 0)))
1473
1243
def unregister_bzrdir_format(klass, format):
1474
del klass._formats[format.get_format_string()]
1244
klass.formats.remove(format.get_format_string())
1477
1247
def probe_transport(klass, transport):
1733
1517
compatible with whatever sub formats are supported by self.
1738
def unregister_format(klass, format):
1739
BzrProber.unregister_bzrdir_format(format)
1740
controldir.ControlDirFormat.unregister_format(format)
1741
network_format_registry.remove(format.get_format_string())
1744
class BzrDirFormat4(BzrDirFormat):
1745
"""Bzr dir format 4.
1747
This format is a combined format for working tree, branch and repository.
1749
- Format 1 working trees [always]
1750
- Format 4 branches [always]
1751
- Format 4 repositories [always]
1753
This format is deprecated: it indexes texts using a text it which is
1754
removed in format 5; write support for this format has been removed.
1757
_lock_class = lockable_files.TransportLock
1759
def get_format_string(self):
1760
"""See BzrDirFormat.get_format_string()."""
1761
return "Bazaar-NG branch, format 0.0.4\n"
1763
def get_format_description(self):
1764
"""See BzrDirFormat.get_format_description()."""
1765
return "All-in-one format 4"
1767
def get_converter(self, format=None):
1768
"""See BzrDirFormat.get_converter()."""
1769
# there is one and only one upgrade path here.
1770
return ConvertBzrDir4To5()
1772
def initialize_on_transport(self, transport):
1773
"""Format 4 branches cannot be created."""
1774
raise errors.UninitializableFormat(self)
1776
def is_supported(self):
1777
"""Format 4 is not supported.
1779
It is not supported because the model changed from 4 to 5 and the
1780
conversion logic is expensive - so doing it on the fly was not
1785
def network_name(self):
1786
return self.get_format_string()
1788
def _open(self, transport):
1789
"""See BzrDirFormat._open."""
1790
return BzrDir4(transport, self)
1792
def __return_repository_format(self):
1793
"""Circular import protection."""
1794
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1795
return RepositoryFormat4()
1796
repository_format = property(__return_repository_format)
1799
class BzrDirFormatAllInOne(BzrDirFormat):
1800
"""Common class for formats before meta-dirs."""
1802
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
1803
create_prefix=False, force_new_repo=False, stacked_on=None,
1804
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
1806
"""See BzrDirFormat.initialize_on_transport_ex."""
1807
require_stacking = (stacked_on is not None)
1808
# Format 5 cannot stack, but we've been asked to - actually init
1810
if require_stacking:
1811
format = BzrDirMetaFormat1()
1812
return format.initialize_on_transport_ex(transport,
1813
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1814
force_new_repo=force_new_repo, stacked_on=stacked_on,
1815
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1816
make_working_trees=make_working_trees, shared_repo=shared_repo)
1817
return BzrDirFormat.initialize_on_transport_ex(self, transport,
1818
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1819
force_new_repo=force_new_repo, stacked_on=stacked_on,
1820
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1821
make_working_trees=make_working_trees, shared_repo=shared_repo)
1824
class BzrDirFormat5(BzrDirFormatAllInOne):
1825
"""Bzr control format 5.
1827
This format is a combined format for working tree, branch and repository.
1829
- Format 2 working trees [always]
1830
- Format 4 branches [always]
1831
- Format 5 repositories [always]
1832
Unhashed stores in the repository.
1835
_lock_class = lockable_files.TransportLock
1837
def get_format_string(self):
1838
"""See BzrDirFormat.get_format_string()."""
1839
return "Bazaar-NG branch, format 5\n"
1841
def get_branch_format(self):
1842
from bzrlib import branch
1843
return branch.BzrBranchFormat4()
1845
def get_format_description(self):
1846
"""See BzrDirFormat.get_format_description()."""
1847
return "All-in-one format 5"
1849
def get_converter(self, format=None):
1850
"""See BzrDirFormat.get_converter()."""
1851
# there is one and only one upgrade path here.
1852
return ConvertBzrDir5To6()
1854
def _initialize_for_clone(self, url):
1855
return self.initialize_on_transport(get_transport(url), _cloning=True)
1857
def initialize_on_transport(self, transport, _cloning=False):
1858
"""Format 5 dirs always have working tree, branch and repository.
1860
Except when they are being cloned.
1862
from bzrlib.branch import BzrBranchFormat4
1863
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1864
result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
1865
RepositoryFormat5().initialize(result, _internal=True)
1867
branch = BzrBranchFormat4().initialize(result)
1868
result._init_workingtree()
1871
def network_name(self):
1872
return self.get_format_string()
1874
def _open(self, transport):
1875
"""See BzrDirFormat._open."""
1876
return BzrDir5(transport, self)
1878
def __return_repository_format(self):
1879
"""Circular import protection."""
1880
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1881
return RepositoryFormat5()
1882
repository_format = property(__return_repository_format)
1885
class BzrDirFormat6(BzrDirFormatAllInOne):
1886
"""Bzr control format 6.
1888
This format is a combined format for working tree, branch and repository.
1890
- Format 2 working trees [always]
1891
- Format 4 branches [always]
1892
- Format 6 repositories [always]
1895
_lock_class = lockable_files.TransportLock
1897
def get_format_string(self):
1898
"""See BzrDirFormat.get_format_string()."""
1899
return "Bazaar-NG branch, format 6\n"
1901
def get_format_description(self):
1902
"""See BzrDirFormat.get_format_description()."""
1903
return "All-in-one format 6"
1905
def get_branch_format(self):
1906
from bzrlib import branch
1907
return branch.BzrBranchFormat4()
1909
def get_converter(self, format=None):
1910
"""See BzrDirFormat.get_converter()."""
1911
# there is one and only one upgrade path here.
1912
return ConvertBzrDir6ToMeta()
1914
def _initialize_for_clone(self, url):
1915
return self.initialize_on_transport(get_transport(url), _cloning=True)
1917
def initialize_on_transport(self, transport, _cloning=False):
1918
"""Format 6 dirs always have working tree, branch and repository.
1920
Except when they are being cloned.
1922
from bzrlib.branch import BzrBranchFormat4
1923
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1924
result = super(BzrDirFormat6, self).initialize_on_transport(transport)
1925
RepositoryFormat6().initialize(result, _internal=True)
1927
branch = BzrBranchFormat4().initialize(result)
1928
result._init_workingtree()
1931
def network_name(self):
1932
return self.get_format_string()
1934
def _open(self, transport):
1935
"""See BzrDirFormat._open."""
1936
return BzrDir6(transport, self)
1938
def __return_repository_format(self):
1939
"""Circular import protection."""
1940
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1941
return RepositoryFormat6()
1942
repository_format = property(__return_repository_format)
1520
other_format.features = dict(self.features)
1522
def supports_transport(self, transport):
1523
# bzr formats can be opened over all known transports
1526
def check_support_status(self, allow_unsupported, recommend_upgrade=True,
1528
controldir.ControlDirFormat.check_support_status(self,
1529
allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
1531
BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
1532
recommend_upgrade=recommend_upgrade, basedir=basedir)
1945
1535
class BzrDirMetaFormat1(BzrDirFormat):
2137
1742
def __get_workingtree_format(self):
2138
1743
if self._workingtree_format is None:
2139
from bzrlib.workingtree import WorkingTreeFormat
2140
self._workingtree_format = WorkingTreeFormat.get_default_format()
1744
from bzrlib.workingtree import (
1745
format_registry as wt_format_registry,
1747
self._workingtree_format = wt_format_registry.get_default()
2141
1748
return self._workingtree_format
2143
1750
def __set_workingtree_format(self, wt_format):
2144
1751
self._workingtree_format = wt_format
1754
return "<%r>" % (self.__class__.__name__,)
2146
1756
workingtree_format = property(__get_workingtree_format,
2147
1757
__set_workingtree_format)
2150
network_format_registry = registry.FormatRegistry()
2151
"""Registry of formats indexed by their network name.
2153
The network name for a BzrDirFormat is an identifier that can be used when
2154
referring to formats with smart server operations. See
2155
BzrDirFormat.network_name() for more detail.
2159
1760
# Register bzr formats
2160
BzrDirFormat.register_format(BzrDirFormat4())
2161
BzrDirFormat.register_format(BzrDirFormat5())
2162
BzrDirFormat.register_format(BzrDirFormat6())
2163
__default_format = BzrDirMetaFormat1()
2164
BzrDirFormat.register_format(__default_format)
2165
controldir.ControlDirFormat._default_format = __default_format
2168
class Converter(object):
2169
"""Converts a disk format object from one format to another."""
2171
def convert(self, to_convert, pb):
2172
"""Perform the conversion of to_convert, giving feedback via pb.
2174
:param to_convert: The disk object to convert.
2175
:param pb: a progress bar to use for progress information.
2178
def step(self, message):
2179
"""Update the pb by a step."""
2181
self.pb.update(message, self.count, self.total)
2184
class ConvertBzrDir4To5(Converter):
2185
"""Converts format 4 bzr dirs to format 5."""
2188
super(ConvertBzrDir4To5, self).__init__()
2189
self.converted_revs = set()
2190
self.absent_revisions = set()
2194
def convert(self, to_convert, pb):
2195
"""See Converter.convert()."""
2196
self.bzrdir = to_convert
2198
warnings.warn("pb parameter to convert() is deprecated")
2199
self.pb = ui.ui_factory.nested_progress_bar()
2201
ui.ui_factory.note('starting upgrade from format 4 to 5')
2202
if isinstance(self.bzrdir.transport, local.LocalTransport):
2203
self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2204
self._convert_to_weaves()
2205
return BzrDir.open(self.bzrdir.user_url)
2209
def _convert_to_weaves(self):
2210
ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
2213
stat = self.bzrdir.transport.stat('weaves')
2214
if not S_ISDIR(stat.st_mode):
2215
self.bzrdir.transport.delete('weaves')
2216
self.bzrdir.transport.mkdir('weaves')
2217
except errors.NoSuchFile:
2218
self.bzrdir.transport.mkdir('weaves')
2219
# deliberately not a WeaveFile as we want to build it up slowly.
2220
self.inv_weave = Weave('inventory')
2221
# holds in-memory weaves for all files
2222
self.text_weaves = {}
2223
self.bzrdir.transport.delete('branch-format')
2224
self.branch = self.bzrdir.open_branch()
2225
self._convert_working_inv()
2226
rev_history = self.branch.revision_history()
2227
# to_read is a stack holding the revisions we still need to process;
2228
# appending to it adds new highest-priority revisions
2229
self.known_revisions = set(rev_history)
2230
self.to_read = rev_history[-1:]
2232
rev_id = self.to_read.pop()
2233
if (rev_id not in self.revisions
2234
and rev_id not in self.absent_revisions):
2235
self._load_one_rev(rev_id)
2237
to_import = self._make_order()
2238
for i, rev_id in enumerate(to_import):
2239
self.pb.update('converting revision', i, len(to_import))
2240
self._convert_one_rev(rev_id)
2242
self._write_all_weaves()
2243
self._write_all_revs()
2244
ui.ui_factory.note('upgraded to weaves:')
2245
ui.ui_factory.note(' %6d revisions and inventories' % len(self.revisions))
2246
ui.ui_factory.note(' %6d revisions not present' % len(self.absent_revisions))
2247
ui.ui_factory.note(' %6d texts' % self.text_count)
2248
self._cleanup_spare_files_after_format4()
2249
self.branch._transport.put_bytes(
2251
BzrDirFormat5().get_format_string(),
2252
mode=self.bzrdir._get_file_mode())
2254
def _cleanup_spare_files_after_format4(self):
2255
# FIXME working tree upgrade foo.
2256
for n in 'merged-patches', 'pending-merged-patches':
2258
## assert os.path.getsize(p) == 0
2259
self.bzrdir.transport.delete(n)
2260
except errors.NoSuchFile:
2262
self.bzrdir.transport.delete_tree('inventory-store')
2263
self.bzrdir.transport.delete_tree('text-store')
2265
def _convert_working_inv(self):
2266
inv = xml4.serializer_v4.read_inventory(
2267
self.branch._transport.get('inventory'))
2268
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv, working=True)
2269
self.branch._transport.put_bytes('inventory', new_inv_xml,
2270
mode=self.bzrdir._get_file_mode())
2272
def _write_all_weaves(self):
2273
controlweaves = WeaveStore(self.bzrdir.transport, prefixed=False)
2274
weave_transport = self.bzrdir.transport.clone('weaves')
2275
weaves = WeaveStore(weave_transport, prefixed=False)
2276
transaction = WriteTransaction()
2280
for file_id, file_weave in self.text_weaves.items():
2281
self.pb.update('writing weave', i, len(self.text_weaves))
2282
weaves._put_weave(file_id, file_weave, transaction)
2284
self.pb.update('inventory', 0, 1)
2285
controlweaves._put_weave('inventory', self.inv_weave, transaction)
2286
self.pb.update('inventory', 1, 1)
2290
def _write_all_revs(self):
2291
"""Write all revisions out in new form."""
2292
self.bzrdir.transport.delete_tree('revision-store')
2293
self.bzrdir.transport.mkdir('revision-store')
2294
revision_transport = self.bzrdir.transport.clone('revision-store')
2296
from bzrlib.xml5 import serializer_v5
2297
from bzrlib.repofmt.weaverepo import RevisionTextStore
2298
revision_store = RevisionTextStore(revision_transport,
2299
serializer_v5, False, versionedfile.PrefixMapper(),
2300
lambda:True, lambda:True)
2302
for i, rev_id in enumerate(self.converted_revs):
2303
self.pb.update('write revision', i, len(self.converted_revs))
2304
text = serializer_v5.write_revision_to_string(
2305
self.revisions[rev_id])
2307
revision_store.add_lines(key, None, osutils.split_lines(text))
2311
def _load_one_rev(self, rev_id):
2312
"""Load a revision object into memory.
2314
Any parents not either loaded or abandoned get queued to be
2316
self.pb.update('loading revision',
2317
len(self.revisions),
2318
len(self.known_revisions))
2319
if not self.branch.repository.has_revision(rev_id):
2321
ui.ui_factory.note('revision {%s} not present in branch; '
2322
'will be converted as a ghost' %
2324
self.absent_revisions.add(rev_id)
2326
rev = self.branch.repository.get_revision(rev_id)
2327
for parent_id in rev.parent_ids:
2328
self.known_revisions.add(parent_id)
2329
self.to_read.append(parent_id)
2330
self.revisions[rev_id] = rev
2332
def _load_old_inventory(self, rev_id):
2333
f = self.branch.repository.inventory_store.get(rev_id)
2335
old_inv_xml = f.read()
2338
inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
2339
inv.revision_id = rev_id
2340
rev = self.revisions[rev_id]
2343
def _load_updated_inventory(self, rev_id):
2344
inv_xml = self.inv_weave.get_text(rev_id)
2345
inv = xml5.serializer_v5.read_inventory_from_string(inv_xml, rev_id)
2348
def _convert_one_rev(self, rev_id):
2349
"""Convert revision and all referenced objects to new format."""
2350
rev = self.revisions[rev_id]
2351
inv = self._load_old_inventory(rev_id)
2352
present_parents = [p for p in rev.parent_ids
2353
if p not in self.absent_revisions]
2354
self._convert_revision_contents(rev, inv, present_parents)
2355
self._store_new_inv(rev, inv, present_parents)
2356
self.converted_revs.add(rev_id)
2358
def _store_new_inv(self, rev, inv, present_parents):
2359
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
2360
new_inv_sha1 = sha_string(new_inv_xml)
2361
self.inv_weave.add_lines(rev.revision_id,
2363
new_inv_xml.splitlines(True))
2364
rev.inventory_sha1 = new_inv_sha1
2366
def _convert_revision_contents(self, rev, inv, present_parents):
2367
"""Convert all the files within a revision.
2369
Also upgrade the inventory to refer to the text revision ids."""
2370
rev_id = rev.revision_id
2371
mutter('converting texts of revision {%s}',
2373
parent_invs = map(self._load_updated_inventory, present_parents)
2374
entries = inv.iter_entries()
2376
for path, ie in entries:
2377
self._convert_file_version(rev, ie, parent_invs)
2379
def _convert_file_version(self, rev, ie, parent_invs):
2380
"""Convert one version of one file.
2382
The file needs to be added into the weave if it is a merge
2383
of >=2 parents or if it's changed from its parent.
2385
file_id = ie.file_id
2386
rev_id = rev.revision_id
2387
w = self.text_weaves.get(file_id)
2390
self.text_weaves[file_id] = w
2391
text_changed = False
2392
parent_candiate_entries = ie.parent_candidates(parent_invs)
2393
heads = graph.Graph(self).heads(parent_candiate_entries.keys())
2394
# XXX: Note that this is unordered - and this is tolerable because
2395
# the previous code was also unordered.
2396
previous_entries = dict((head, parent_candiate_entries[head]) for head
2398
self.snapshot_ie(previous_entries, ie, w, rev_id)
2400
def get_parent_map(self, revision_ids):
2401
"""See graph.StackedParentsProvider.get_parent_map"""
2402
return dict((revision_id, self.revisions[revision_id])
2403
for revision_id in revision_ids
2404
if revision_id in self.revisions)
2406
def snapshot_ie(self, previous_revisions, ie, w, rev_id):
2407
# TODO: convert this logic, which is ~= snapshot to
2408
# a call to:. This needs the path figured out. rather than a work_tree
2409
# a v4 revision_tree can be given, or something that looks enough like
2410
# one to give the file content to the entry if it needs it.
2411
# and we need something that looks like a weave store for snapshot to
2413
#ie.snapshot(rev, PATH, previous_revisions, REVISION_TREE, InMemoryWeaveStore(self.text_weaves))
2414
if len(previous_revisions) == 1:
2415
previous_ie = previous_revisions.values()[0]
2416
if ie._unchanged(previous_ie):
2417
ie.revision = previous_ie.revision
2420
f = self.branch.repository._text_store.get(ie.text_id)
2422
file_lines = f.readlines()
2425
w.add_lines(rev_id, previous_revisions, file_lines)
2426
self.text_count += 1
2428
w.add_lines(rev_id, previous_revisions, [])
2429
ie.revision = rev_id
2431
def _make_order(self):
2432
"""Return a suitable order for importing revisions.
2434
The order must be such that an revision is imported after all
2435
its (present) parents.
2437
todo = set(self.revisions.keys())
2438
done = self.absent_revisions.copy()
2441
# scan through looking for a revision whose parents
2443
for rev_id in sorted(list(todo)):
2444
rev = self.revisions[rev_id]
2445
parent_ids = set(rev.parent_ids)
2446
if parent_ids.issubset(done):
2447
# can take this one now
2448
order.append(rev_id)
2454
class ConvertBzrDir5To6(Converter):
2455
"""Converts format 5 bzr dirs to format 6."""
2457
def convert(self, to_convert, pb):
2458
"""See Converter.convert()."""
2459
self.bzrdir = to_convert
2460
pb = ui.ui_factory.nested_progress_bar()
2462
ui.ui_factory.note('starting upgrade from format 5 to 6')
2463
self._convert_to_prefixed()
2464
return BzrDir.open(self.bzrdir.user_url)
2468
def _convert_to_prefixed(self):
2469
from bzrlib.store import TransportStore
2470
self.bzrdir.transport.delete('branch-format')
2471
for store_name in ["weaves", "revision-store"]:
2472
ui.ui_factory.note("adding prefixes to %s" % store_name)
2473
store_transport = self.bzrdir.transport.clone(store_name)
2474
store = TransportStore(store_transport, prefixed=True)
2475
for urlfilename in store_transport.list_dir('.'):
2476
filename = urlutils.unescape(urlfilename)
2477
if (filename.endswith(".weave") or
2478
filename.endswith(".gz") or
2479
filename.endswith(".sig")):
2480
file_id, suffix = os.path.splitext(filename)
2484
new_name = store._mapper.map((file_id,)) + suffix
2485
# FIXME keep track of the dirs made RBC 20060121
2487
store_transport.move(filename, new_name)
2488
except errors.NoSuchFile: # catches missing dirs strangely enough
2489
store_transport.mkdir(osutils.dirname(new_name))
2490
store_transport.move(filename, new_name)
2491
self.bzrdir.transport.put_bytes(
2493
BzrDirFormat6().get_format_string(),
2494
mode=self.bzrdir._get_file_mode())
2497
class ConvertBzrDir6ToMeta(Converter):
2498
"""Converts format 6 bzr dirs to metadirs."""
2500
def convert(self, to_convert, pb):
2501
"""See Converter.convert()."""
2502
from bzrlib.repofmt.weaverepo import RepositoryFormat7
2503
from bzrlib.branch import BzrBranchFormat5
2504
self.bzrdir = to_convert
2505
self.pb = ui.ui_factory.nested_progress_bar()
2507
self.total = 20 # the steps we know about
2508
self.garbage_inventories = []
2509
self.dir_mode = self.bzrdir._get_dir_mode()
2510
self.file_mode = self.bzrdir._get_file_mode()
2512
ui.ui_factory.note('starting upgrade from format 6 to metadir')
2513
self.bzrdir.transport.put_bytes(
2515
"Converting to format 6",
2516
mode=self.file_mode)
2517
# its faster to move specific files around than to open and use the apis...
2518
# first off, nuke ancestry.weave, it was never used.
2520
self.step('Removing ancestry.weave')
2521
self.bzrdir.transport.delete('ancestry.weave')
2522
except errors.NoSuchFile:
2524
# find out whats there
2525
self.step('Finding branch files')
2526
last_revision = self.bzrdir.open_branch().last_revision()
2527
bzrcontents = self.bzrdir.transport.list_dir('.')
2528
for name in bzrcontents:
2529
if name.startswith('basis-inventory.'):
2530
self.garbage_inventories.append(name)
2531
# create new directories for repository, working tree and branch
2532
repository_names = [('inventory.weave', True),
2533
('revision-store', True),
2535
self.step('Upgrading repository ')
2536
self.bzrdir.transport.mkdir('repository', mode=self.dir_mode)
2537
self.make_lock('repository')
2538
# we hard code the formats here because we are converting into
2539
# the meta format. The meta format upgrader can take this to a
2540
# future format within each component.
2541
self.put_format('repository', RepositoryFormat7())
2542
for entry in repository_names:
2543
self.move_entry('repository', entry)
2545
self.step('Upgrading branch ')
2546
self.bzrdir.transport.mkdir('branch', mode=self.dir_mode)
2547
self.make_lock('branch')
2548
self.put_format('branch', BzrBranchFormat5())
2549
branch_files = [('revision-history', True),
2550
('branch-name', True),
2552
for entry in branch_files:
2553
self.move_entry('branch', entry)
2555
checkout_files = [('pending-merges', True),
2556
('inventory', True),
2557
('stat-cache', False)]
2558
# If a mandatory checkout file is not present, the branch does not have
2559
# a functional checkout. Do not create a checkout in the converted
2561
for name, mandatory in checkout_files:
2562
if mandatory and name not in bzrcontents:
2563
has_checkout = False
2567
if not has_checkout:
2568
ui.ui_factory.note('No working tree.')
2569
# If some checkout files are there, we may as well get rid of them.
2570
for name, mandatory in checkout_files:
2571
if name in bzrcontents:
2572
self.bzrdir.transport.delete(name)
2574
from bzrlib.workingtree import WorkingTreeFormat3
2575
self.step('Upgrading working tree')
2576
self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
2577
self.make_lock('checkout')
2579
'checkout', WorkingTreeFormat3())
2580
self.bzrdir.transport.delete_multi(
2581
self.garbage_inventories, self.pb)
2582
for entry in checkout_files:
2583
self.move_entry('checkout', entry)
2584
if last_revision is not None:
2585
self.bzrdir.transport.put_bytes(
2586
'checkout/last-revision', last_revision)
2587
self.bzrdir.transport.put_bytes(
2589
BzrDirMetaFormat1().get_format_string(),
2590
mode=self.file_mode)
2592
return BzrDir.open(self.bzrdir.user_url)
2594
def make_lock(self, name):
2595
"""Make a lock for the new control dir name."""
2596
self.step('Make %s lock' % name)
2597
ld = lockdir.LockDir(self.bzrdir.transport,
2599
file_modebits=self.file_mode,
2600
dir_modebits=self.dir_mode)
2603
def move_entry(self, new_dir, entry):
2604
"""Move then entry name into new_dir."""
2606
mandatory = entry[1]
2607
self.step('Moving %s' % name)
2609
self.bzrdir.transport.move(name, '%s/%s' % (new_dir, name))
2610
except errors.NoSuchFile:
2614
def put_format(self, dirname, format):
2615
self.bzrdir.transport.put_bytes('%s/format' % dirname,
2616
format.get_format_string(),
2620
class ConvertMetaToMeta(Converter):
1761
BzrProber.formats.register(BzrDirMetaFormat1.get_format_string(),
1763
controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()
1766
class BzrDirMetaFormat1Colo(BzrDirMetaFormat1):
1767
"""BzrDirMeta1 format with support for colocated branches."""
1769
colocated_branches = True
1772
def get_format_string(cls):
1773
"""See BzrDirFormat.get_format_string()."""
1774
return "Bazaar meta directory, format 1 (with colocated branches)\n"
1776
def get_format_description(self):
1777
"""See BzrDirFormat.get_format_description()."""
1778
return "Meta directory format 1 with support for colocated branches"
1780
def _open(self, transport):
1781
"""See BzrDirFormat._open."""
1782
# Create a new format instance because otherwise initialisation of new
1783
# metadirs share the global default format object leading to alias
1785
format = BzrDirMetaFormat1Colo()
1786
self._supply_sub_formats_to(format)
1787
return BzrDirMeta1(transport, format)
1790
BzrProber.formats.register(BzrDirMetaFormat1Colo.get_format_string(),
1791
BzrDirMetaFormat1Colo)
1794
class ConvertMetaToMeta(controldir.Converter):
2621
1795
"""Converts the components of metadirs."""
2623
1797
def __init__(self, target_format):
2696
1869
return to_convert
2699
# This is not in remote.py because it's relatively small, and needs to be
2700
# registered. Putting it in remote.py creates a circular import problem.
2701
# we can make it a lazy object if the control formats is turned into something
2703
class RemoteBzrDirFormat(BzrDirMetaFormat1):
2704
"""Format representing bzrdirs accessed via a smart server"""
2707
BzrDirMetaFormat1.__init__(self)
2708
# XXX: It's a bit ugly that the network name is here, because we'd
2709
# like to believe that format objects are stateless or at least
2710
# immutable, However, we do at least avoid mutating the name after
2711
# it's returned. See <https://bugs.launchpad.net/bzr/+bug/504102>
2712
self._network_name = None
2715
return "%s(_network_name=%r)" % (self.__class__.__name__,
2718
def get_format_description(self):
2719
if self._network_name:
2720
real_format = network_format_registry.get(self._network_name)
2721
return 'Remote: ' + real_format.get_format_description()
2722
return 'bzr remote bzrdir'
2724
def get_format_string(self):
2725
raise NotImplementedError(self.get_format_string)
2727
def network_name(self):
2728
if self._network_name:
2729
return self._network_name
2731
raise AssertionError("No network name set.")
2733
def initialize_on_transport(self, transport):
2735
# hand off the request to the smart server
2736
client_medium = transport.get_smart_medium()
2737
except errors.NoSmartMedium:
2738
# TODO: lookup the local format from a server hint.
2739
local_dir_format = BzrDirMetaFormat1()
2740
return local_dir_format.initialize_on_transport(transport)
2741
client = _SmartClient(client_medium)
2742
path = client.remote_path_from_transport(transport)
2744
response = client.call('BzrDirFormat.initialize', path)
2745
except errors.ErrorFromSmartServer, err:
2746
remote._translate_error(err, path=path)
2747
if response[0] != 'ok':
2748
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2749
format = RemoteBzrDirFormat()
2750
self._supply_sub_formats_to(format)
2751
return remote.RemoteBzrDir(transport, format)
2753
def parse_NoneTrueFalse(self, arg):
2760
raise AssertionError("invalid arg %r" % arg)
2762
def _serialize_NoneTrueFalse(self, arg):
2769
def _serialize_NoneString(self, arg):
2772
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
2773
create_prefix=False, force_new_repo=False, stacked_on=None,
2774
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
2777
# hand off the request to the smart server
2778
client_medium = transport.get_smart_medium()
2779
except errors.NoSmartMedium:
2782
# Decline to open it if the server doesn't support our required
2783
# version (3) so that the VFS-based transport will do it.
2784
if client_medium.should_probe():
2786
server_version = client_medium.protocol_version()
2787
if server_version != '2':
2791
except errors.SmartProtocolError:
2792
# Apparently there's no usable smart server there, even though
2793
# the medium supports the smart protocol.
2798
client = _SmartClient(client_medium)
2799
path = client.remote_path_from_transport(transport)
2800
if client_medium._is_remote_before((1, 16)):
2803
# TODO: lookup the local format from a server hint.
2804
local_dir_format = BzrDirMetaFormat1()
2805
self._supply_sub_formats_to(local_dir_format)
2806
return local_dir_format.initialize_on_transport_ex(transport,
2807
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2808
force_new_repo=force_new_repo, stacked_on=stacked_on,
2809
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2810
make_working_trees=make_working_trees, shared_repo=shared_repo,
2812
return self._initialize_on_transport_ex_rpc(client, path, transport,
2813
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2814
stack_on_pwd, repo_format_name, make_working_trees, shared_repo)
2816
def _initialize_on_transport_ex_rpc(self, client, path, transport,
2817
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2818
stack_on_pwd, repo_format_name, make_working_trees, shared_repo):
2820
args.append(self._serialize_NoneTrueFalse(use_existing_dir))
2821
args.append(self._serialize_NoneTrueFalse(create_prefix))
2822
args.append(self._serialize_NoneTrueFalse(force_new_repo))
2823
args.append(self._serialize_NoneString(stacked_on))
2824
# stack_on_pwd is often/usually our transport
2827
stack_on_pwd = transport.relpath(stack_on_pwd)
2828
if not stack_on_pwd:
2830
except errors.PathNotChild:
2832
args.append(self._serialize_NoneString(stack_on_pwd))
2833
args.append(self._serialize_NoneString(repo_format_name))
2834
args.append(self._serialize_NoneTrueFalse(make_working_trees))
2835
args.append(self._serialize_NoneTrueFalse(shared_repo))
2836
request_network_name = self._network_name or \
2837
BzrDirFormat.get_default_format().network_name()
2839
response = client.call('BzrDirFormat.initialize_ex_1.16',
2840
request_network_name, path, *args)
2841
except errors.UnknownSmartMethod:
2842
client._medium._remember_remote_is_before((1,16))
2843
local_dir_format = BzrDirMetaFormat1()
2844
self._supply_sub_formats_to(local_dir_format)
2845
return local_dir_format.initialize_on_transport_ex(transport,
2846
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2847
force_new_repo=force_new_repo, stacked_on=stacked_on,
2848
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2849
make_working_trees=make_working_trees, shared_repo=shared_repo,
2851
except errors.ErrorFromSmartServer, err:
2852
remote._translate_error(err, path=path)
2853
repo_path = response[0]
2854
bzrdir_name = response[6]
2855
require_stacking = response[7]
2856
require_stacking = self.parse_NoneTrueFalse(require_stacking)
2857
format = RemoteBzrDirFormat()
2858
format._network_name = bzrdir_name
2859
self._supply_sub_formats_to(format)
2860
bzrdir = remote.RemoteBzrDir(transport, format, _client=client)
2862
repo_format = remote.response_tuple_to_repo_format(response[1:])
2863
if repo_path == '.':
2866
repo_bzrdir_format = RemoteBzrDirFormat()
2867
repo_bzrdir_format._network_name = response[5]
2868
repo_bzr = remote.RemoteBzrDir(transport.clone(repo_path),
2872
final_stack = response[8] or None
2873
final_stack_pwd = response[9] or None
2875
final_stack_pwd = urlutils.join(
2876
transport.base, final_stack_pwd)
2877
remote_repo = remote.RemoteRepository(repo_bzr, repo_format)
2878
if len(response) > 10:
2879
# Updated server verb that locks remotely.
2880
repo_lock_token = response[10] or None
2881
remote_repo.lock_write(repo_lock_token, _skip_rpc=True)
2883
remote_repo.dont_leave_lock_in_place()
2885
remote_repo.lock_write()
2886
policy = UseExistingRepository(remote_repo, final_stack,
2887
final_stack_pwd, require_stacking)
2888
policy.acquire_repository()
2892
bzrdir._format.set_branch_format(self.get_branch_format())
2893
if require_stacking:
2894
# The repo has already been created, but we need to make sure that
2895
# we'll make a stackable branch.
2896
bzrdir._format.require_stacking(_skip_repo=True)
2897
return remote_repo, bzrdir, require_stacking, policy
2899
def _open(self, transport):
2900
return remote.RemoteBzrDir(transport, self)
2902
def __eq__(self, other):
2903
if not isinstance(other, RemoteBzrDirFormat):
2905
return self.get_format_description() == other.get_format_description()
2907
def __return_repository_format(self):
2908
# Always return a RemoteRepositoryFormat object, but if a specific bzr
2909
# repository format has been asked for, tell the RemoteRepositoryFormat
2910
# that it should use that for init() etc.
2911
result = remote.RemoteRepositoryFormat()
2912
custom_format = getattr(self, '_repository_format', None)
2914
if isinstance(custom_format, remote.RemoteRepositoryFormat):
2915
return custom_format
2917
# We will use the custom format to create repositories over the
2918
# wire; expose its details like rich_root_data for code to
2920
result._custom_format = custom_format
2923
def get_branch_format(self):
2924
result = BzrDirMetaFormat1.get_branch_format(self)
2925
if not isinstance(result, remote.RemoteBranchFormat):
2926
new_result = remote.RemoteBranchFormat()
2927
new_result._custom_format = result
2929
self.set_branch_format(new_result)
2933
repository_format = property(__return_repository_format,
2934
BzrDirMetaFormat1._set_repository_format) #.im_func)
1872
class ConvertMetaToColo(controldir.Converter):
1873
"""Add colocated branch support."""
1875
def __init__(self, target_format):
1876
"""Create a converter.that upgrades a metadir to the colo format.
1878
:param target_format: The final metadir format that is desired.
1880
self.target_format = target_format
1882
def convert(self, to_convert, pb):
1883
"""See Converter.convert()."""
1884
to_convert.transport.put_bytes('branch-format',
1885
self.target_format.as_string())
1886
return BzrDir.open_from_transport(to_convert.root_transport)
1889
class ConvertMetaToColo(controldir.Converter):
1890
"""Convert a 'development-colo' bzrdir to a '2a' bzrdir."""
1892
def __init__(self, target_format):
1893
"""Create a converter that converts a 'development-colo' metadir
1896
:param target_format: The final metadir format that is desired.
1898
self.target_format = target_format
1900
def convert(self, to_convert, pb):
1901
"""See Converter.convert()."""
1902
to_convert.transport.put_bytes('branch-format',
1903
self.target_format.as_string())
1904
return BzrDir.open_from_transport(to_convert.root_transport)
2937
1907
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
3141
2124
registry.register(key, helper, help, native, deprecated, hidden,
3142
2125
experimental, alias)
3144
# The pre-0.8 formats have their repository format network name registered in
3145
# repository.py. MetaDir formats have their repository format network name
3146
# inferred from their disk format string.
3147
controldir.format_registry.register('weave', BzrDirFormat6,
3148
'Pre-0.8 format. Slower than knit and does not'
3149
' support checkouts or shared repositories.',
3152
register_metadir(controldir.format_registry, 'metaweave',
3153
'bzrlib.repofmt.weaverepo.RepositoryFormat7',
3154
'Transitional format in 0.8. Slower than knit.',
3155
branch_format='bzrlib.branch.BzrBranchFormat5',
3156
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3159
2127
register_metadir(controldir.format_registry, 'knit',
3160
2128
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3161
2129
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
3162
2130
branch_format='bzrlib.branch.BzrBranchFormat5',
3163
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
2131
tree_format='bzrlib.workingtree_3.WorkingTreeFormat3',
3165
2133
deprecated=True)
3166
2134
register_metadir(controldir.format_registry, 'dirstate',
3167
2135
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3168
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
3169
'above when accessed over the network.',
2136
help='Format using dirstate for working trees. '
2137
'Compatible with bzr 0.8 and '
2138
'above when accessed over the network. Introduced in bzr 0.15.',
3170
2139
branch_format='bzrlib.branch.BzrBranchFormat5',
3171
# this uses bzrlib.workingtree.WorkingTreeFormat4 because importing
3172
# directly from workingtree_4 triggers a circular import.
3173
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2140
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3175
2142
deprecated=True)
3176
2143
register_metadir(controldir.format_registry, 'dirstate-tags',
3177
2144
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3178
help='New in 0.15: Fast local operations and improved scaling for '
3179
'network operations. Additionally adds support for tags.'
3180
' Incompatible with bzr < 0.15.',
2145
help='Variant of dirstate with support for tags. '
2146
'Introduced in bzr 0.15.',
3181
2147
branch_format='bzrlib.branch.BzrBranchFormat6',
3182
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2148
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3184
2150
deprecated=True)
3185
2151
register_metadir(controldir.format_registry, 'rich-root',
3186
2152
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4',
3187
help='New in 1.0. Better handling of tree roots. Incompatible with'
2153
help='Variant of dirstate with better handling of tree roots. '
2154
'Introduced in bzr 1.0',
3189
2155
branch_format='bzrlib.branch.BzrBranchFormat6',
3190
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2156
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3192
2158
deprecated=True)
3193
2159
register_metadir(controldir.format_registry, 'dirstate-with-subtree',
3194
2160
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
3195
help='New in 0.15: Fast local operations and improved scaling for '
3196
'network operations. Additionally adds support for versioning nested '
3197
'bzr branches. Incompatible with bzr < 0.15.',
2161
help='Variant of dirstate with support for nested trees. '
2162
'Introduced in 0.15.',
3198
2163
branch_format='bzrlib.branch.BzrBranchFormat6',
3199
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2164
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3200
2165
experimental=True,
3203
2168
register_metadir(controldir.format_registry, 'pack-0.92',
3204
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
3205
help='New in 0.92: Pack-based format with data compatible with '
3206
'dirstate-tags format repositories. Interoperates with '
3207
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2169
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack1',
2170
help='Pack-based format used in 1.x series. Introduced in 0.92. '
2171
'Interoperates with bzr repositories before 0.92 but cannot be '
2172
'read by bzr < 0.92. '
3209
2174
branch_format='bzrlib.branch.BzrBranchFormat6',
3210
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2175
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3212
2178
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
3213
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
3214
help='New in 0.92: Pack-based format with data compatible with '
3215
'dirstate-with-subtree format repositories. Interoperates with '
2179
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack3',
2180
help='Pack-based format used in 1.x series, with subtree support. '
2181
'Introduced in 0.92. Interoperates with '
3216
2182
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3218
2184
branch_format='bzrlib.branch.BzrBranchFormat6',
3219
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2185
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3221
2188
experimental=True,
3223
2190
register_metadir(controldir.format_registry, 'rich-root-pack',
3224
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3225
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
3226
'(needed for bzr-svn and bzr-git).',
2191
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack4',
2192
help='A variant of pack-0.92 that supports rich-root data '
2193
'(needed for bzr-svn and bzr-git). Introduced in 1.0.',
3227
2194
branch_format='bzrlib.branch.BzrBranchFormat6',
3228
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2195
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3231
2199
register_metadir(controldir.format_registry, '1.6',
3232
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
2200
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5',
3233
2201
help='A format that allows a branch to indicate that there is another '
3234
2202
'(stacked) repository that should be used to access data that is '
3235
2203
'not present locally.',
3236
2204
branch_format='bzrlib.branch.BzrBranchFormat7',
3237
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2205
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3240
2209
register_metadir(controldir.format_registry, '1.6.1-rich-root',
3241
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
2210
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5RichRoot',
3242
2211
help='A variant of 1.6 that supports rich-root data '
3243
2212
'(needed for bzr-svn and bzr-git).',
3244
2213
branch_format='bzrlib.branch.BzrBranchFormat7',
3245
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2214
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3248
2218
register_metadir(controldir.format_registry, '1.9',
3249
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2219
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3250
2220
help='A repository format using B+tree indexes. These indexes '
3251
2221
'are smaller in size, have smarter caching and provide faster '
3252
2222
'performance for most operations.',
3253
2223
branch_format='bzrlib.branch.BzrBranchFormat7',
3254
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2224
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3257
2228
register_metadir(controldir.format_registry, '1.9-rich-root',
3258
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2229
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3259
2230
help='A variant of 1.9 that supports rich-root data '
3260
2231
'(needed for bzr-svn and bzr-git).',
3261
2232
branch_format='bzrlib.branch.BzrBranchFormat7',
3262
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2233
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3265
2237
register_metadir(controldir.format_registry, '1.14',
3266
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2238
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3267
2239
help='A working-tree format that supports content filtering.',
3268
2240
branch_format='bzrlib.branch.BzrBranchFormat7',
3269
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2241
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3271
2245
register_metadir(controldir.format_registry, '1.14-rich-root',
3272
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2246
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3273
2247
help='A variant of 1.14 that supports rich-root data '
3274
2248
'(needed for bzr-svn and bzr-git).',
3275
2249
branch_format='bzrlib.branch.BzrBranchFormat7',
3276
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2250
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3278
2254
# The following un-numbered 'development' formats should always just be aliases.
3279
register_metadir(controldir.format_registry, 'development-rich-root',
3280
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3281
help='Current development format. Supports rich roots. Can convert data '
3282
'to and from rich-root-pack (and anything compatible with '
3283
'rich-root-pack) format repositories. Repositories and branches in '
3284
'this format can only be read by bzr.dev. Please read '
3285
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3287
branch_format='bzrlib.branch.BzrBranchFormat7',
3288
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3293
2255
register_metadir(controldir.format_registry, 'development-subtree',
3294
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
2256
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2aSubtree',
3295
2257
help='Current development format, subtree variant. Can convert data to and '
3296
2258
'from pack-0.92-subtree (and anything compatible with '
3297
2259
'pack-0.92-subtree) format repositories. Repositories and branches in '