434
299
policy = self.determine_repository_policy(force_new_repo)
435
300
return policy.acquire_repository()[0]
438
def create_branch_convenience(base, force_new_repo=False,
439
force_new_tree=None, format=None,
440
possible_transports=None):
441
"""Create a new BzrDir, Branch and Repository at the url 'base'.
443
This is a convenience function - it will use an existing repository
444
if possible, can be told explicitly whether to create a working tree or
447
This will use the current default BzrDirFormat unless one is
448
specified, and use whatever
449
repository format that that uses via bzrdir.create_branch and
450
create_repository. If a shared repository is available that is used
451
preferentially. Whatever repository is used, its tree creation policy
454
The created Branch object is returned.
455
If a working tree cannot be made due to base not being a file:// url,
456
no error is raised unless force_new_tree is True, in which case no
457
data is created on disk and NotLocalUrl is raised.
459
:param base: The URL to create the branch at.
460
:param force_new_repo: If True a new repository is always created.
461
:param force_new_tree: If True or False force creation of a tree or
462
prevent such creation respectively.
463
:param format: Override for the bzrdir format to create.
464
:param possible_transports: An optional reusable transports list.
467
# check for non local urls
468
t = get_transport(base, possible_transports)
469
if not isinstance(t, local.LocalTransport):
470
raise errors.NotLocalUrl(base)
471
bzrdir = BzrDir.create(base, format, possible_transports)
472
repo = bzrdir._find_or_create_repository(force_new_repo)
473
result = bzrdir.create_branch()
474
if force_new_tree or (repo.make_working_trees() and
475
force_new_tree is None):
477
bzrdir.create_workingtree()
478
except errors.NotLocalUrl:
302
def _find_source_repo(self, add_cleanup, source_branch):
303
"""Find the source branch and repo for a sprout operation.
305
This is helper intended for use by _sprout.
307
:returns: (source_branch, source_repository). Either or both may be
308
None. If not None, they will be read-locked (and their unlock(s)
309
scheduled via the add_cleanup param).
311
if source_branch is not None:
312
add_cleanup(source_branch.lock_read().unlock)
313
return source_branch, source_branch.repository
315
source_branch = self.open_branch()
316
source_repository = source_branch.repository
317
except errors.NotBranchError:
320
source_repository = self.open_repository()
321
except errors.NoRepositoryPresent:
322
source_repository = None
324
add_cleanup(source_repository.lock_read().unlock)
326
add_cleanup(source_branch.lock_read().unlock)
327
return source_branch, source_repository
329
def sprout(self, url, revision_id=None, force_new_repo=False,
330
recurse='down', possible_transports=None,
331
accelerator_tree=None, hardlink=False, stacked=False,
332
source_branch=None, create_tree_if_local=True):
333
"""Create a copy of this controldir prepared for use as a new line of
336
If url's last component does not exist, it will be created.
338
Attributes related to the identity of the source branch like
339
branch nickname will be cleaned, a working tree is created
340
whether one existed before or not; and a local branch is always
343
if revision_id is not None, then the clone operation may tune
344
itself to download less data.
346
:param accelerator_tree: A tree which can be used for retrieving file
347
contents more quickly than the revision tree, i.e. a workingtree.
348
The revision tree will be used for cases where accelerator_tree's
349
content is different.
350
:param hardlink: If true, hard-link files from accelerator_tree,
352
:param stacked: If true, create a stacked branch referring to the
353
location of this control directory.
354
:param create_tree_if_local: If true, a working-tree will be created
355
when working locally.
357
operation = cleanup.OperationWithCleanups(self._sprout)
358
return operation.run(url, revision_id=revision_id,
359
force_new_repo=force_new_repo, recurse=recurse,
360
possible_transports=possible_transports,
361
accelerator_tree=accelerator_tree, hardlink=hardlink,
362
stacked=stacked, source_branch=source_branch,
363
create_tree_if_local=create_tree_if_local)
365
def _sprout(self, op, url, revision_id=None, force_new_repo=False,
366
recurse='down', possible_transports=None,
367
accelerator_tree=None, hardlink=False, stacked=False,
368
source_branch=None, create_tree_if_local=True):
369
add_cleanup = op.add_cleanup
370
fetch_spec_factory = fetch.FetchSpecFactory()
371
if revision_id is not None:
372
fetch_spec_factory.add_revision_ids([revision_id])
373
fetch_spec_factory.source_branch_stop_revision_id = revision_id
374
if possible_transports is None:
375
possible_transports = []
377
possible_transports = list(possible_transports) + [
379
target_transport = _mod_transport.get_transport(url,
381
target_transport.ensure_base()
382
cloning_format = self.cloning_metadir(stacked)
383
# Create/update the result branch
385
result = controldir.ControlDir.open_from_transport(target_transport)
386
except errors.NotBranchError:
387
result = cloning_format.initialize_on_transport(target_transport)
388
source_branch, source_repository = self._find_source_repo(
389
add_cleanup, source_branch)
390
fetch_spec_factory.source_branch = source_branch
391
# if a stacked branch wasn't requested, we don't create one
392
# even if the origin was stacked
393
if stacked and source_branch is not None:
394
stacked_branch_url = self.root_transport.base
396
stacked_branch_url = None
397
repository_policy = result.determine_repository_policy(
398
force_new_repo, stacked_branch_url, require_stacking=stacked)
399
result_repo, is_new_repo = repository_policy.acquire_repository(
400
possible_transports=possible_transports)
401
add_cleanup(result_repo.lock_write().unlock)
402
fetch_spec_factory.source_repo = source_repository
403
fetch_spec_factory.target_repo = result_repo
404
if stacked or (len(result_repo._fallback_repositories) != 0):
405
target_repo_kind = fetch.TargetRepoKinds.STACKED
407
target_repo_kind = fetch.TargetRepoKinds.EMPTY
409
target_repo_kind = fetch.TargetRepoKinds.PREEXISTING
410
fetch_spec_factory.target_repo_kind = target_repo_kind
411
if source_repository is not None:
412
fetch_spec = fetch_spec_factory.make_fetch_spec()
413
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
415
if source_branch is None:
416
# this is for sprouting a controldir without a branch; is that
418
# Not especially, but it's part of the contract.
419
result_branch = result.create_branch()
421
result_branch = source_branch.sprout(result,
422
revision_id=revision_id, repository_policy=repository_policy,
423
repository=result_repo)
424
mutter("created new branch %r" % (result_branch,))
426
# Create/update the result working tree
427
if (create_tree_if_local and not result.has_workingtree() and
428
isinstance(target_transport, local.LocalTransport) and
429
(result_repo is None or result_repo.make_working_trees())):
430
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
431
hardlink=hardlink, from_branch=result_branch)
434
if wt.path2id('') is None:
436
wt.set_root_id(self.open_workingtree.get_root_id())
437
except errors.NoWorkingTree:
443
if recurse == 'down':
446
basis = wt.basis_tree()
447
elif result_branch is not None:
448
basis = result_branch.basis_tree()
449
elif source_branch is not None:
450
basis = source_branch.basis_tree()
451
if basis is not None:
452
add_cleanup(basis.lock_read().unlock)
453
subtrees = basis.iter_references()
456
for path, file_id in subtrees:
457
target = urlutils.join(url, urlutils.escape(path))
458
sublocation = source_branch.reference_parent(file_id, path)
459
sublocation.bzrdir.sprout(target,
460
basis.get_reference_revision(file_id, path),
461
force_new_repo=force_new_repo, recurse=recurse,
483
def create_standalone_workingtree(base, format=None):
484
"""Create a new BzrDir, WorkingTree, Branch and Repository at 'base'.
486
'base' must be a local path or a file:// url.
488
This will use the current default BzrDirFormat unless one is
489
specified, and use whatever
490
repository format that that uses for bzrdirformat.create_workingtree,
491
create_branch and create_repository.
493
:param format: Override for the bzrdir format to create.
494
:return: The WorkingTree object.
496
t = get_transport(base)
497
if not isinstance(t, local.LocalTransport):
498
raise errors.NotLocalUrl(base)
499
bzrdir = BzrDir.create_branch_and_repo(base,
501
format=format).bzrdir
502
return bzrdir.create_workingtree()
504
465
@deprecated_method(deprecated_in((2, 3, 0)))
505
466
def generate_backup_name(self, base):
506
467
return self._available_backup_name(base)
702
664
# add new tests for it to the appropriate place.
703
665
return filename == '.bzr' or filename.startswith('.bzr/')
706
def open_unsupported(base):
707
"""Open a branch which is not supported."""
708
return BzrDir.open(base, _unsupported=True)
711
def open(base, _unsupported=False, possible_transports=None):
712
"""Open an existing bzrdir, rooted at 'base' (url).
714
:param _unsupported: a private parameter to the BzrDir class.
716
t = get_transport(base, possible_transports=possible_transports)
717
return BzrDir.open_from_transport(t, _unsupported=_unsupported)
720
def open_from_transport(transport, _unsupported=False,
721
_server_formats=True):
722
"""Open a bzrdir within a particular directory.
724
:param transport: Transport containing the bzrdir.
725
:param _unsupported: private.
727
for hook in BzrDir.hooks['pre_open']:
729
# Keep initial base since 'transport' may be modified while following
731
base = transport.base
732
def find_format(transport):
733
return transport, controldir.ControlDirFormat.find_format(
734
transport, _server_formats=_server_formats)
736
def redirected(transport, e, redirection_notice):
737
redirected_transport = transport._redirected_to(e.source, e.target)
738
if redirected_transport is None:
739
raise errors.NotBranchError(base)
740
note('%s is%s redirected to %s',
741
transport.base, e.permanently, redirected_transport.base)
742
return redirected_transport
745
transport, format = do_catching_redirections(find_format,
748
except errors.TooManyRedirections:
749
raise errors.NotBranchError(base)
751
BzrDir._check_supported(format, _unsupported)
752
return format.open(transport, _found=True)
755
def open_containing(url, possible_transports=None):
756
"""Open an existing branch which contains url.
758
:param url: url to search from.
759
See open_containing_from_transport for more detail.
761
transport = get_transport(url, possible_transports)
762
return BzrDir.open_containing_from_transport(transport)
765
def open_containing_from_transport(a_transport):
766
"""Open an existing branch which contains a_transport.base.
768
This probes for a branch at a_transport, and searches upwards from there.
770
Basically we keep looking up until we find the control directory or
771
run into the root. If there isn't one, raises NotBranchError.
772
If there is one and it is either an unrecognised format or an unsupported
773
format, UnknownFormatError or UnsupportedFormatError are raised.
774
If there is one, it is returned, along with the unused portion of url.
776
:return: The BzrDir that contains the path, and a Unicode path
777
for the rest of the URL.
779
# this gets the normalised url back. I.e. '.' -> the full path.
780
url = a_transport.base
783
result = BzrDir.open_from_transport(a_transport)
784
return result, urlutils.unescape(a_transport.relpath(url))
785
except errors.NotBranchError, e:
788
new_t = a_transport.clone('..')
789
except errors.InvalidURLJoin:
790
# reached the root, whatever that may be
791
raise errors.NotBranchError(path=url)
792
if new_t.base == a_transport.base:
793
# reached the root, whatever that may be
794
raise errors.NotBranchError(path=url)
798
def open_tree_or_branch(klass, location):
799
"""Return the branch and working tree at a location.
801
If there is no tree at the location, tree will be None.
802
If there is no branch at the location, an exception will be
804
:return: (tree, branch)
806
bzrdir = klass.open(location)
807
return bzrdir._get_tree_branch()
810
def open_containing_tree_or_branch(klass, location):
811
"""Return the branch and working tree contained by a location.
813
Returns (tree, branch, relpath).
814
If there is no tree at containing the location, tree will be None.
815
If there is no branch containing the location, an exception will be
817
relpath is the portion of the path that is contained by the branch.
819
bzrdir, relpath = klass.open_containing(location)
820
tree, branch = bzrdir._get_tree_branch()
821
return tree, branch, relpath
824
def open_containing_tree_branch_or_repository(klass, location):
825
"""Return the working tree, branch and repo contained by a location.
827
Returns (tree, branch, repository, relpath).
828
If there is no tree containing the location, tree will be None.
829
If there is no branch containing the location, branch will be None.
830
If there is no repository containing the location, repository will be
832
relpath is the portion of the path that is contained by the innermost
835
If no tree, branch or repository is found, a NotBranchError is raised.
837
bzrdir, relpath = klass.open_containing(location)
839
tree, branch = bzrdir._get_tree_branch()
840
except errors.NotBranchError:
842
repo = bzrdir.find_repository()
843
return None, None, repo, relpath
844
except (errors.NoRepositoryPresent):
845
raise errors.NotBranchError(location)
846
return tree, branch, branch.repository, relpath
848
667
def _cloning_metadir(self):
849
668
"""Produce a metadir suitable for cloning with.
918
776
can be reused to share a remote connection.
920
778
if cls is not BzrDir:
921
raise AssertionError("BzrDir.create always creates the"
779
raise AssertionError("BzrDir.create always creates the "
922
780
"default format, not one of %r" % cls)
923
t = get_transport(base, possible_transports)
926
format = controldir.ControlDirFormat.get_default_format()
927
return format.initialize_on_transport(t)
931
class BzrDirHooks(hooks.Hooks):
932
"""Hooks for BzrDir operations."""
935
"""Create the default hooks."""
936
hooks.Hooks.__init__(self)
937
self.create_hook(hooks.HookPoint('pre_open',
938
"Invoked before attempting to open a BzrDir with the transport "
939
"that the open will use.", (1, 14), None))
940
self.create_hook(hooks.HookPoint('post_repo_init',
941
"Invoked after a repository has been initialized. "
942
"post_repo_init is called with a "
943
"bzrlib.bzrdir.RepoInitHookParams.",
946
# install the default hooks
947
BzrDir.hooks = BzrDirHooks()
950
class RepoInitHookParams(object):
951
"""Object holding parameters passed to *_repo_init hooks.
953
There are 4 fields that hooks may wish to access:
955
:ivar repository: Repository created
956
:ivar format: Repository format
957
:ivar bzrdir: The bzrdir for the repository
958
:ivar shared: The repository is shared
961
def __init__(self, repository, format, a_bzrdir, shared):
962
"""Create a group of RepoInitHook parameters.
964
:param repository: Repository created
965
:param format: Repository format
966
:param bzrdir: The bzrdir for the repository
967
:param shared: The repository is shared
969
self.repository = repository
971
self.bzrdir = a_bzrdir
974
def __eq__(self, other):
975
return self.__dict__ == other.__dict__
781
return controldir.ControlDir.create(base, format=format,
782
possible_transports=possible_transports)
977
784
def __repr__(self):
979
return "<%s for %s>" % (self.__class__.__name__,
982
return "<%s for %s>" % (self.__class__.__name__,
986
class BzrDirPreSplitOut(BzrDir):
987
"""A common class for the all-in-one formats."""
989
def __init__(self, _transport, _format):
990
"""See BzrDir.__init__."""
991
super(BzrDirPreSplitOut, self).__init__(_transport, _format)
992
self._control_files = lockable_files.LockableFiles(
993
self.get_branch_transport(None),
994
self._format._lock_file_name,
995
self._format._lock_class)
997
def break_lock(self):
998
"""Pre-splitout bzrdirs do not suffer from stale locks."""
999
raise NotImplementedError(self.break_lock)
1001
def cloning_metadir(self, require_stacking=False):
1002
"""Produce a metadir suitable for cloning with."""
1003
if require_stacking:
1004
return controldir.format_registry.make_bzrdir('1.6')
1005
return self._format.__class__()
1007
def clone(self, url, revision_id=None, force_new_repo=False,
1008
preserve_stacking=False):
1009
"""See BzrDir.clone().
1011
force_new_repo has no effect, since this family of formats always
1012
require a new repository.
1013
preserve_stacking has no effect, since no source branch using this
1014
family of formats can be stacked, so there is no stacking to preserve.
1016
self._make_tail(url)
1017
result = self._format._initialize_for_clone(url)
1018
self.open_repository().clone(result, revision_id=revision_id)
1019
from_branch = self.open_branch()
1020
from_branch.clone(result, revision_id=revision_id)
1022
tree = self.open_workingtree()
1023
except errors.NotLocalUrl:
1024
# make a new one, this format always has to have one.
1025
result._init_workingtree()
1030
def create_branch(self, name=None):
1031
"""See BzrDir.create_branch."""
1032
return self._format.get_branch_format().initialize(self, name=name)
1034
def destroy_branch(self, name=None):
1035
"""See BzrDir.destroy_branch."""
1036
raise errors.UnsupportedOperation(self.destroy_branch, self)
1038
def create_repository(self, shared=False):
1039
"""See BzrDir.create_repository."""
1041
raise errors.IncompatibleFormat('shared repository', self._format)
1042
return self.open_repository()
1044
def destroy_repository(self):
1045
"""See BzrDir.destroy_repository."""
1046
raise errors.UnsupportedOperation(self.destroy_repository, self)
1048
def create_workingtree(self, revision_id=None, from_branch=None,
1049
accelerator_tree=None, hardlink=False):
1050
"""See BzrDir.create_workingtree."""
1051
# The workingtree is sometimes created when the bzrdir is created,
1052
# but not when cloning.
1054
# this looks buggy but is not -really-
1055
# because this format creates the workingtree when the bzrdir is
1057
# clone and sprout will have set the revision_id
1058
# and that will have set it for us, its only
1059
# specific uses of create_workingtree in isolation
1060
# that can do wonky stuff here, and that only
1061
# happens for creating checkouts, which cannot be
1062
# done on this format anyway. So - acceptable wart.
1064
warning("can't support hardlinked working trees in %r"
1067
result = self.open_workingtree(recommend_upgrade=False)
1068
except errors.NoSuchFile:
1069
result = self._init_workingtree()
1070
if revision_id is not None:
1071
if revision_id == _mod_revision.NULL_REVISION:
1072
result.set_parent_ids([])
1074
result.set_parent_ids([revision_id])
1077
def _init_workingtree(self):
1078
from bzrlib.workingtree import WorkingTreeFormat2
1080
return WorkingTreeFormat2().initialize(self)
1081
except errors.NotLocalUrl:
1082
# Even though we can't access the working tree, we need to
1083
# create its control files.
1084
return WorkingTreeFormat2()._stub_initialize_on_transport(
1085
self.transport, self._control_files._file_mode)
1087
def destroy_workingtree(self):
1088
"""See BzrDir.destroy_workingtree."""
1089
raise errors.UnsupportedOperation(self.destroy_workingtree, self)
1091
def destroy_workingtree_metadata(self):
1092
"""See BzrDir.destroy_workingtree_metadata."""
1093
raise errors.UnsupportedOperation(self.destroy_workingtree_metadata,
1096
def get_branch_transport(self, branch_format, name=None):
1097
"""See BzrDir.get_branch_transport()."""
1098
if name is not None:
1099
raise errors.NoColocatedBranchSupport(self)
1100
if branch_format is None:
1101
return self.transport
1103
branch_format.get_format_string()
1104
except NotImplementedError:
1105
return self.transport
1106
raise errors.IncompatibleFormat(branch_format, self._format)
1108
def get_repository_transport(self, repository_format):
1109
"""See BzrDir.get_repository_transport()."""
1110
if repository_format is None:
1111
return self.transport
1113
repository_format.get_format_string()
1114
except NotImplementedError:
1115
return self.transport
1116
raise errors.IncompatibleFormat(repository_format, self._format)
1118
def get_workingtree_transport(self, workingtree_format):
1119
"""See BzrDir.get_workingtree_transport()."""
1120
if workingtree_format is None:
1121
return self.transport
1123
workingtree_format.get_format_string()
1124
except NotImplementedError:
1125
return self.transport
1126
raise errors.IncompatibleFormat(workingtree_format, self._format)
1128
def needs_format_conversion(self, format=None):
1129
"""See BzrDir.needs_format_conversion()."""
1130
# if the format is not the same as the system default,
1131
# an upgrade is needed.
1133
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1134
% 'needs_format_conversion(format=None)')
1135
format = BzrDirFormat.get_default_format()
1136
return not isinstance(self._format, format.__class__)
1138
def open_branch(self, name=None, unsupported=False,
1139
ignore_fallbacks=False):
1140
"""See BzrDir.open_branch."""
1141
from bzrlib.branch import BzrBranchFormat4
1142
format = BzrBranchFormat4()
1143
self._check_supported(format, unsupported)
1144
return format.open(self, name, _found=True)
1146
def sprout(self, url, revision_id=None, force_new_repo=False,
1147
possible_transports=None, accelerator_tree=None,
1148
hardlink=False, stacked=False, create_tree_if_local=True,
1149
source_branch=None):
1150
"""See BzrDir.sprout()."""
1151
if source_branch is not None:
1152
my_branch = self.open_branch()
1153
if source_branch.base != my_branch.base:
1154
raise AssertionError(
1155
"source branch %r is not within %r with branch %r" %
1156
(source_branch, self, my_branch))
1158
raise errors.UnstackableBranchFormat(
1159
self._format, self.root_transport.base)
1160
if not create_tree_if_local:
1161
raise errors.MustHaveWorkingTree(
1162
self._format, self.root_transport.base)
1163
from bzrlib.workingtree import WorkingTreeFormat2
1164
self._make_tail(url)
1165
result = self._format._initialize_for_clone(url)
1167
self.open_repository().clone(result, revision_id=revision_id)
1168
except errors.NoRepositoryPresent:
1171
self.open_branch().sprout(result, revision_id=revision_id)
1172
except errors.NotBranchError:
1175
# we always want a working tree
1176
WorkingTreeFormat2().initialize(result,
1177
accelerator_tree=accelerator_tree,
1182
class BzrDir4(BzrDirPreSplitOut):
1183
"""A .bzr version 4 control object.
1185
This is a deprecated format and may be removed after sept 2006.
1188
def create_repository(self, shared=False):
1189
"""See BzrDir.create_repository."""
1190
return self._format.repository_format.initialize(self, shared)
1192
def needs_format_conversion(self, format=None):
1193
"""Format 4 dirs are always in need of conversion."""
1195
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0))
1196
% 'needs_format_conversion(format=None)')
1199
def open_repository(self):
1200
"""See BzrDir.open_repository."""
1201
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1202
return RepositoryFormat4().open(self, _found=True)
1205
class BzrDir5(BzrDirPreSplitOut):
1206
"""A .bzr version 5 control object.
1208
This is a deprecated format and may be removed after sept 2006.
1211
def has_workingtree(self):
1212
"""See BzrDir.has_workingtree."""
1215
def open_repository(self):
1216
"""See BzrDir.open_repository."""
1217
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1218
return RepositoryFormat5().open(self, _found=True)
1220
def open_workingtree(self, _unsupported=False,
1221
recommend_upgrade=True):
1222
"""See BzrDir.create_workingtree."""
1223
from bzrlib.workingtree import WorkingTreeFormat2
1224
wt_format = WorkingTreeFormat2()
1225
# we don't warn here about upgrades; that ought to be handled for the
1227
return wt_format.open(self, _found=True)
1230
class BzrDir6(BzrDirPreSplitOut):
1231
"""A .bzr version 6 control object.
1233
This is a deprecated format and may be removed after sept 2006.
1236
def has_workingtree(self):
1237
"""See BzrDir.has_workingtree."""
1240
def open_repository(self):
1241
"""See BzrDir.open_repository."""
1242
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1243
return RepositoryFormat6().open(self, _found=True)
1245
def open_workingtree(self, _unsupported=False,
1246
recommend_upgrade=True):
1247
"""See BzrDir.create_workingtree."""
1248
# we don't warn here about upgrades; that ought to be handled for the
1250
from bzrlib.workingtree import WorkingTreeFormat2
1251
return WorkingTreeFormat2().open(self, _found=True)
785
return "<%s at %r>" % (self.__class__.__name__, self.user_url)
1254
788
class BzrDirMeta1(BzrDir):
1447
984
return config.TransportConfig(self.transport, 'control.conf')
987
class BzrDirMeta1Colo(BzrDirMeta1):
988
"""BzrDirMeta1 with support for colocated branches.
990
This format is experimental, and will eventually be merged back into
994
def __init__(self, _transport, _format):
995
super(BzrDirMeta1Colo, self).__init__(_transport, _format)
996
self.control_files = lockable_files.LockableFiles(self.control_transport,
997
self._format._lock_file_name, self._format._lock_class)
999
def _get_branch_path(self, name):
1000
"""Obtain the branch path to use.
1002
This uses the API specified branch name first, and then falls back to
1003
the branch name specified in the URL. If neither of those is specified,
1004
it uses the default branch.
1006
:param name: Optional branch name to use
1007
:return: Relative path to branch
1011
return urlutils.join('branches', name.encode("utf-8"))
1013
def _read_branch_list(self):
1014
"""Read the branch list.
1016
:return: List of utf-8 encoded branch names.
1019
f = self.control_transport.get('branch-list')
1020
except errors.NoSuchFile:
1026
ret.append(name.rstrip("\n"))
1031
def _write_branch_list(self, branches):
1032
"""Write out the branch list.
1034
:param branches: List of utf-8 branch names to write
1036
self.transport.put_bytes('branch-list',
1037
"".join([name+"\n" for name in branches]))
1039
def destroy_branch(self, name=None):
1040
"""See BzrDir.create_branch."""
1042
name = self._get_selected_branch()
1043
path = self._get_branch_path(name)
1044
if name is not None:
1045
self.control_files.lock_write()
1047
branches = self._read_branch_list()
1049
branches.remove(name.encode("utf-8"))
1051
raise errors.NotBranchError(name)
1052
self._write_branch_list(branches)
1054
self.control_files.unlock()
1055
self.transport.delete_tree(path)
1057
def get_branches(self):
1058
"""See ControlDir.get_branches."""
1061
ret[None] = self.open_branch()
1062
except (errors.NotBranchError, errors.NoRepositoryPresent):
1065
for name in self._read_branch_list():
1066
ret[name] = self.open_branch(name.decode('utf-8'))
1070
def get_branch_transport(self, branch_format, name=None):
1071
"""See BzrDir.get_branch_transport()."""
1072
path = self._get_branch_path(name)
1073
# XXX: this shouldn't implicitly create the directory if it's just
1074
# promising to get a transport -- mbp 20090727
1075
if branch_format is None:
1076
return self.transport.clone(path)
1078
branch_format.get_format_string()
1079
except NotImplementedError:
1080
raise errors.IncompatibleFormat(branch_format, self._format)
1081
if name is not None:
1083
self.transport.mkdir('branches', mode=self._get_mkdir_mode())
1084
except errors.FileExists:
1086
branches = self._read_branch_list()
1087
utf8_name = name.encode("utf-8")
1088
if not utf8_name in branches:
1089
self.control_files.lock_write()
1091
branches = self._read_branch_list()
1092
branches.append(utf8_name)
1093
self._write_branch_list(branches)
1095
self.control_files.unlock()
1097
self.transport.mkdir(path, mode=self._get_mkdir_mode())
1098
except errors.FileExists:
1100
return self.transport.clone(path)
1103
class BzrDirMetaComponentFormat(controldir.ControlComponentFormat):
1104
"""Base class for all formats of things living in metadirs.
1106
This class manages the format string that is stored in the 'format'
1107
or 'branch-format' file.
1109
All classes for (branch-, repository-, workingtree-) formats that
1110
live in meta directories and have their own 'format' file
1111
(i.e. different from .bzr/branch-format) derive from this class,
1112
as well as the relevant base class for their kind
1113
(BranchFormat, WorkingTreeFormat, RepositoryFormat).
1117
def get_format_string(cls):
1118
"""Return the ASCII format string that identifies this format."""
1119
raise NotImplementedError(cls.get_format_string)
1122
def from_string(cls, format_string):
1123
if format_string != cls.get_format_string():
1124
raise ValueError("Invalid format header %r" % format_string)
1128
def _find_format(klass, registry, kind, format_string):
1130
cls = registry.get(format_string)
1132
raise errors.UnknownFormatError(format=format_string, kind=kind)
1135
def network_name(self):
1136
"""A simple byte string uniquely identifying this format for RPC calls.
1138
Metadir branch formats use their format string.
1140
return self.get_format_string()
1142
def __eq__(self, other):
1143
return (self.__class__ is other.__class__)
1450
1146
class BzrProber(controldir.Prober):
1451
1147
"""Prober for formats that use a .bzr/ control directory."""
1149
formats = registry.FormatRegistry(controldir.network_format_registry)
1454
1150
"""The known .bzr formats."""
1153
@deprecated_method(deprecated_in((2, 4, 0)))
1457
1154
def register_bzrdir_format(klass, format):
1458
klass._formats[format.get_format_string()] = format
1155
klass.formats.register(format.get_format_string(), format)
1158
@deprecated_method(deprecated_in((2, 4, 0)))
1461
1159
def unregister_bzrdir_format(klass, format):
1462
del klass._formats[format.get_format_string()]
1160
klass.formats.remove(format.get_format_string())
1465
1163
def probe_transport(klass, transport):
1726
def unregister_format(klass, format):
1727
BzrProber.unregister_bzrdir_format(format)
1728
controldir.ControlDirFormat.unregister_format(format)
1729
controldir.network_format_registry.remove(format.get_format_string())
1732
class BzrDirFormat4(BzrDirFormat):
1733
"""Bzr dir format 4.
1735
This format is a combined format for working tree, branch and repository.
1737
- Format 1 working trees [always]
1738
- Format 4 branches [always]
1739
- Format 4 repositories [always]
1741
This format is deprecated: it indexes texts using a text it which is
1742
removed in format 5; write support for this format has been removed.
1745
_lock_class = lockable_files.TransportLock
1747
def get_format_string(self):
1748
"""See BzrDirFormat.get_format_string()."""
1749
return "Bazaar-NG branch, format 0.0.4\n"
1751
def get_format_description(self):
1752
"""See BzrDirFormat.get_format_description()."""
1753
return "All-in-one format 4"
1755
def get_converter(self, format=None):
1756
"""See BzrDirFormat.get_converter()."""
1757
# there is one and only one upgrade path here.
1758
return ConvertBzrDir4To5()
1760
def initialize_on_transport(self, transport):
1761
"""Format 4 branches cannot be created."""
1762
raise errors.UninitializableFormat(self)
1764
def is_supported(self):
1765
"""Format 4 is not supported.
1767
It is not supported because the model changed from 4 to 5 and the
1768
conversion logic is expensive - so doing it on the fly was not
1773
def network_name(self):
1774
return self.get_format_string()
1776
def _open(self, transport):
1777
"""See BzrDirFormat._open."""
1778
return BzrDir4(transport, self)
1780
def __return_repository_format(self):
1781
"""Circular import protection."""
1782
from bzrlib.repofmt.weaverepo import RepositoryFormat4
1783
return RepositoryFormat4()
1784
repository_format = property(__return_repository_format)
1787
class BzrDirFormatAllInOne(BzrDirFormat):
1788
"""Common class for formats before meta-dirs."""
1790
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
1791
create_prefix=False, force_new_repo=False, stacked_on=None,
1792
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
1794
"""See BzrDirFormat.initialize_on_transport_ex."""
1795
require_stacking = (stacked_on is not None)
1796
# Format 5 cannot stack, but we've been asked to - actually init
1798
if require_stacking:
1799
format = BzrDirMetaFormat1()
1800
return format.initialize_on_transport_ex(transport,
1801
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1802
force_new_repo=force_new_repo, stacked_on=stacked_on,
1803
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1804
make_working_trees=make_working_trees, shared_repo=shared_repo)
1805
return BzrDirFormat.initialize_on_transport_ex(self, transport,
1806
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1807
force_new_repo=force_new_repo, stacked_on=stacked_on,
1808
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1809
make_working_trees=make_working_trees, shared_repo=shared_repo)
1812
class BzrDirFormat5(BzrDirFormatAllInOne):
1813
"""Bzr control format 5.
1815
This format is a combined format for working tree, branch and repository.
1817
- Format 2 working trees [always]
1818
- Format 4 branches [always]
1819
- Format 5 repositories [always]
1820
Unhashed stores in the repository.
1823
_lock_class = lockable_files.TransportLock
1825
def get_format_string(self):
1826
"""See BzrDirFormat.get_format_string()."""
1827
return "Bazaar-NG branch, format 5\n"
1829
def get_branch_format(self):
1830
from bzrlib import branch
1831
return branch.BzrBranchFormat4()
1833
def get_format_description(self):
1834
"""See BzrDirFormat.get_format_description()."""
1835
return "All-in-one format 5"
1837
def get_converter(self, format=None):
1838
"""See BzrDirFormat.get_converter()."""
1839
# there is one and only one upgrade path here.
1840
return ConvertBzrDir5To6()
1842
def _initialize_for_clone(self, url):
1843
return self.initialize_on_transport(get_transport(url), _cloning=True)
1845
def initialize_on_transport(self, transport, _cloning=False):
1846
"""Format 5 dirs always have working tree, branch and repository.
1848
Except when they are being cloned.
1850
from bzrlib.branch import BzrBranchFormat4
1851
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1852
result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
1853
RepositoryFormat5().initialize(result, _internal=True)
1855
branch = BzrBranchFormat4().initialize(result)
1856
result._init_workingtree()
1859
def network_name(self):
1860
return self.get_format_string()
1862
def _open(self, transport):
1863
"""See BzrDirFormat._open."""
1864
return BzrDir5(transport, self)
1866
def __return_repository_format(self):
1867
"""Circular import protection."""
1868
from bzrlib.repofmt.weaverepo import RepositoryFormat5
1869
return RepositoryFormat5()
1870
repository_format = property(__return_repository_format)
1873
class BzrDirFormat6(BzrDirFormatAllInOne):
1874
"""Bzr control format 6.
1876
This format is a combined format for working tree, branch and repository.
1878
- Format 2 working trees [always]
1879
- Format 4 branches [always]
1880
- Format 6 repositories [always]
1883
_lock_class = lockable_files.TransportLock
1885
def get_format_string(self):
1886
"""See BzrDirFormat.get_format_string()."""
1887
return "Bazaar-NG branch, format 6\n"
1889
def get_format_description(self):
1890
"""See BzrDirFormat.get_format_description()."""
1891
return "All-in-one format 6"
1893
def get_branch_format(self):
1894
from bzrlib import branch
1895
return branch.BzrBranchFormat4()
1897
def get_converter(self, format=None):
1898
"""See BzrDirFormat.get_converter()."""
1899
# there is one and only one upgrade path here.
1900
return ConvertBzrDir6ToMeta()
1902
def _initialize_for_clone(self, url):
1903
return self.initialize_on_transport(get_transport(url), _cloning=True)
1905
def initialize_on_transport(self, transport, _cloning=False):
1906
"""Format 6 dirs always have working tree, branch and repository.
1908
Except when they are being cloned.
1910
from bzrlib.branch import BzrBranchFormat4
1911
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1912
result = super(BzrDirFormat6, self).initialize_on_transport(transport)
1913
RepositoryFormat6().initialize(result, _internal=True)
1915
branch = BzrBranchFormat4().initialize(result)
1916
result._init_workingtree()
1919
def network_name(self):
1920
return self.get_format_string()
1922
def _open(self, transport):
1923
"""See BzrDirFormat._open."""
1924
return BzrDir6(transport, self)
1926
def __return_repository_format(self):
1927
"""Circular import protection."""
1928
from bzrlib.repofmt.weaverepo import RepositoryFormat6
1929
return RepositoryFormat6()
1930
repository_format = property(__return_repository_format)
1435
def supports_transport(self, transport):
1436
# bzr formats can be opened over all known transports
1933
1440
class BzrDirMetaFormat1(BzrDirFormat):
2125
1652
def __get_workingtree_format(self):
2126
1653
if self._workingtree_format is None:
2127
from bzrlib.workingtree import WorkingTreeFormat
2128
self._workingtree_format = WorkingTreeFormat.get_default_format()
1654
from bzrlib.workingtree import (
1655
format_registry as wt_format_registry,
1657
self._workingtree_format = wt_format_registry.get_default()
2129
1658
return self._workingtree_format
2131
1660
def __set_workingtree_format(self, wt_format):
2132
1661
self._workingtree_format = wt_format
1664
return "<%r>" % (self.__class__.__name__,)
2134
1666
workingtree_format = property(__get_workingtree_format,
2135
1667
__set_workingtree_format)
2138
1670
# Register bzr formats
2139
BzrDirFormat.register_format(BzrDirFormat4())
2140
BzrDirFormat.register_format(BzrDirFormat5())
2141
BzrDirFormat.register_format(BzrDirFormat6())
2142
__default_format = BzrDirMetaFormat1()
2143
BzrDirFormat.register_format(__default_format)
2144
controldir.ControlDirFormat._default_format = __default_format
2147
class Converter(object):
2148
"""Converts a disk format object from one format to another."""
2150
def convert(self, to_convert, pb):
2151
"""Perform the conversion of to_convert, giving feedback via pb.
2153
:param to_convert: The disk object to convert.
2154
:param pb: a progress bar to use for progress information.
2157
def step(self, message):
2158
"""Update the pb by a step."""
2160
self.pb.update(message, self.count, self.total)
2163
class ConvertBzrDir4To5(Converter):
2164
"""Converts format 4 bzr dirs to format 5."""
2167
super(ConvertBzrDir4To5, self).__init__()
2168
self.converted_revs = set()
2169
self.absent_revisions = set()
2173
def convert(self, to_convert, pb):
2174
"""See Converter.convert()."""
2175
self.bzrdir = to_convert
2177
warnings.warn("pb parameter to convert() is deprecated")
2178
self.pb = ui.ui_factory.nested_progress_bar()
2180
ui.ui_factory.note('starting upgrade from format 4 to 5')
2181
if isinstance(self.bzrdir.transport, local.LocalTransport):
2182
self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2183
self._convert_to_weaves()
2184
return BzrDir.open(self.bzrdir.user_url)
2188
def _convert_to_weaves(self):
2189
ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
2192
stat = self.bzrdir.transport.stat('weaves')
2193
if not S_ISDIR(stat.st_mode):
2194
self.bzrdir.transport.delete('weaves')
2195
self.bzrdir.transport.mkdir('weaves')
2196
except errors.NoSuchFile:
2197
self.bzrdir.transport.mkdir('weaves')
2198
# deliberately not a WeaveFile as we want to build it up slowly.
2199
self.inv_weave = Weave('inventory')
2200
# holds in-memory weaves for all files
2201
self.text_weaves = {}
2202
self.bzrdir.transport.delete('branch-format')
2203
self.branch = self.bzrdir.open_branch()
2204
self._convert_working_inv()
2205
rev_history = self.branch.revision_history()
2206
# to_read is a stack holding the revisions we still need to process;
2207
# appending to it adds new highest-priority revisions
2208
self.known_revisions = set(rev_history)
2209
self.to_read = rev_history[-1:]
2211
rev_id = self.to_read.pop()
2212
if (rev_id not in self.revisions
2213
and rev_id not in self.absent_revisions):
2214
self._load_one_rev(rev_id)
2216
to_import = self._make_order()
2217
for i, rev_id in enumerate(to_import):
2218
self.pb.update('converting revision', i, len(to_import))
2219
self._convert_one_rev(rev_id)
2221
self._write_all_weaves()
2222
self._write_all_revs()
2223
ui.ui_factory.note('upgraded to weaves:')
2224
ui.ui_factory.note(' %6d revisions and inventories' % len(self.revisions))
2225
ui.ui_factory.note(' %6d revisions not present' % len(self.absent_revisions))
2226
ui.ui_factory.note(' %6d texts' % self.text_count)
2227
self._cleanup_spare_files_after_format4()
2228
self.branch._transport.put_bytes(
2230
BzrDirFormat5().get_format_string(),
2231
mode=self.bzrdir._get_file_mode())
2233
def _cleanup_spare_files_after_format4(self):
2234
# FIXME working tree upgrade foo.
2235
for n in 'merged-patches', 'pending-merged-patches':
2237
## assert os.path.getsize(p) == 0
2238
self.bzrdir.transport.delete(n)
2239
except errors.NoSuchFile:
2241
self.bzrdir.transport.delete_tree('inventory-store')
2242
self.bzrdir.transport.delete_tree('text-store')
2244
def _convert_working_inv(self):
2245
inv = xml4.serializer_v4.read_inventory(
2246
self.branch._transport.get('inventory'))
2247
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv, working=True)
2248
self.branch._transport.put_bytes('inventory', new_inv_xml,
2249
mode=self.bzrdir._get_file_mode())
2251
def _write_all_weaves(self):
2252
controlweaves = WeaveStore(self.bzrdir.transport, prefixed=False)
2253
weave_transport = self.bzrdir.transport.clone('weaves')
2254
weaves = WeaveStore(weave_transport, prefixed=False)
2255
transaction = WriteTransaction()
2259
for file_id, file_weave in self.text_weaves.items():
2260
self.pb.update('writing weave', i, len(self.text_weaves))
2261
weaves._put_weave(file_id, file_weave, transaction)
2263
self.pb.update('inventory', 0, 1)
2264
controlweaves._put_weave('inventory', self.inv_weave, transaction)
2265
self.pb.update('inventory', 1, 1)
2269
def _write_all_revs(self):
2270
"""Write all revisions out in new form."""
2271
self.bzrdir.transport.delete_tree('revision-store')
2272
self.bzrdir.transport.mkdir('revision-store')
2273
revision_transport = self.bzrdir.transport.clone('revision-store')
2275
from bzrlib.xml5 import serializer_v5
2276
from bzrlib.repofmt.weaverepo import RevisionTextStore
2277
revision_store = RevisionTextStore(revision_transport,
2278
serializer_v5, False, versionedfile.PrefixMapper(),
2279
lambda:True, lambda:True)
2281
for i, rev_id in enumerate(self.converted_revs):
2282
self.pb.update('write revision', i, len(self.converted_revs))
2283
text = serializer_v5.write_revision_to_string(
2284
self.revisions[rev_id])
2286
revision_store.add_lines(key, None, osutils.split_lines(text))
2290
def _load_one_rev(self, rev_id):
2291
"""Load a revision object into memory.
2293
Any parents not either loaded or abandoned get queued to be
2295
self.pb.update('loading revision',
2296
len(self.revisions),
2297
len(self.known_revisions))
2298
if not self.branch.repository.has_revision(rev_id):
2300
ui.ui_factory.note('revision {%s} not present in branch; '
2301
'will be converted as a ghost' %
2303
self.absent_revisions.add(rev_id)
2305
rev = self.branch.repository.get_revision(rev_id)
2306
for parent_id in rev.parent_ids:
2307
self.known_revisions.add(parent_id)
2308
self.to_read.append(parent_id)
2309
self.revisions[rev_id] = rev
2311
def _load_old_inventory(self, rev_id):
2312
f = self.branch.repository.inventory_store.get(rev_id)
2314
old_inv_xml = f.read()
2317
inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
2318
inv.revision_id = rev_id
2319
rev = self.revisions[rev_id]
2322
def _load_updated_inventory(self, rev_id):
2323
inv_xml = self.inv_weave.get_text(rev_id)
2324
inv = xml5.serializer_v5.read_inventory_from_string(inv_xml, rev_id)
2327
def _convert_one_rev(self, rev_id):
2328
"""Convert revision and all referenced objects to new format."""
2329
rev = self.revisions[rev_id]
2330
inv = self._load_old_inventory(rev_id)
2331
present_parents = [p for p in rev.parent_ids
2332
if p not in self.absent_revisions]
2333
self._convert_revision_contents(rev, inv, present_parents)
2334
self._store_new_inv(rev, inv, present_parents)
2335
self.converted_revs.add(rev_id)
2337
def _store_new_inv(self, rev, inv, present_parents):
2338
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
2339
new_inv_sha1 = sha_string(new_inv_xml)
2340
self.inv_weave.add_lines(rev.revision_id,
2342
new_inv_xml.splitlines(True))
2343
rev.inventory_sha1 = new_inv_sha1
2345
def _convert_revision_contents(self, rev, inv, present_parents):
2346
"""Convert all the files within a revision.
2348
Also upgrade the inventory to refer to the text revision ids."""
2349
rev_id = rev.revision_id
2350
mutter('converting texts of revision {%s}',
2352
parent_invs = map(self._load_updated_inventory, present_parents)
2353
entries = inv.iter_entries()
2355
for path, ie in entries:
2356
self._convert_file_version(rev, ie, parent_invs)
2358
def _convert_file_version(self, rev, ie, parent_invs):
2359
"""Convert one version of one file.
2361
The file needs to be added into the weave if it is a merge
2362
of >=2 parents or if it's changed from its parent.
2364
file_id = ie.file_id
2365
rev_id = rev.revision_id
2366
w = self.text_weaves.get(file_id)
2369
self.text_weaves[file_id] = w
2370
text_changed = False
2371
parent_candiate_entries = ie.parent_candidates(parent_invs)
2372
heads = graph.Graph(self).heads(parent_candiate_entries.keys())
2373
# XXX: Note that this is unordered - and this is tolerable because
2374
# the previous code was also unordered.
2375
previous_entries = dict((head, parent_candiate_entries[head]) for head
2377
self.snapshot_ie(previous_entries, ie, w, rev_id)
2379
def get_parent_map(self, revision_ids):
2380
"""See graph.StackedParentsProvider.get_parent_map"""
2381
return dict((revision_id, self.revisions[revision_id])
2382
for revision_id in revision_ids
2383
if revision_id in self.revisions)
2385
def snapshot_ie(self, previous_revisions, ie, w, rev_id):
2386
# TODO: convert this logic, which is ~= snapshot to
2387
# a call to:. This needs the path figured out. rather than a work_tree
2388
# a v4 revision_tree can be given, or something that looks enough like
2389
# one to give the file content to the entry if it needs it.
2390
# and we need something that looks like a weave store for snapshot to
2392
#ie.snapshot(rev, PATH, previous_revisions, REVISION_TREE, InMemoryWeaveStore(self.text_weaves))
2393
if len(previous_revisions) == 1:
2394
previous_ie = previous_revisions.values()[0]
2395
if ie._unchanged(previous_ie):
2396
ie.revision = previous_ie.revision
2399
f = self.branch.repository._text_store.get(ie.text_id)
2401
file_lines = f.readlines()
2404
w.add_lines(rev_id, previous_revisions, file_lines)
2405
self.text_count += 1
2407
w.add_lines(rev_id, previous_revisions, [])
2408
ie.revision = rev_id
2410
def _make_order(self):
2411
"""Return a suitable order for importing revisions.
2413
The order must be such that an revision is imported after all
2414
its (present) parents.
2416
todo = set(self.revisions.keys())
2417
done = self.absent_revisions.copy()
2420
# scan through looking for a revision whose parents
2422
for rev_id in sorted(list(todo)):
2423
rev = self.revisions[rev_id]
2424
parent_ids = set(rev.parent_ids)
2425
if parent_ids.issubset(done):
2426
# can take this one now
2427
order.append(rev_id)
2433
class ConvertBzrDir5To6(Converter):
2434
"""Converts format 5 bzr dirs to format 6."""
2436
def convert(self, to_convert, pb):
2437
"""See Converter.convert()."""
2438
self.bzrdir = to_convert
2439
pb = ui.ui_factory.nested_progress_bar()
2441
ui.ui_factory.note('starting upgrade from format 5 to 6')
2442
self._convert_to_prefixed()
2443
return BzrDir.open(self.bzrdir.user_url)
2447
def _convert_to_prefixed(self):
2448
from bzrlib.store import TransportStore
2449
self.bzrdir.transport.delete('branch-format')
2450
for store_name in ["weaves", "revision-store"]:
2451
ui.ui_factory.note("adding prefixes to %s" % store_name)
2452
store_transport = self.bzrdir.transport.clone(store_name)
2453
store = TransportStore(store_transport, prefixed=True)
2454
for urlfilename in store_transport.list_dir('.'):
2455
filename = urlutils.unescape(urlfilename)
2456
if (filename.endswith(".weave") or
2457
filename.endswith(".gz") or
2458
filename.endswith(".sig")):
2459
file_id, suffix = os.path.splitext(filename)
2463
new_name = store._mapper.map((file_id,)) + suffix
2464
# FIXME keep track of the dirs made RBC 20060121
2466
store_transport.move(filename, new_name)
2467
except errors.NoSuchFile: # catches missing dirs strangely enough
2468
store_transport.mkdir(osutils.dirname(new_name))
2469
store_transport.move(filename, new_name)
2470
self.bzrdir.transport.put_bytes(
2472
BzrDirFormat6().get_format_string(),
2473
mode=self.bzrdir._get_file_mode())
2476
class ConvertBzrDir6ToMeta(Converter):
2477
"""Converts format 6 bzr dirs to metadirs."""
2479
def convert(self, to_convert, pb):
2480
"""See Converter.convert()."""
2481
from bzrlib.repofmt.weaverepo import RepositoryFormat7
2482
from bzrlib.branch import BzrBranchFormat5
2483
self.bzrdir = to_convert
2484
self.pb = ui.ui_factory.nested_progress_bar()
2486
self.total = 20 # the steps we know about
2487
self.garbage_inventories = []
2488
self.dir_mode = self.bzrdir._get_dir_mode()
2489
self.file_mode = self.bzrdir._get_file_mode()
2491
ui.ui_factory.note('starting upgrade from format 6 to metadir')
2492
self.bzrdir.transport.put_bytes(
2494
"Converting to format 6",
2495
mode=self.file_mode)
2496
# its faster to move specific files around than to open and use the apis...
2497
# first off, nuke ancestry.weave, it was never used.
2499
self.step('Removing ancestry.weave')
2500
self.bzrdir.transport.delete('ancestry.weave')
2501
except errors.NoSuchFile:
2503
# find out whats there
2504
self.step('Finding branch files')
2505
last_revision = self.bzrdir.open_branch().last_revision()
2506
bzrcontents = self.bzrdir.transport.list_dir('.')
2507
for name in bzrcontents:
2508
if name.startswith('basis-inventory.'):
2509
self.garbage_inventories.append(name)
2510
# create new directories for repository, working tree and branch
2511
repository_names = [('inventory.weave', True),
2512
('revision-store', True),
2514
self.step('Upgrading repository ')
2515
self.bzrdir.transport.mkdir('repository', mode=self.dir_mode)
2516
self.make_lock('repository')
2517
# we hard code the formats here because we are converting into
2518
# the meta format. The meta format upgrader can take this to a
2519
# future format within each component.
2520
self.put_format('repository', RepositoryFormat7())
2521
for entry in repository_names:
2522
self.move_entry('repository', entry)
2524
self.step('Upgrading branch ')
2525
self.bzrdir.transport.mkdir('branch', mode=self.dir_mode)
2526
self.make_lock('branch')
2527
self.put_format('branch', BzrBranchFormat5())
2528
branch_files = [('revision-history', True),
2529
('branch-name', True),
2531
for entry in branch_files:
2532
self.move_entry('branch', entry)
2534
checkout_files = [('pending-merges', True),
2535
('inventory', True),
2536
('stat-cache', False)]
2537
# If a mandatory checkout file is not present, the branch does not have
2538
# a functional checkout. Do not create a checkout in the converted
2540
for name, mandatory in checkout_files:
2541
if mandatory and name not in bzrcontents:
2542
has_checkout = False
2546
if not has_checkout:
2547
ui.ui_factory.note('No working tree.')
2548
# If some checkout files are there, we may as well get rid of them.
2549
for name, mandatory in checkout_files:
2550
if name in bzrcontents:
2551
self.bzrdir.transport.delete(name)
2553
from bzrlib.workingtree import WorkingTreeFormat3
2554
self.step('Upgrading working tree')
2555
self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
2556
self.make_lock('checkout')
2558
'checkout', WorkingTreeFormat3())
2559
self.bzrdir.transport.delete_multi(
2560
self.garbage_inventories, self.pb)
2561
for entry in checkout_files:
2562
self.move_entry('checkout', entry)
2563
if last_revision is not None:
2564
self.bzrdir.transport.put_bytes(
2565
'checkout/last-revision', last_revision)
2566
self.bzrdir.transport.put_bytes(
2568
BzrDirMetaFormat1().get_format_string(),
2569
mode=self.file_mode)
2571
return BzrDir.open(self.bzrdir.user_url)
2573
def make_lock(self, name):
2574
"""Make a lock for the new control dir name."""
2575
self.step('Make %s lock' % name)
2576
ld = lockdir.LockDir(self.bzrdir.transport,
2578
file_modebits=self.file_mode,
2579
dir_modebits=self.dir_mode)
2582
def move_entry(self, new_dir, entry):
2583
"""Move then entry name into new_dir."""
2585
mandatory = entry[1]
2586
self.step('Moving %s' % name)
2588
self.bzrdir.transport.move(name, '%s/%s' % (new_dir, name))
2589
except errors.NoSuchFile:
2593
def put_format(self, dirname, format):
2594
self.bzrdir.transport.put_bytes('%s/format' % dirname,
2595
format.get_format_string(),
2599
class ConvertMetaToMeta(Converter):
1671
BzrProber.formats.register(BzrDirMetaFormat1.get_format_string(),
1673
controldir.ControlDirFormat._default_format = BzrDirMetaFormat1()
1676
class BzrDirMetaFormat1Colo(BzrDirMetaFormat1):
1677
"""BzrDirMeta1 format with support for colocated branches."""
1679
colocated_branches = True
1682
def get_format_string(cls):
1683
"""See BzrDirFormat.get_format_string()."""
1684
return "Bazaar meta directory, format 1 (with colocated branches)\n"
1686
def get_format_description(self):
1687
"""See BzrDirFormat.get_format_description()."""
1688
return "Meta directory format 1 with support for colocated branches"
1690
def _open(self, transport):
1691
"""See BzrDirFormat._open."""
1692
# Create a new format instance because otherwise initialisation of new
1693
# metadirs share the global default format object leading to alias
1695
format = BzrDirMetaFormat1Colo()
1696
self._supply_sub_formats_to(format)
1697
return BzrDirMeta1Colo(transport, format)
1700
BzrProber.formats.register(BzrDirMetaFormat1Colo.get_format_string(),
1701
BzrDirMetaFormat1Colo)
1704
class ConvertMetaToMeta(controldir.Converter):
2600
1705
"""Converts the components of metadirs."""
2602
1707
def __init__(self, target_format):
2675
1779
return to_convert
2678
# This is not in remote.py because it's relatively small, and needs to be
2679
# registered. Putting it in remote.py creates a circular import problem.
2680
# we can make it a lazy object if the control formats is turned into something
2682
class RemoteBzrDirFormat(BzrDirMetaFormat1):
2683
"""Format representing bzrdirs accessed via a smart server"""
2685
supports_workingtrees = False
2688
BzrDirMetaFormat1.__init__(self)
2689
# XXX: It's a bit ugly that the network name is here, because we'd
2690
# like to believe that format objects are stateless or at least
2691
# immutable, However, we do at least avoid mutating the name after
2692
# it's returned. See <https://bugs.launchpad.net/bzr/+bug/504102>
2693
self._network_name = None
2696
return "%s(_network_name=%r)" % (self.__class__.__name__,
2699
def get_format_description(self):
2700
if self._network_name:
2701
real_format = controldir.network_format_registry.get(self._network_name)
2702
return 'Remote: ' + real_format.get_format_description()
2703
return 'bzr remote bzrdir'
2705
def get_format_string(self):
2706
raise NotImplementedError(self.get_format_string)
2708
def network_name(self):
2709
if self._network_name:
2710
return self._network_name
2712
raise AssertionError("No network name set.")
2714
def initialize_on_transport(self, transport):
2716
# hand off the request to the smart server
2717
client_medium = transport.get_smart_medium()
2718
except errors.NoSmartMedium:
2719
# TODO: lookup the local format from a server hint.
2720
local_dir_format = BzrDirMetaFormat1()
2721
return local_dir_format.initialize_on_transport(transport)
2722
client = _SmartClient(client_medium)
2723
path = client.remote_path_from_transport(transport)
2725
response = client.call('BzrDirFormat.initialize', path)
2726
except errors.ErrorFromSmartServer, err:
2727
remote._translate_error(err, path=path)
2728
if response[0] != 'ok':
2729
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2730
format = RemoteBzrDirFormat()
2731
self._supply_sub_formats_to(format)
2732
return remote.RemoteBzrDir(transport, format)
2734
def parse_NoneTrueFalse(self, arg):
2741
raise AssertionError("invalid arg %r" % arg)
2743
def _serialize_NoneTrueFalse(self, arg):
2750
def _serialize_NoneString(self, arg):
2753
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
2754
create_prefix=False, force_new_repo=False, stacked_on=None,
2755
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
2758
# hand off the request to the smart server
2759
client_medium = transport.get_smart_medium()
2760
except errors.NoSmartMedium:
2763
# Decline to open it if the server doesn't support our required
2764
# version (3) so that the VFS-based transport will do it.
2765
if client_medium.should_probe():
2767
server_version = client_medium.protocol_version()
2768
if server_version != '2':
2772
except errors.SmartProtocolError:
2773
# Apparently there's no usable smart server there, even though
2774
# the medium supports the smart protocol.
2779
client = _SmartClient(client_medium)
2780
path = client.remote_path_from_transport(transport)
2781
if client_medium._is_remote_before((1, 16)):
2784
# TODO: lookup the local format from a server hint.
2785
local_dir_format = BzrDirMetaFormat1()
2786
self._supply_sub_formats_to(local_dir_format)
2787
return local_dir_format.initialize_on_transport_ex(transport,
2788
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2789
force_new_repo=force_new_repo, stacked_on=stacked_on,
2790
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2791
make_working_trees=make_working_trees, shared_repo=shared_repo,
2793
return self._initialize_on_transport_ex_rpc(client, path, transport,
2794
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2795
stack_on_pwd, repo_format_name, make_working_trees, shared_repo)
2797
def _initialize_on_transport_ex_rpc(self, client, path, transport,
2798
use_existing_dir, create_prefix, force_new_repo, stacked_on,
2799
stack_on_pwd, repo_format_name, make_working_trees, shared_repo):
2801
args.append(self._serialize_NoneTrueFalse(use_existing_dir))
2802
args.append(self._serialize_NoneTrueFalse(create_prefix))
2803
args.append(self._serialize_NoneTrueFalse(force_new_repo))
2804
args.append(self._serialize_NoneString(stacked_on))
2805
# stack_on_pwd is often/usually our transport
2808
stack_on_pwd = transport.relpath(stack_on_pwd)
2809
if not stack_on_pwd:
2811
except errors.PathNotChild:
2813
args.append(self._serialize_NoneString(stack_on_pwd))
2814
args.append(self._serialize_NoneString(repo_format_name))
2815
args.append(self._serialize_NoneTrueFalse(make_working_trees))
2816
args.append(self._serialize_NoneTrueFalse(shared_repo))
2817
request_network_name = self._network_name or \
2818
BzrDirFormat.get_default_format().network_name()
2820
response = client.call('BzrDirFormat.initialize_ex_1.16',
2821
request_network_name, path, *args)
2822
except errors.UnknownSmartMethod:
2823
client._medium._remember_remote_is_before((1,16))
2824
local_dir_format = BzrDirMetaFormat1()
2825
self._supply_sub_formats_to(local_dir_format)
2826
return local_dir_format.initialize_on_transport_ex(transport,
2827
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2828
force_new_repo=force_new_repo, stacked_on=stacked_on,
2829
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2830
make_working_trees=make_working_trees, shared_repo=shared_repo,
2832
except errors.ErrorFromSmartServer, err:
2833
remote._translate_error(err, path=path)
2834
repo_path = response[0]
2835
bzrdir_name = response[6]
2836
require_stacking = response[7]
2837
require_stacking = self.parse_NoneTrueFalse(require_stacking)
2838
format = RemoteBzrDirFormat()
2839
format._network_name = bzrdir_name
2840
self._supply_sub_formats_to(format)
2841
bzrdir = remote.RemoteBzrDir(transport, format, _client=client)
2843
repo_format = remote.response_tuple_to_repo_format(response[1:])
2844
if repo_path == '.':
2847
repo_bzrdir_format = RemoteBzrDirFormat()
2848
repo_bzrdir_format._network_name = response[5]
2849
repo_bzr = remote.RemoteBzrDir(transport.clone(repo_path),
2853
final_stack = response[8] or None
2854
final_stack_pwd = response[9] or None
2856
final_stack_pwd = urlutils.join(
2857
transport.base, final_stack_pwd)
2858
remote_repo = remote.RemoteRepository(repo_bzr, repo_format)
2859
if len(response) > 10:
2860
# Updated server verb that locks remotely.
2861
repo_lock_token = response[10] or None
2862
remote_repo.lock_write(repo_lock_token, _skip_rpc=True)
2864
remote_repo.dont_leave_lock_in_place()
2866
remote_repo.lock_write()
2867
policy = UseExistingRepository(remote_repo, final_stack,
2868
final_stack_pwd, require_stacking)
2869
policy.acquire_repository()
2873
bzrdir._format.set_branch_format(self.get_branch_format())
2874
if require_stacking:
2875
# The repo has already been created, but we need to make sure that
2876
# we'll make a stackable branch.
2877
bzrdir._format.require_stacking(_skip_repo=True)
2878
return remote_repo, bzrdir, require_stacking, policy
2880
def _open(self, transport):
2881
return remote.RemoteBzrDir(transport, self)
2883
def __eq__(self, other):
2884
if not isinstance(other, RemoteBzrDirFormat):
2886
return self.get_format_description() == other.get_format_description()
2888
def __return_repository_format(self):
2889
# Always return a RemoteRepositoryFormat object, but if a specific bzr
2890
# repository format has been asked for, tell the RemoteRepositoryFormat
2891
# that it should use that for init() etc.
2892
result = remote.RemoteRepositoryFormat()
2893
custom_format = getattr(self, '_repository_format', None)
2895
if isinstance(custom_format, remote.RemoteRepositoryFormat):
2896
return custom_format
2898
# We will use the custom format to create repositories over the
2899
# wire; expose its details like rich_root_data for code to
2901
result._custom_format = custom_format
2904
def get_branch_format(self):
2905
result = BzrDirMetaFormat1.get_branch_format(self)
2906
if not isinstance(result, remote.RemoteBranchFormat):
2907
new_result = remote.RemoteBranchFormat()
2908
new_result._custom_format = result
2910
self.set_branch_format(new_result)
2914
repository_format = property(__return_repository_format,
2915
BzrDirMetaFormat1._set_repository_format) #.im_func)
1782
class ConvertMetaToColo(controldir.Converter):
1783
"""Add colocated branch support."""
1785
def __init__(self, target_format):
1786
"""Create a converter.that upgrades a metadir to the colo format.
1788
:param target_format: The final metadir format that is desired.
1790
self.target_format = target_format
1792
def convert(self, to_convert, pb):
1793
"""See Converter.convert()."""
1794
to_convert.transport.put_bytes('branch-format',
1795
self.target_format.get_format_string())
1796
return BzrDir.open_from_transport(to_convert.root_transport)
1799
class ConvertMetaRemoveColo(controldir.Converter):
1800
"""Remove colocated branch support from a bzrdir."""
1802
def __init__(self, target_format):
1803
"""Create a converter.that downgrades a colocated branch metadir
1804
to a regular metadir.
1806
:param target_format: The final metadir format that is desired.
1808
self.target_format = target_format
1810
def convert(self, to_convert, pb):
1811
"""See Converter.convert()."""
1812
to_convert.control_files.lock_write()
1814
branches = to_convert.list_branches()
1815
if len(branches) > 1:
1816
raise errors.BzrError("remove all but a single "
1817
"colocated branch when downgrading")
1819
to_convert.control_files.unlock()
1820
to_convert.transport.put_bytes('branch-format',
1821
self.target_format.get_format_string())
1822
return BzrDir.open_from_transport(to_convert.root_transport)
2918
1825
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
3119
2042
registry.register(key, helper, help, native, deprecated, hidden,
3120
2043
experimental, alias)
3122
# The pre-0.8 formats have their repository format network name registered in
3123
# repository.py. MetaDir formats have their repository format network name
3124
# inferred from their disk format string.
3125
controldir.format_registry.register('weave', BzrDirFormat6,
3126
'Pre-0.8 format. Slower than knit and does not'
3127
' support checkouts or shared repositories.',
3130
register_metadir(controldir.format_registry, 'metaweave',
3131
'bzrlib.repofmt.weaverepo.RepositoryFormat7',
3132
'Transitional format in 0.8. Slower than knit.',
3133
branch_format='bzrlib.branch.BzrBranchFormat5',
3134
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3137
2045
register_metadir(controldir.format_registry, 'knit',
3138
2046
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3139
2047
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
3140
2048
branch_format='bzrlib.branch.BzrBranchFormat5',
3141
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
2049
tree_format='bzrlib.workingtree_3.WorkingTreeFormat3',
3143
2051
deprecated=True)
3144
2052
register_metadir(controldir.format_registry, 'dirstate',
3145
2053
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3146
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
3147
'above when accessed over the network.',
2054
help='Format using dirstate for working trees. '
2055
'Compatible with bzr 0.8 and '
2056
'above when accessed over the network. Introduced in bzr 0.15.',
3148
2057
branch_format='bzrlib.branch.BzrBranchFormat5',
3149
# this uses bzrlib.workingtree.WorkingTreeFormat4 because importing
3150
# directly from workingtree_4 triggers a circular import.
3151
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2058
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3153
2060
deprecated=True)
3154
2061
register_metadir(controldir.format_registry, 'dirstate-tags',
3155
2062
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3156
help='New in 0.15: Fast local operations and improved scaling for '
3157
'network operations. Additionally adds support for tags.'
3158
' Incompatible with bzr < 0.15.',
2063
help='Variant of dirstate with support for tags. '
2064
'Introduced in bzr 0.15.',
3159
2065
branch_format='bzrlib.branch.BzrBranchFormat6',
3160
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2066
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3162
2068
deprecated=True)
3163
2069
register_metadir(controldir.format_registry, 'rich-root',
3164
2070
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4',
3165
help='New in 1.0. Better handling of tree roots. Incompatible with'
2071
help='Variant of dirstate with better handling of tree roots. '
2072
'Introduced in bzr 1.0',
3167
2073
branch_format='bzrlib.branch.BzrBranchFormat6',
3168
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2074
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3170
2076
deprecated=True)
3171
2077
register_metadir(controldir.format_registry, 'dirstate-with-subtree',
3172
2078
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
3173
help='New in 0.15: Fast local operations and improved scaling for '
3174
'network operations. Additionally adds support for versioning nested '
3175
'bzr branches. Incompatible with bzr < 0.15.',
2079
help='Variant of dirstate with support for nested trees. '
2080
'Introduced in 0.15.',
3176
2081
branch_format='bzrlib.branch.BzrBranchFormat6',
3177
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2082
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3178
2083
experimental=True,
3181
2086
register_metadir(controldir.format_registry, 'pack-0.92',
3182
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
3183
help='New in 0.92: Pack-based format with data compatible with '
3184
'dirstate-tags format repositories. Interoperates with '
3185
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2087
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack1',
2088
help='Pack-based format used in 1.x series. Introduced in 0.92. '
2089
'Interoperates with bzr repositories before 0.92 but cannot be '
2090
'read by bzr < 0.92. '
3187
2092
branch_format='bzrlib.branch.BzrBranchFormat6',
3188
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2093
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3190
2096
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
3191
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
3192
help='New in 0.92: Pack-based format with data compatible with '
3193
'dirstate-with-subtree format repositories. Interoperates with '
2097
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack3',
2098
help='Pack-based format used in 1.x series, with subtree support. '
2099
'Introduced in 0.92. Interoperates with '
3194
2100
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3196
2102
branch_format='bzrlib.branch.BzrBranchFormat6',
3197
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2103
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3199
2106
experimental=True,
3201
2108
register_metadir(controldir.format_registry, 'rich-root-pack',
3202
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3203
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
3204
'(needed for bzr-svn and bzr-git).',
2109
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack4',
2110
help='A variant of pack-0.92 that supports rich-root data '
2111
'(needed for bzr-svn and bzr-git). Introduced in 1.0.',
3205
2112
branch_format='bzrlib.branch.BzrBranchFormat6',
3206
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2113
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3209
2117
register_metadir(controldir.format_registry, '1.6',
3210
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
2118
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5',
3211
2119
help='A format that allows a branch to indicate that there is another '
3212
2120
'(stacked) repository that should be used to access data that is '
3213
2121
'not present locally.',
3214
2122
branch_format='bzrlib.branch.BzrBranchFormat7',
3215
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2123
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3218
2127
register_metadir(controldir.format_registry, '1.6.1-rich-root',
3219
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
2128
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack5RichRoot',
3220
2129
help='A variant of 1.6 that supports rich-root data '
3221
2130
'(needed for bzr-svn and bzr-git).',
3222
2131
branch_format='bzrlib.branch.BzrBranchFormat7',
3223
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2132
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3226
2136
register_metadir(controldir.format_registry, '1.9',
3227
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2137
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3228
2138
help='A repository format using B+tree indexes. These indexes '
3229
2139
'are smaller in size, have smarter caching and provide faster '
3230
2140
'performance for most operations.',
3231
2141
branch_format='bzrlib.branch.BzrBranchFormat7',
3232
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2142
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3235
2146
register_metadir(controldir.format_registry, '1.9-rich-root',
3236
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2147
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3237
2148
help='A variant of 1.9 that supports rich-root data '
3238
2149
'(needed for bzr-svn and bzr-git).',
3239
2150
branch_format='bzrlib.branch.BzrBranchFormat7',
3240
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2151
tree_format='bzrlib.workingtree_4.WorkingTreeFormat4',
3243
2155
register_metadir(controldir.format_registry, '1.14',
3244
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
2156
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6',
3245
2157
help='A working-tree format that supports content filtering.',
3246
2158
branch_format='bzrlib.branch.BzrBranchFormat7',
3247
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2159
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3249
2163
register_metadir(controldir.format_registry, '1.14-rich-root',
3250
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
2164
'bzrlib.repofmt.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
3251
2165
help='A variant of 1.14 that supports rich-root data '
3252
2166
'(needed for bzr-svn and bzr-git).',
3253
2167
branch_format='bzrlib.branch.BzrBranchFormat7',
3254
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
2168
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3256
2172
# The following un-numbered 'development' formats should always just be aliases.
3257
register_metadir(controldir.format_registry, 'development-rich-root',
3258
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3259
help='Current development format. Supports rich roots. Can convert data '
3260
'to and from rich-root-pack (and anything compatible with '
3261
'rich-root-pack) format repositories. Repositories and branches in '
3262
'this format can only be read by bzr.dev. Please read '
3263
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3265
branch_format='bzrlib.branch.BzrBranchFormat7',
3266
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3271
register_metadir(controldir.format_registry, 'development5-subtree',
3272
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3273
help='Development format, subtree variant. Can convert data to and '
3274
'from pack-0.92-subtree (and anything compatible with '
3275
'pack-0.92-subtree) format repositories. Repositories and branches in '
3276
'this format can only be read by bzr.dev. Please read '
3277
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3279
branch_format='bzrlib.branch.BzrBranchFormat7',
3280
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3287
2173
register_metadir(controldir.format_registry, 'development-subtree',
3288
2174
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2aSubtree',
3289
2175
help='Current development format, subtree variant. Can convert data to and '