562
496
format=format).bzrdir
563
497
return bzrdir.create_workingtree()
565
def create_workingtree(self, revision_id=None, from_branch=None,
566
accelerator_tree=None, hardlink=False):
567
"""Create a working tree at this BzrDir.
569
:param revision_id: create it as of this revision id.
570
:param from_branch: override bzrdir branch (for lightweight checkouts)
571
:param accelerator_tree: A tree which can be used for retrieving file
572
contents more quickly than the revision tree, i.e. a workingtree.
573
The revision tree will be used for cases where accelerator_tree's
574
content is different.
576
raise NotImplementedError(self.create_workingtree)
499
def generate_backup_name(self, base):
500
"""Generate a non-existing backup file name based on base."""
502
name = "%s.~%d~" % (base, counter)
503
while self.root_transport.has(name):
505
name = "%s.~%d~" % (base, counter)
578
508
def backup_bzrdir(self):
579
509
"""Backup this bzr control directory.
581
511
:return: Tuple with old path name and new path name
514
backup_dir=self.generate_backup_name('backup.bzr')
583
515
pb = ui.ui_factory.nested_progress_bar()
585
517
# FIXME: bug 300001 -- the backup fails if the backup directory
586
518
# already exists, but it should instead either remove it or make
587
519
# a new backup directory.
589
# FIXME: bug 262450 -- the backup directory should have the same
590
# permissions as the .bzr directory (probably a bug in copy_tree)
591
521
old_path = self.root_transport.abspath('.bzr')
592
new_path = self.root_transport.abspath('backup.bzr')
522
new_path = self.root_transport.abspath(backup_dir)
593
523
ui.ui_factory.note('making backup of %s\n to %s' % (old_path, new_path,))
594
self.root_transport.copy_tree('.bzr', 'backup.bzr')
524
self.root_transport.copy_tree('.bzr', backup_dir)
595
525
return (old_path, new_path)
1003
841
raise errors.NotBranchError(location)
1004
842
return tree, branch, branch.repository, relpath
1006
def open_repository(self, _unsupported=False):
1007
"""Open the repository object at this BzrDir if one is present.
1009
This will not follow the Branch object pointer - it's strictly a direct
1010
open facility. Most client code should use open_branch().repository to
1011
get at a repository.
1013
:param _unsupported: a private parameter, not part of the api.
1014
TODO: static convenience version of this?
1016
raise NotImplementedError(self.open_repository)
1018
def open_workingtree(self, _unsupported=False,
1019
recommend_upgrade=True, from_branch=None):
1020
"""Open the workingtree object at this BzrDir if one is present.
1022
:param recommend_upgrade: Optional keyword parameter, when True (the
1023
default), emit through the ui module a recommendation that the user
1024
upgrade the working tree when the workingtree being opened is old
1025
(but still fully supported).
1026
:param from_branch: override bzrdir branch (for lightweight checkouts)
1028
raise NotImplementedError(self.open_workingtree)
1030
def has_branch(self):
1031
"""Tell if this bzrdir contains a branch.
1033
Note: if you're going to open the branch, you should just go ahead
1034
and try, and not ask permission first. (This method just opens the
1035
branch and discards it, and that's somewhat expensive.)
1040
except errors.NotBranchError:
1043
def has_workingtree(self):
1044
"""Tell if this bzrdir contains a working tree.
1046
This will still raise an exception if the bzrdir has a workingtree that
1047
is remote & inaccessible.
1049
Note: if you're going to open the working tree, you should just go ahead
1050
and try, and not ask permission first. (This method just opens the
1051
workingtree and discards it, and that's somewhat expensive.)
1054
self.open_workingtree(recommend_upgrade=False)
1056
except errors.NoWorkingTree:
1059
844
def _cloning_metadir(self):
1060
845
"""Produce a metadir suitable for cloning with.
1119
904
format.require_stacking()
1122
def checkout_metadir(self):
1123
return self.cloning_metadir()
1125
def sprout(self, url, revision_id=None, force_new_repo=False,
1126
recurse='down', possible_transports=None,
1127
accelerator_tree=None, hardlink=False, stacked=False,
1128
source_branch=None, create_tree_if_local=True):
1129
"""Create a copy of this bzrdir prepared for use as a new line of
1132
If url's last component does not exist, it will be created.
1134
Attributes related to the identity of the source branch like
1135
branch nickname will be cleaned, a working tree is created
1136
whether one existed before or not; and a local branch is always
1139
if revision_id is not None, then the clone operation may tune
1140
itself to download less data.
1141
:param accelerator_tree: A tree which can be used for retrieving file
1142
contents more quickly than the revision tree, i.e. a workingtree.
1143
The revision tree will be used for cases where accelerator_tree's
1144
content is different.
1145
:param hardlink: If true, hard-link files from accelerator_tree,
1147
:param stacked: If true, create a stacked branch referring to the
1148
location of this control directory.
1149
:param create_tree_if_local: If true, a working-tree will be created
1150
when working locally.
908
def create(cls, base, format=None, possible_transports=None):
909
"""Create a new BzrDir at the url 'base'.
911
:param format: If supplied, the format of branch to create. If not
912
supplied, the default is used.
913
:param possible_transports: If supplied, a list of transports that
914
can be reused to share a remote connection.
1152
target_transport = get_transport(url, possible_transports)
1153
target_transport.ensure_base()
1154
cloning_format = self.cloning_metadir(stacked)
1155
# Create/update the result branch
1156
result = cloning_format.initialize_on_transport(target_transport)
1157
# if a stacked branch wasn't requested, we don't create one
1158
# even if the origin was stacked
1159
stacked_branch_url = None
1160
if source_branch is not None:
1162
stacked_branch_url = self.root_transport.base
1163
source_repository = source_branch.repository
1166
source_branch = self.open_branch()
1167
source_repository = source_branch.repository
1169
stacked_branch_url = self.root_transport.base
1170
except errors.NotBranchError:
1171
source_branch = None
1173
source_repository = self.open_repository()
1174
except errors.NoRepositoryPresent:
1175
source_repository = None
1176
repository_policy = result.determine_repository_policy(
1177
force_new_repo, stacked_branch_url, require_stacking=stacked)
1178
result_repo, is_new_repo = repository_policy.acquire_repository()
1179
if is_new_repo and revision_id is not None and not stacked:
1180
fetch_spec = graph.PendingAncestryResult(
1181
[revision_id], source_repository)
1184
if source_repository is not None:
1185
# Fetch while stacked to prevent unstacked fetch from
1187
if fetch_spec is None:
1188
result_repo.fetch(source_repository, revision_id=revision_id)
1190
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
1192
if source_branch is None:
1193
# this is for sprouting a bzrdir without a branch; is that
1195
# Not especially, but it's part of the contract.
1196
result_branch = result.create_branch()
1198
result_branch = source_branch.sprout(result,
1199
revision_id=revision_id, repository_policy=repository_policy)
1200
mutter("created new branch %r" % (result_branch,))
1202
# Create/update the result working tree
1203
if (create_tree_if_local and
1204
isinstance(target_transport, local.LocalTransport) and
1205
(result_repo is None or result_repo.make_working_trees())):
1206
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
1210
if wt.path2id('') is None:
1212
wt.set_root_id(self.open_workingtree.get_root_id())
1213
except errors.NoWorkingTree:
1219
if recurse == 'down':
1221
basis = wt.basis_tree()
1223
subtrees = basis.iter_references()
1224
elif result_branch is not None:
1225
basis = result_branch.basis_tree()
1227
subtrees = basis.iter_references()
1228
elif source_branch is not None:
1229
basis = source_branch.basis_tree()
1231
subtrees = basis.iter_references()
1236
for path, file_id in subtrees:
1237
target = urlutils.join(url, urlutils.escape(path))
1238
sublocation = source_branch.reference_parent(file_id, path)
1239
sublocation.bzrdir.sprout(target,
1240
basis.get_reference_revision(file_id, path),
1241
force_new_repo=force_new_repo, recurse=recurse,
1244
if basis is not None:
1248
def push_branch(self, source, revision_id=None, overwrite=False,
1249
remember=False, create_prefix=False):
1250
"""Push the source branch into this BzrDir."""
1252
# If we can open a branch, use its direct repository, otherwise see
1253
# if there is a repository without a branch.
1255
br_to = self.open_branch()
1256
except errors.NotBranchError:
1257
# Didn't find a branch, can we find a repository?
1258
repository_to = self.find_repository()
1260
# Found a branch, so we must have found a repository
1261
repository_to = br_to.repository
1263
push_result = PushResult()
1264
push_result.source_branch = source
1266
# We have a repository but no branch, copy the revisions, and then
1268
repository_to.fetch(source.repository, revision_id=revision_id)
1269
br_to = source.clone(self, revision_id=revision_id)
1270
if source.get_push_location() is None or remember:
1271
source.set_push_location(br_to.base)
1272
push_result.stacked_on = None
1273
push_result.branch_push_result = None
1274
push_result.old_revno = None
1275
push_result.old_revid = _mod_revision.NULL_REVISION
1276
push_result.target_branch = br_to
1277
push_result.master_branch = None
1278
push_result.workingtree_updated = False
1280
# We have successfully opened the branch, remember if necessary:
1281
if source.get_push_location() is None or remember:
1282
source.set_push_location(br_to.base)
1284
tree_to = self.open_workingtree()
1285
except errors.NotLocalUrl:
1286
push_result.branch_push_result = source.push(br_to,
1287
overwrite, stop_revision=revision_id)
1288
push_result.workingtree_updated = False
1289
except errors.NoWorkingTree:
1290
push_result.branch_push_result = source.push(br_to,
1291
overwrite, stop_revision=revision_id)
1292
push_result.workingtree_updated = None # Not applicable
1294
tree_to.lock_write()
1296
push_result.branch_push_result = source.push(
1297
tree_to.branch, overwrite, stop_revision=revision_id)
1301
push_result.workingtree_updated = True
1302
push_result.old_revno = push_result.branch_push_result.old_revno
1303
push_result.old_revid = push_result.branch_push_result.old_revid
1304
push_result.target_branch = \
1305
push_result.branch_push_result.target_branch
916
if cls is not BzrDir:
917
raise AssertionError("BzrDir.create always creates the"
918
"default format, not one of %r" % cls)
919
t = get_transport(base, possible_transports)
922
format = controldir.ControlDirFormat.get_default_format()
923
return format.initialize_on_transport(t)
1309
927
class BzrDirHooks(hooks.Hooks):
1315
933
self.create_hook(hooks.HookPoint('pre_open',
1316
934
"Invoked before attempting to open a BzrDir with the transport "
1317
935
"that the open will use.", (1, 14), None))
936
self.create_hook(hooks.HookPoint('post_repo_init',
937
"Invoked after a repository has been initialized. "
938
"post_repo_init is called with a "
939
"bzrlib.bzrdir.RepoInitHookParams.",
1319
942
# install the default hooks
1320
943
BzrDir.hooks = BzrDirHooks()
946
class RepoInitHookParams(object):
947
"""Object holding parameters passed to *_repo_init hooks.
949
There are 4 fields that hooks may wish to access:
951
:ivar repository: Repository created
952
:ivar format: Repository format
953
:ivar bzrdir: The bzrdir for the repository
954
:ivar shared: The repository is shared
957
def __init__(self, repository, format, a_bzrdir, shared):
958
"""Create a group of RepoInitHook parameters.
960
:param repository: Repository created
961
:param format: Repository format
962
:param bzrdir: The bzrdir for the repository
963
:param shared: The repository is shared
965
self.repository = repository
967
self.bzrdir = a_bzrdir
970
def __eq__(self, other):
971
return self.__dict__ == other.__dict__
975
return "<%s for %s>" % (self.__class__.__name__,
978
return "<%s for %s>" % (self.__class__.__name__,
1323
982
class BzrDirPreSplitOut(BzrDir):
1324
983
"""A common class for the all-in-one formats."""
1774
1440
return config.TransportConfig(self.transport, 'control.conf')
1777
class BzrDirFormat(object):
1778
"""An encapsulation of the initialization and open routines for a format.
1780
Formats provide three things:
1781
* An initialization routine,
1443
class BzrProber(controldir.Prober):
1444
"""Prober for formats that use a .bzr/ control directory."""
1447
"""The known .bzr formats."""
1450
def register_bzrdir_format(klass, format):
1451
klass._formats[format.get_format_string()] = format
1454
def unregister_bzrdir_format(klass, format):
1455
del klass._formats[format.get_format_string()]
1458
def probe_transport(klass, transport):
1459
"""Return the .bzrdir style format present in a directory."""
1461
format_string = transport.get_bytes(".bzr/branch-format")
1462
except errors.NoSuchFile:
1463
raise errors.NotBranchError(path=transport.base)
1465
return klass._formats[format_string]
1467
raise errors.UnknownFormatError(format=format_string, kind='bzrdir')
1470
controldir.ControlDirFormat.register_prober(BzrProber)
1473
class RemoteBzrProber(controldir.Prober):
1474
"""Prober for remote servers that provide a Bazaar smart server."""
1477
def probe_transport(klass, transport):
1478
"""Return a RemoteBzrDirFormat object if it looks possible."""
1480
medium = transport.get_smart_medium()
1481
except (NotImplementedError, AttributeError,
1482
errors.TransportNotPossible, errors.NoSmartMedium,
1483
errors.SmartProtocolError):
1484
# no smart server, so not a branch for this format type.
1485
raise errors.NotBranchError(path=transport.base)
1487
# Decline to open it if the server doesn't support our required
1488
# version (3) so that the VFS-based transport will do it.
1489
if medium.should_probe():
1491
server_version = medium.protocol_version()
1492
except errors.SmartProtocolError:
1493
# Apparently there's no usable smart server there, even though
1494
# the medium supports the smart protocol.
1495
raise errors.NotBranchError(path=transport.base)
1496
if server_version != '2':
1497
raise errors.NotBranchError(path=transport.base)
1498
return RemoteBzrDirFormat()
1501
class BzrDirFormat(controldir.ControlDirFormat):
1502
"""ControlDirFormat base class for .bzr/ directories.
1785
1504
Formats are placed in a dict by their format string for reference
1786
1505
during bzrdir opening. These should be subclasses of BzrDirFormat
1791
1510
object will be created every system load.
1794
_default_format = None
1795
"""The default format used for new .bzr dirs."""
1798
"""The known formats."""
1800
_control_formats = []
1801
"""The registered control formats - .bzr, ....
1803
This is a list of BzrDirFormat objects.
1806
_control_server_formats = []
1807
"""The registered control server formats, e.g. RemoteBzrDirs.
1809
This is a list of BzrDirFormat objects.
1812
1513
_lock_file_name = 'branch-lock'
1814
1515
# _lock_class must be set in subclasses to the lock type, typ.
1815
1516
# TransportLock or LockDir
1818
def find_format(klass, transport, _server_formats=True):
1819
"""Return the format present at transport."""
1821
formats = klass._control_server_formats + klass._control_formats
1823
formats = klass._control_formats
1824
for format in formats:
1826
return format.probe_transport(transport)
1827
except errors.NotBranchError:
1828
# this format does not find a control dir here.
1830
raise errors.NotBranchError(path=transport.base)
1833
def probe_transport(klass, transport):
1834
"""Return the .bzrdir style format present in a directory."""
1836
format_string = transport.get_bytes(".bzr/branch-format")
1837
except errors.NoSuchFile:
1838
raise errors.NotBranchError(path=transport.base)
1841
return klass._formats[format_string]
1843
raise errors.UnknownFormatError(format=format_string, kind='bzrdir')
1846
def get_default_format(klass):
1847
"""Return the current default format."""
1848
return klass._default_format
1850
1518
def get_format_string(self):
1851
1519
"""Return the ASCII format string that identifies this format."""
1852
1520
raise NotImplementedError(self.get_format_string)
1854
def get_format_description(self):
1855
"""Return the short description for this format."""
1856
raise NotImplementedError(self.get_format_description)
1858
def get_converter(self, format=None):
1859
"""Return the converter to use to convert bzrdirs needing converts.
1861
This returns a bzrlib.bzrdir.Converter object.
1863
This should return the best upgrader to step this format towards the
1864
current default format. In the case of plugins we can/should provide
1865
some means for them to extend the range of returnable converters.
1867
:param format: Optional format to override the default format of the
1870
raise NotImplementedError(self.get_converter)
1872
def initialize(self, url, possible_transports=None):
1873
"""Create a bzr control dir at this url and return an opened copy.
1875
While not deprecated, this method is very specific and its use will
1876
lead to many round trips to setup a working environment. See
1877
initialize_on_transport_ex for a [nearly] all-in-one method.
1879
Subclasses should typically override initialize_on_transport
1880
instead of this method.
1882
return self.initialize_on_transport(get_transport(url,
1883
possible_transports))
1885
1522
def initialize_on_transport(self, transport):
1886
1523
"""Initialize a new bzrdir in the base directory of a Transport."""
2035
1672
control_files.unlock()
2036
1673
return self.open(transport, _found=True)
2038
def is_supported(self):
2039
"""Is this format supported?
2041
Supported formats must be initializable and openable.
2042
Unsupported formats may not support initialization or committing or
2043
some other features depending on the reason for not being supported.
2047
def network_name(self):
2048
"""A simple byte string uniquely identifying this format for RPC calls.
2050
Bzr control formats use thir disk format string to identify the format
2051
over the wire. Its possible that other control formats have more
2052
complex detection requirements, so we permit them to use any unique and
2053
immutable string they desire.
2055
raise NotImplementedError(self.network_name)
2057
def same_model(self, target_format):
2058
return (self.repository_format.rich_root_data ==
2059
target_format.rich_root_data)
2062
def known_formats(klass):
2063
"""Return all the known formats.
2065
Concrete formats should override _known_formats.
2067
# There is double indirection here to make sure that control
2068
# formats used by more than one dir format will only be probed
2069
# once. This can otherwise be quite expensive for remote connections.
2071
for format in klass._control_formats:
2072
result.update(format._known_formats())
2076
def _known_formats(klass):
2077
"""Return the known format instances for this control format."""
2078
return set(klass._formats.values())
2080
1675
def open(self, transport, _found=False):
2081
1676
"""Return an instance of this format for the dir transport points at.
2083
1678
_found is a private parameter, do not use it.
2086
found_format = BzrDirFormat.find_format(transport)
1681
found_format = controldir.ControlDirFormat.find_format(transport)
2087
1682
if not isinstance(found_format, self.__class__):
2088
1683
raise AssertionError("%s was asked to open %s, but it seems to need "
2105
1700
def register_format(klass, format):
2106
klass._formats[format.get_format_string()] = format
1701
BzrProber.register_bzrdir_format(format)
2107
1702
# bzr native formats have a network name of their format string.
2108
network_format_registry.register(format.get_format_string(), format.__class__)
2111
def register_control_format(klass, format):
2112
"""Register a format that does not use '.bzr' for its control dir.
2114
TODO: This should be pulled up into a 'ControlDirFormat' base class
2115
which BzrDirFormat can inherit from, and renamed to register_format
2116
there. It has been done without that for now for simplicity of
2119
klass._control_formats.append(format)
2122
def register_control_server_format(klass, format):
2123
"""Register a control format for client-server environments.
2125
These formats will be tried before ones registered with
2126
register_control_format. This gives implementations that decide to the
2127
chance to grab it before anything looks at the contents of the format
2130
klass._control_server_formats.append(format)
2133
def _set_default_format(klass, format):
2134
"""Set default format (for testing behavior of defaults only)"""
2135
klass._default_format = format
2139
return self.get_format_description().rstrip()
1703
controldir.network_format_registry.register(format.get_format_string(), format.__class__)
1704
controldir.ControlDirFormat.register_format(format)
2141
1706
def _supply_sub_formats_to(self, other_format):
2142
1707
"""Give other_format the same values for sub formats as this has.
3373
2908
BzrDirMetaFormat1._set_repository_format) #.im_func)
3376
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
3379
class BzrDirFormatInfo(object):
3381
def __init__(self, native, deprecated, hidden, experimental):
3382
self.deprecated = deprecated
3383
self.native = native
3384
self.hidden = hidden
3385
self.experimental = experimental
3388
class BzrDirFormatRegistry(registry.Registry):
3389
"""Registry of user-selectable BzrDir subformats.
3391
Differs from BzrDirFormat._control_formats in that it provides sub-formats,
3392
e.g. BzrDirMeta1 with weave repository. Also, it's more user-oriented.
3396
"""Create a BzrDirFormatRegistry."""
3397
self._aliases = set()
3398
self._registration_order = list()
3399
super(BzrDirFormatRegistry, self).__init__()
3402
"""Return a set of the format names which are aliases."""
3403
return frozenset(self._aliases)
3405
def register_metadir(self, key,
3406
repository_format, help, native=True, deprecated=False,
3412
"""Register a metadir subformat.
3414
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
3415
by the Repository/Branch/WorkingTreeformats.
3417
:param repository_format: The fully-qualified repository format class
3419
:param branch_format: Fully-qualified branch format class name as
3421
:param tree_format: Fully-qualified tree format class name as
3424
# This should be expanded to support setting WorkingTree and Branch
3425
# formats, once BzrDirMetaFormat1 supports that.
3426
def _load(full_name):
3427
mod_name, factory_name = full_name.rsplit('.', 1)
3429
mod = __import__(mod_name, globals(), locals(),
3431
except ImportError, e:
3432
raise ImportError('failed to load %s: %s' % (full_name, e))
3434
factory = getattr(mod, factory_name)
3435
except AttributeError:
3436
raise AttributeError('no factory %s in module %r'
3441
bd = BzrDirMetaFormat1()
3442
if branch_format is not None:
3443
bd.set_branch_format(_load(branch_format))
3444
if tree_format is not None:
3445
bd.workingtree_format = _load(tree_format)
3446
if repository_format is not None:
3447
bd.repository_format = _load(repository_format)
3449
self.register(key, helper, help, native, deprecated, hidden,
3450
experimental, alias)
3452
def register(self, key, factory, help, native=True, deprecated=False,
3453
hidden=False, experimental=False, alias=False):
3454
"""Register a BzrDirFormat factory.
3456
The factory must be a callable that takes one parameter: the key.
3457
It must produce an instance of the BzrDirFormat when called.
3459
This function mainly exists to prevent the info object from being
3462
registry.Registry.register(self, key, factory, help,
3463
BzrDirFormatInfo(native, deprecated, hidden, experimental))
3465
self._aliases.add(key)
3466
self._registration_order.append(key)
3468
def register_lazy(self, key, module_name, member_name, help, native=True,
3469
deprecated=False, hidden=False, experimental=False, alias=False):
3470
registry.Registry.register_lazy(self, key, module_name, member_name,
3471
help, BzrDirFormatInfo(native, deprecated, hidden, experimental))
3473
self._aliases.add(key)
3474
self._registration_order.append(key)
3476
def set_default(self, key):
3477
"""Set the 'default' key to be a clone of the supplied key.
3479
This method must be called once and only once.
3481
registry.Registry.register(self, 'default', self.get(key),
3482
self.get_help(key), info=self.get_info(key))
3483
self._aliases.add('default')
3485
def set_default_repository(self, key):
3486
"""Set the FormatRegistry default and Repository default.
3488
This is a transitional method while Repository.set_default_format
3491
if 'default' in self:
3492
self.remove('default')
3493
self.set_default(key)
3494
format = self.get('default')()
3496
def make_bzrdir(self, key):
3497
return self.get(key)()
3499
def help_topic(self, topic):
3501
default_realkey = None
3502
default_help = self.get_help('default')
3504
for key in self._registration_order:
3505
if key == 'default':
3507
help = self.get_help(key)
3508
if help == default_help:
3509
default_realkey = key
3511
help_pairs.append((key, help))
3513
def wrapped(key, help, info):
3515
help = '(native) ' + help
3516
return ':%s:\n%s\n\n' % (key,
3517
textwrap.fill(help, initial_indent=' ',
3518
subsequent_indent=' ',
3519
break_long_words=False))
3520
if default_realkey is not None:
3521
output += wrapped(default_realkey, '(default) %s' % default_help,
3522
self.get_info('default'))
3523
deprecated_pairs = []
3524
experimental_pairs = []
3525
for key, help in help_pairs:
3526
info = self.get_info(key)
3529
elif info.deprecated:
3530
deprecated_pairs.append((key, help))
3531
elif info.experimental:
3532
experimental_pairs.append((key, help))
3534
output += wrapped(key, help, info)
3535
output += "\nSee :doc:`formats-help` for more about storage formats."
3537
if len(experimental_pairs) > 0:
3538
other_output += "Experimental formats are shown below.\n\n"
3539
for key, help in experimental_pairs:
3540
info = self.get_info(key)
3541
other_output += wrapped(key, help, info)
3544
"No experimental formats are available.\n\n"
3545
if len(deprecated_pairs) > 0:
3546
other_output += "\nDeprecated formats are shown below.\n\n"
3547
for key, help in deprecated_pairs:
3548
info = self.get_info(key)
3549
other_output += wrapped(key, help, info)
3552
"\nNo deprecated formats are available.\n\n"
3554
"\nSee :doc:`formats-help` for more about storage formats."
3556
if topic == 'other-formats':
2911
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
3562
2914
class RepositoryAcquisitionPolicy(object):
3716
3068
return self._repository, False
3719
# Please register new formats after old formats so that formats
3720
# appear in chronological order and format descriptions can build
3722
format_registry = BzrDirFormatRegistry()
3071
def register_metadir(registry, key,
3072
repository_format, help, native=True, deprecated=False,
3078
"""Register a metadir subformat.
3080
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
3081
by the Repository/Branch/WorkingTreeformats.
3083
:param repository_format: The fully-qualified repository format class
3085
:param branch_format: Fully-qualified branch format class name as
3087
:param tree_format: Fully-qualified tree format class name as
3090
# This should be expanded to support setting WorkingTree and Branch
3091
# formats, once BzrDirMetaFormat1 supports that.
3092
def _load(full_name):
3093
mod_name, factory_name = full_name.rsplit('.', 1)
3095
mod = __import__(mod_name, globals(), locals(),
3097
except ImportError, e:
3098
raise ImportError('failed to load %s: %s' % (full_name, e))
3100
factory = getattr(mod, factory_name)
3101
except AttributeError:
3102
raise AttributeError('no factory %s in module %r'
3107
bd = BzrDirMetaFormat1()
3108
if branch_format is not None:
3109
bd.set_branch_format(_load(branch_format))
3110
if tree_format is not None:
3111
bd.workingtree_format = _load(tree_format)
3112
if repository_format is not None:
3113
bd.repository_format = _load(repository_format)
3115
registry.register(key, helper, help, native, deprecated, hidden,
3116
experimental, alias)
3723
3118
# The pre-0.8 formats have their repository format network name registered in
3724
3119
# repository.py. MetaDir formats have their repository format network name
3725
3120
# inferred from their disk format string.
3726
format_registry.register('weave', BzrDirFormat6,
3121
controldir.format_registry.register('weave', BzrDirFormat6,
3727
3122
'Pre-0.8 format. Slower than knit and does not'
3728
3123
' support checkouts or shared repositories.',
3730
3125
deprecated=True)
3731
format_registry.register_metadir('metaweave',
3126
register_metadir(controldir.format_registry, 'metaweave',
3732
3127
'bzrlib.repofmt.weaverepo.RepositoryFormat7',
3733
3128
'Transitional format in 0.8. Slower than knit.',
3734
3129
branch_format='bzrlib.branch.BzrBranchFormat5',
3735
3130
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3737
3132
deprecated=True)
3738
format_registry.register_metadir('knit',
3133
register_metadir(controldir.format_registry, 'knit',
3739
3134
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3740
3135
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
3741
3136
branch_format='bzrlib.branch.BzrBranchFormat5',
3742
3137
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3744
3139
deprecated=True)
3745
format_registry.register_metadir('dirstate',
3140
register_metadir(controldir.format_registry, 'dirstate',
3746
3141
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3747
3142
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
3748
3143
'above when accessed over the network.',