364
350
except errors.NoRepositoryPresent:
367
return False, (None, repository)
369
branch = bzrdir.open_branch()
370
except errors.NotBranchError:
371
return True, (None, None)
373
return True, (branch, None)
375
for branch, repo in BzrDir.find_bzrdirs(transport, evaluate=evaluate):
353
return False, ([], repository)
354
return True, (bzrdir.list_branches(), None)
356
for branches, repo in BzrDir.find_bzrdirs(transport,
376
358
if repo is not None:
377
branches.extend(repo.find_branches())
378
if branch is not None:
379
branches.append(branch)
382
def destroy_repository(self):
383
"""Destroy the repository in this BzrDir"""
384
raise NotImplementedError(self.destroy_repository)
386
def create_branch(self):
387
"""Create a branch in this BzrDir.
389
The bzrdir's format will control what branch format is created.
390
For more control see BranchFormatXX.create(a_bzrdir).
392
raise NotImplementedError(self.create_branch)
394
def destroy_branch(self):
395
"""Destroy the branch in this BzrDir"""
396
raise NotImplementedError(self.destroy_branch)
359
ret.extend(repo.find_branches())
360
if branches is not None:
399
365
def create_branch_and_repo(base, force_new_repo=False, format=None):
549
515
format=format).bzrdir
550
516
return bzrdir.create_workingtree()
552
def create_workingtree(self, revision_id=None, from_branch=None,
553
accelerator_tree=None, hardlink=False):
554
"""Create a working tree at this BzrDir.
556
:param revision_id: create it as of this revision id.
557
:param from_branch: override bzrdir branch (for lightweight checkouts)
558
:param accelerator_tree: A tree which can be used for retrieving file
559
contents more quickly than the revision tree, i.e. a workingtree.
560
The revision tree will be used for cases where accelerator_tree's
561
content is different.
563
raise NotImplementedError(self.create_workingtree)
518
def generate_backup_name(self, base):
519
"""Generate a non-existing backup file name based on base."""
521
name = "%s.~%d~" % (base, counter)
522
while self.root_transport.has(name):
524
name = "%s.~%d~" % (base, counter)
565
527
def backup_bzrdir(self):
566
528
"""Backup this bzr control directory.
568
530
:return: Tuple with old path name and new path name
533
backup_dir=self.generate_backup_name('backup.bzr')
570
534
pb = ui.ui_factory.nested_progress_bar()
572
536
# FIXME: bug 300001 -- the backup fails if the backup directory
573
537
# already exists, but it should instead either remove it or make
574
538
# a new backup directory.
576
# FIXME: bug 262450 -- the backup directory should have the same
577
# permissions as the .bzr directory (probably a bug in copy_tree)
578
540
old_path = self.root_transport.abspath('.bzr')
579
new_path = self.root_transport.abspath('backup.bzr')
580
pb.note('making backup of %s' % (old_path,))
581
pb.note(' to %s' % (new_path,))
582
self.root_transport.copy_tree('.bzr', 'backup.bzr')
541
new_path = self.root_transport.abspath(backup_dir)
542
ui.ui_factory.note('making backup of %s\n to %s' % (old_path, new_path,))
543
self.root_transport.copy_tree('.bzr', backup_dir)
583
544
return (old_path, new_path)
991
860
raise errors.NotBranchError(location)
992
861
return tree, branch, branch.repository, relpath
994
def open_repository(self, _unsupported=False):
995
"""Open the repository object at this BzrDir if one is present.
997
This will not follow the Branch object pointer - it's strictly a direct
998
open facility. Most client code should use open_branch().repository to
1001
:param _unsupported: a private parameter, not part of the api.
1002
TODO: static convenience version of this?
1004
raise NotImplementedError(self.open_repository)
1006
def open_workingtree(self, _unsupported=False,
1007
recommend_upgrade=True, from_branch=None):
1008
"""Open the workingtree object at this BzrDir if one is present.
1010
:param recommend_upgrade: Optional keyword parameter, when True (the
1011
default), emit through the ui module a recommendation that the user
1012
upgrade the working tree when the workingtree being opened is old
1013
(but still fully supported).
1014
:param from_branch: override bzrdir branch (for lightweight checkouts)
1016
raise NotImplementedError(self.open_workingtree)
1018
def has_branch(self):
1019
"""Tell if this bzrdir contains a branch.
1021
Note: if you're going to open the branch, you should just go ahead
1022
and try, and not ask permission first. (This method just opens the
1023
branch and discards it, and that's somewhat expensive.)
1028
except errors.NotBranchError:
1031
def has_workingtree(self):
1032
"""Tell if this bzrdir contains a working tree.
1034
This will still raise an exception if the bzrdir has a workingtree that
1035
is remote & inaccessible.
1037
Note: if you're going to open the working tree, you should just go ahead
1038
and try, and not ask permission first. (This method just opens the
1039
workingtree and discards it, and that's somewhat expensive.)
1042
self.open_workingtree(recommend_upgrade=False)
1044
except errors.NoWorkingTree:
1047
863
def _cloning_metadir(self):
1048
864
"""Produce a metadir suitable for cloning with.
1107
923
format.require_stacking()
1110
def checkout_metadir(self):
1111
return self.cloning_metadir()
1113
def sprout(self, url, revision_id=None, force_new_repo=False,
1114
recurse='down', possible_transports=None,
1115
accelerator_tree=None, hardlink=False, stacked=False,
1116
source_branch=None, create_tree_if_local=True):
1117
"""Create a copy of this bzrdir prepared for use as a new line of
1120
If url's last component does not exist, it will be created.
1122
Attributes related to the identity of the source branch like
1123
branch nickname will be cleaned, a working tree is created
1124
whether one existed before or not; and a local branch is always
1127
if revision_id is not None, then the clone operation may tune
1128
itself to download less data.
1129
:param accelerator_tree: A tree which can be used for retrieving file
1130
contents more quickly than the revision tree, i.e. a workingtree.
1131
The revision tree will be used for cases where accelerator_tree's
1132
content is different.
1133
:param hardlink: If true, hard-link files from accelerator_tree,
1135
:param stacked: If true, create a stacked branch referring to the
1136
location of this control directory.
1137
:param create_tree_if_local: If true, a working-tree will be created
1138
when working locally.
927
def create(cls, base, format=None, possible_transports=None):
928
"""Create a new BzrDir at the url 'base'.
930
:param format: If supplied, the format of branch to create. If not
931
supplied, the default is used.
932
:param possible_transports: If supplied, a list of transports that
933
can be reused to share a remote connection.
1140
target_transport = get_transport(url, possible_transports)
1141
target_transport.ensure_base()
1142
cloning_format = self.cloning_metadir(stacked)
1143
# Create/update the result branch
1144
result = cloning_format.initialize_on_transport(target_transport)
1145
# if a stacked branch wasn't requested, we don't create one
1146
# even if the origin was stacked
1147
stacked_branch_url = None
1148
if source_branch is not None:
1150
stacked_branch_url = self.root_transport.base
1151
source_repository = source_branch.repository
1154
source_branch = self.open_branch()
1155
source_repository = source_branch.repository
1157
stacked_branch_url = self.root_transport.base
1158
except errors.NotBranchError:
1159
source_branch = None
1161
source_repository = self.open_repository()
1162
except errors.NoRepositoryPresent:
1163
source_repository = None
1164
repository_policy = result.determine_repository_policy(
1165
force_new_repo, stacked_branch_url, require_stacking=stacked)
1166
result_repo, is_new_repo = repository_policy.acquire_repository()
1167
if is_new_repo and revision_id is not None and not stacked:
1168
fetch_spec = graph.PendingAncestryResult(
1169
[revision_id], source_repository)
1172
if source_repository is not None:
1173
# Fetch while stacked to prevent unstacked fetch from
1175
if fetch_spec is None:
1176
result_repo.fetch(source_repository, revision_id=revision_id)
1178
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
1180
if source_branch is None:
1181
# this is for sprouting a bzrdir without a branch; is that
1183
# Not especially, but it's part of the contract.
1184
result_branch = result.create_branch()
1186
result_branch = source_branch.sprout(result,
1187
revision_id=revision_id, repository_policy=repository_policy)
1188
mutter("created new branch %r" % (result_branch,))
1190
# Create/update the result working tree
1191
if (create_tree_if_local and
1192
isinstance(target_transport, local.LocalTransport) and
1193
(result_repo is None or result_repo.make_working_trees())):
1194
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
1198
if wt.path2id('') is None:
1200
wt.set_root_id(self.open_workingtree.get_root_id())
1201
except errors.NoWorkingTree:
1207
if recurse == 'down':
1209
basis = wt.basis_tree()
1211
subtrees = basis.iter_references()
1212
elif result_branch is not None:
1213
basis = result_branch.basis_tree()
1215
subtrees = basis.iter_references()
1216
elif source_branch is not None:
1217
basis = source_branch.basis_tree()
1219
subtrees = basis.iter_references()
1224
for path, file_id in subtrees:
1225
target = urlutils.join(url, urlutils.escape(path))
1226
sublocation = source_branch.reference_parent(file_id, path)
1227
sublocation.bzrdir.sprout(target,
1228
basis.get_reference_revision(file_id, path),
1229
force_new_repo=force_new_repo, recurse=recurse,
1232
if basis is not None:
1236
def push_branch(self, source, revision_id=None, overwrite=False,
1237
remember=False, create_prefix=False):
1238
"""Push the source branch into this BzrDir."""
1240
# If we can open a branch, use its direct repository, otherwise see
1241
# if there is a repository without a branch.
1243
br_to = self.open_branch()
1244
except errors.NotBranchError:
1245
# Didn't find a branch, can we find a repository?
1246
repository_to = self.find_repository()
1248
# Found a branch, so we must have found a repository
1249
repository_to = br_to.repository
1251
push_result = PushResult()
1252
push_result.source_branch = source
1254
# We have a repository but no branch, copy the revisions, and then
1256
repository_to.fetch(source.repository, revision_id=revision_id)
1257
br_to = source.clone(self, revision_id=revision_id)
1258
if source.get_push_location() is None or remember:
1259
source.set_push_location(br_to.base)
1260
push_result.stacked_on = None
1261
push_result.branch_push_result = None
1262
push_result.old_revno = None
1263
push_result.old_revid = _mod_revision.NULL_REVISION
1264
push_result.target_branch = br_to
1265
push_result.master_branch = None
1266
push_result.workingtree_updated = False
1268
# We have successfully opened the branch, remember if necessary:
1269
if source.get_push_location() is None or remember:
1270
source.set_push_location(br_to.base)
1272
tree_to = self.open_workingtree()
1273
except errors.NotLocalUrl:
1274
push_result.branch_push_result = source.push(br_to,
1275
overwrite, stop_revision=revision_id)
1276
push_result.workingtree_updated = False
1277
except errors.NoWorkingTree:
1278
push_result.branch_push_result = source.push(br_to,
1279
overwrite, stop_revision=revision_id)
1280
push_result.workingtree_updated = None # Not applicable
1282
tree_to.lock_write()
1284
push_result.branch_push_result = source.push(
1285
tree_to.branch, overwrite, stop_revision=revision_id)
1289
push_result.workingtree_updated = True
1290
push_result.old_revno = push_result.branch_push_result.old_revno
1291
push_result.old_revid = push_result.branch_push_result.old_revid
1292
push_result.target_branch = \
1293
push_result.branch_push_result.target_branch
935
if cls is not BzrDir:
936
raise AssertionError("BzrDir.create always creates the"
937
"default format, not one of %r" % cls)
938
t = get_transport(base, possible_transports)
941
format = controldir.ControlDirFormat.get_default_format()
942
return format.initialize_on_transport(t)
1297
946
class BzrDirHooks(hooks.Hooks):
1303
952
self.create_hook(hooks.HookPoint('pre_open',
1304
953
"Invoked before attempting to open a BzrDir with the transport "
1305
954
"that the open will use.", (1, 14), None))
955
self.create_hook(hooks.HookPoint('post_repo_init',
956
"Invoked after a repository has been initialized. "
957
"post_repo_init is called with a "
958
"bzrlib.bzrdir.RepoInitHookParams.",
1307
961
# install the default hooks
1308
962
BzrDir.hooks = BzrDirHooks()
965
class RepoInitHookParams(object):
966
"""Object holding parameters passed to *_repo_init hooks.
968
There are 4 fields that hooks may wish to access:
970
:ivar repository: Repository created
971
:ivar format: Repository format
972
:ivar bzrdir: The bzrdir for the repository
973
:ivar shared: The repository is shared
976
def __init__(self, repository, format, a_bzrdir, shared):
977
"""Create a group of RepoInitHook parameters.
979
:param repository: Repository created
980
:param format: Repository format
981
:param bzrdir: The bzrdir for the repository
982
:param shared: The repository is shared
984
self.repository = repository
986
self.bzrdir = a_bzrdir
989
def __eq__(self, other):
990
return self.__dict__ == other.__dict__
994
return "<%s for %s>" % (self.__class__.__name__,
997
return "<%s for %s>" % (self.__class__.__name__,
1311
1001
class BzrDirPreSplitOut(BzrDir):
1312
1002
"""A common class for the all-in-one formats."""
1738
1459
return config.TransportConfig(self.transport, 'control.conf')
1741
class BzrDirFormat(object):
1742
"""An encapsulation of the initialization and open routines for a format.
1744
Formats provide three things:
1745
* An initialization routine,
1462
class BzrProber(controldir.Prober):
1463
"""Prober for formats that use a .bzr/ control directory."""
1466
"""The known .bzr formats."""
1469
def register_bzrdir_format(klass, format):
1470
klass._formats[format.get_format_string()] = format
1473
def unregister_bzrdir_format(klass, format):
1474
del klass._formats[format.get_format_string()]
1477
def probe_transport(klass, transport):
1478
"""Return the .bzrdir style format present in a directory."""
1480
format_string = transport.get_bytes(".bzr/branch-format")
1481
except errors.NoSuchFile:
1482
raise errors.NotBranchError(path=transport.base)
1484
return klass._formats[format_string]
1486
raise errors.UnknownFormatError(format=format_string, kind='bzrdir')
1489
controldir.ControlDirFormat.register_prober(BzrProber)
1492
class RemoteBzrProber(controldir.Prober):
1493
"""Prober for remote servers that provide a Bazaar smart server."""
1496
def probe_transport(klass, transport):
1497
"""Return a RemoteBzrDirFormat object if it looks possible."""
1499
medium = transport.get_smart_medium()
1500
except (NotImplementedError, AttributeError,
1501
errors.TransportNotPossible, errors.NoSmartMedium,
1502
errors.SmartProtocolError):
1503
# no smart server, so not a branch for this format type.
1504
raise errors.NotBranchError(path=transport.base)
1506
# Decline to open it if the server doesn't support our required
1507
# version (3) so that the VFS-based transport will do it.
1508
if medium.should_probe():
1510
server_version = medium.protocol_version()
1511
except errors.SmartProtocolError:
1512
# Apparently there's no usable smart server there, even though
1513
# the medium supports the smart protocol.
1514
raise errors.NotBranchError(path=transport.base)
1515
if server_version != '2':
1516
raise errors.NotBranchError(path=transport.base)
1517
return RemoteBzrDirFormat()
1520
class BzrDirFormat(controldir.ControlDirFormat):
1521
"""ControlDirFormat base class for .bzr/ directories.
1749
1523
Formats are placed in a dict by their format string for reference
1750
1524
during bzrdir opening. These should be subclasses of BzrDirFormat
1755
1529
object will be created every system load.
1758
_default_format = None
1759
"""The default format used for new .bzr dirs."""
1762
"""The known formats."""
1764
_control_formats = []
1765
"""The registered control formats - .bzr, ....
1767
This is a list of BzrDirFormat objects.
1770
_control_server_formats = []
1771
"""The registered control server formats, e.g. RemoteBzrDirs.
1773
This is a list of BzrDirFormat objects.
1776
1532
_lock_file_name = 'branch-lock'
1778
1534
# _lock_class must be set in subclasses to the lock type, typ.
1779
1535
# TransportLock or LockDir
1782
def find_format(klass, transport, _server_formats=True):
1783
"""Return the format present at transport."""
1785
formats = klass._control_server_formats + klass._control_formats
1787
formats = klass._control_formats
1788
for format in formats:
1790
return format.probe_transport(transport)
1791
except errors.NotBranchError:
1792
# this format does not find a control dir here.
1794
raise errors.NotBranchError(path=transport.base)
1797
def probe_transport(klass, transport):
1798
"""Return the .bzrdir style format present in a directory."""
1800
format_string = transport.get(".bzr/branch-format").read()
1801
except errors.NoSuchFile:
1802
raise errors.NotBranchError(path=transport.base)
1805
return klass._formats[format_string]
1807
raise errors.UnknownFormatError(format=format_string, kind='bzrdir')
1810
def get_default_format(klass):
1811
"""Return the current default format."""
1812
return klass._default_format
1814
1537
def get_format_string(self):
1815
1538
"""Return the ASCII format string that identifies this format."""
1816
1539
raise NotImplementedError(self.get_format_string)
1818
def get_format_description(self):
1819
"""Return the short description for this format."""
1820
raise NotImplementedError(self.get_format_description)
1822
def get_converter(self, format=None):
1823
"""Return the converter to use to convert bzrdirs needing converts.
1825
This returns a bzrlib.bzrdir.Converter object.
1827
This should return the best upgrader to step this format towards the
1828
current default format. In the case of plugins we can/should provide
1829
some means for them to extend the range of returnable converters.
1831
:param format: Optional format to override the default format of the
1834
raise NotImplementedError(self.get_converter)
1836
def initialize(self, url, possible_transports=None):
1837
"""Create a bzr control dir at this url and return an opened copy.
1839
While not deprecated, this method is very specific and its use will
1840
lead to many round trips to setup a working environment. See
1841
initialize_on_transport_ex for a [nearly] all-in-one method.
1843
Subclasses should typically override initialize_on_transport
1844
instead of this method.
1846
return self.initialize_on_transport(get_transport(url,
1847
possible_transports))
1849
1541
def initialize_on_transport(self, transport):
1850
1542
"""Initialize a new bzrdir in the base directory of a Transport."""
1999
1691
control_files.unlock()
2000
1692
return self.open(transport, _found=True)
2002
def is_supported(self):
2003
"""Is this format supported?
2005
Supported formats must be initializable and openable.
2006
Unsupported formats may not support initialization or committing or
2007
some other features depending on the reason for not being supported.
2011
def network_name(self):
2012
"""A simple byte string uniquely identifying this format for RPC calls.
2014
Bzr control formats use thir disk format string to identify the format
2015
over the wire. Its possible that other control formats have more
2016
complex detection requirements, so we permit them to use any unique and
2017
immutable string they desire.
2019
raise NotImplementedError(self.network_name)
2021
def same_model(self, target_format):
2022
return (self.repository_format.rich_root_data ==
2023
target_format.rich_root_data)
2026
def known_formats(klass):
2027
"""Return all the known formats.
2029
Concrete formats should override _known_formats.
2031
# There is double indirection here to make sure that control
2032
# formats used by more than one dir format will only be probed
2033
# once. This can otherwise be quite expensive for remote connections.
2035
for format in klass._control_formats:
2036
result.update(format._known_formats())
2040
def _known_formats(klass):
2041
"""Return the known format instances for this control format."""
2042
return set(klass._formats.values())
2044
1694
def open(self, transport, _found=False):
2045
1695
"""Return an instance of this format for the dir transport points at.
2047
1697
_found is a private parameter, do not use it.
2050
found_format = BzrDirFormat.find_format(transport)
1700
found_format = controldir.ControlDirFormat.find_format(transport)
2051
1701
if not isinstance(found_format, self.__class__):
2052
1702
raise AssertionError("%s was asked to open %s, but it seems to need "
3320
2934
BzrDirMetaFormat1._set_repository_format) #.im_func)
3323
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
3326
class BzrDirFormatInfo(object):
3328
def __init__(self, native, deprecated, hidden, experimental):
3329
self.deprecated = deprecated
3330
self.native = native
3331
self.hidden = hidden
3332
self.experimental = experimental
3335
class BzrDirFormatRegistry(registry.Registry):
3336
"""Registry of user-selectable BzrDir subformats.
3338
Differs from BzrDirFormat._control_formats in that it provides sub-formats,
3339
e.g. BzrDirMeta1 with weave repository. Also, it's more user-oriented.
3343
"""Create a BzrDirFormatRegistry."""
3344
self._aliases = set()
3345
self._registration_order = list()
3346
super(BzrDirFormatRegistry, self).__init__()
3349
"""Return a set of the format names which are aliases."""
3350
return frozenset(self._aliases)
3352
def register_metadir(self, key,
3353
repository_format, help, native=True, deprecated=False,
3359
"""Register a metadir subformat.
3361
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
3362
by the Repository/Branch/WorkingTreeformats.
3364
:param repository_format: The fully-qualified repository format class
3366
:param branch_format: Fully-qualified branch format class name as
3368
:param tree_format: Fully-qualified tree format class name as
3371
# This should be expanded to support setting WorkingTree and Branch
3372
# formats, once BzrDirMetaFormat1 supports that.
3373
def _load(full_name):
3374
mod_name, factory_name = full_name.rsplit('.', 1)
3376
mod = __import__(mod_name, globals(), locals(),
3378
except ImportError, e:
3379
raise ImportError('failed to load %s: %s' % (full_name, e))
3381
factory = getattr(mod, factory_name)
3382
except AttributeError:
3383
raise AttributeError('no factory %s in module %r'
3388
bd = BzrDirMetaFormat1()
3389
if branch_format is not None:
3390
bd.set_branch_format(_load(branch_format))
3391
if tree_format is not None:
3392
bd.workingtree_format = _load(tree_format)
3393
if repository_format is not None:
3394
bd.repository_format = _load(repository_format)
3396
self.register(key, helper, help, native, deprecated, hidden,
3397
experimental, alias)
3399
def register(self, key, factory, help, native=True, deprecated=False,
3400
hidden=False, experimental=False, alias=False):
3401
"""Register a BzrDirFormat factory.
3403
The factory must be a callable that takes one parameter: the key.
3404
It must produce an instance of the BzrDirFormat when called.
3406
This function mainly exists to prevent the info object from being
3409
registry.Registry.register(self, key, factory, help,
3410
BzrDirFormatInfo(native, deprecated, hidden, experimental))
3412
self._aliases.add(key)
3413
self._registration_order.append(key)
3415
def register_lazy(self, key, module_name, member_name, help, native=True,
3416
deprecated=False, hidden=False, experimental=False, alias=False):
3417
registry.Registry.register_lazy(self, key, module_name, member_name,
3418
help, BzrDirFormatInfo(native, deprecated, hidden, experimental))
3420
self._aliases.add(key)
3421
self._registration_order.append(key)
3423
def set_default(self, key):
3424
"""Set the 'default' key to be a clone of the supplied key.
3426
This method must be called once and only once.
3428
registry.Registry.register(self, 'default', self.get(key),
3429
self.get_help(key), info=self.get_info(key))
3430
self._aliases.add('default')
3432
def set_default_repository(self, key):
3433
"""Set the FormatRegistry default and Repository default.
3435
This is a transitional method while Repository.set_default_format
3438
if 'default' in self:
3439
self.remove('default')
3440
self.set_default(key)
3441
format = self.get('default')()
3443
def make_bzrdir(self, key):
3444
return self.get(key)()
3446
def help_topic(self, topic):
3448
default_realkey = None
3449
default_help = self.get_help('default')
3451
for key in self._registration_order:
3452
if key == 'default':
3454
help = self.get_help(key)
3455
if help == default_help:
3456
default_realkey = key
3458
help_pairs.append((key, help))
3460
def wrapped(key, help, info):
3462
help = '(native) ' + help
3463
return ':%s:\n%s\n\n' % (key,
3464
textwrap.fill(help, initial_indent=' ',
3465
subsequent_indent=' ',
3466
break_long_words=False))
3467
if default_realkey is not None:
3468
output += wrapped(default_realkey, '(default) %s' % default_help,
3469
self.get_info('default'))
3470
deprecated_pairs = []
3471
experimental_pairs = []
3472
for key, help in help_pairs:
3473
info = self.get_info(key)
3476
elif info.deprecated:
3477
deprecated_pairs.append((key, help))
3478
elif info.experimental:
3479
experimental_pairs.append((key, help))
3481
output += wrapped(key, help, info)
3482
output += "\nSee ``bzr help formats`` for more about storage formats."
3484
if len(experimental_pairs) > 0:
3485
other_output += "Experimental formats are shown below.\n\n"
3486
for key, help in experimental_pairs:
3487
info = self.get_info(key)
3488
other_output += wrapped(key, help, info)
3491
"No experimental formats are available.\n\n"
3492
if len(deprecated_pairs) > 0:
3493
other_output += "\nDeprecated formats are shown below.\n\n"
3494
for key, help in deprecated_pairs:
3495
info = self.get_info(key)
3496
other_output += wrapped(key, help, info)
3499
"\nNo deprecated formats are available.\n\n"
3501
"\nSee ``bzr help formats`` for more about storage formats."
3503
if topic == 'other-formats':
2937
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
3509
2940
class RepositoryAcquisitionPolicy(object):
3659
3094
return self._repository, False
3662
# Please register new formats after old formats so that formats
3663
# appear in chronological order and format descriptions can build
3665
format_registry = BzrDirFormatRegistry()
3097
def register_metadir(registry, key,
3098
repository_format, help, native=True, deprecated=False,
3104
"""Register a metadir subformat.
3106
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
3107
by the Repository/Branch/WorkingTreeformats.
3109
:param repository_format: The fully-qualified repository format class
3111
:param branch_format: Fully-qualified branch format class name as
3113
:param tree_format: Fully-qualified tree format class name as
3116
# This should be expanded to support setting WorkingTree and Branch
3117
# formats, once BzrDirMetaFormat1 supports that.
3118
def _load(full_name):
3119
mod_name, factory_name = full_name.rsplit('.', 1)
3121
mod = __import__(mod_name, globals(), locals(),
3123
except ImportError, e:
3124
raise ImportError('failed to load %s: %s' % (full_name, e))
3126
factory = getattr(mod, factory_name)
3127
except AttributeError:
3128
raise AttributeError('no factory %s in module %r'
3133
bd = BzrDirMetaFormat1()
3134
if branch_format is not None:
3135
bd.set_branch_format(_load(branch_format))
3136
if tree_format is not None:
3137
bd.workingtree_format = _load(tree_format)
3138
if repository_format is not None:
3139
bd.repository_format = _load(repository_format)
3141
registry.register(key, helper, help, native, deprecated, hidden,
3142
experimental, alias)
3666
3144
# The pre-0.8 formats have their repository format network name registered in
3667
3145
# repository.py. MetaDir formats have their repository format network name
3668
3146
# inferred from their disk format string.
3669
format_registry.register('weave', BzrDirFormat6,
3147
controldir.format_registry.register('weave', BzrDirFormat6,
3670
3148
'Pre-0.8 format. Slower than knit and does not'
3671
3149
' support checkouts or shared repositories.',
3672
3151
deprecated=True)
3673
format_registry.register_metadir('metaweave',
3152
register_metadir(controldir.format_registry, 'metaweave',
3674
3153
'bzrlib.repofmt.weaverepo.RepositoryFormat7',
3675
3154
'Transitional format in 0.8. Slower than knit.',
3676
3155
branch_format='bzrlib.branch.BzrBranchFormat5',
3677
3156
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3678
3158
deprecated=True)
3679
format_registry.register_metadir('knit',
3159
register_metadir(controldir.format_registry, 'knit',
3680
3160
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3681
3161
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
3682
3162
branch_format='bzrlib.branch.BzrBranchFormat5',
3683
3163
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3684
3165
deprecated=True)
3685
format_registry.register_metadir('dirstate',
3166
register_metadir(controldir.format_registry, 'dirstate',
3686
3167
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3687
3168
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
3688
3169
'above when accessed over the network.',
3690
3171
# this uses bzrlib.workingtree.WorkingTreeFormat4 because importing
3691
3172
# directly from workingtree_4 triggers a circular import.
3692
3173
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3693
3175
deprecated=True)
3694
format_registry.register_metadir('dirstate-tags',
3176
register_metadir(controldir.format_registry, 'dirstate-tags',
3695
3177
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3696
3178
help='New in 0.15: Fast local operations and improved scaling for '
3697
3179
'network operations. Additionally adds support for tags.'
3698
3180
' Incompatible with bzr < 0.15.',
3699
3181
branch_format='bzrlib.branch.BzrBranchFormat6',
3700
3182
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3701
3184
deprecated=True)
3702
format_registry.register_metadir('rich-root',
3185
register_metadir(controldir.format_registry, 'rich-root',
3703
3186
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4',
3704
3187
help='New in 1.0. Better handling of tree roots. Incompatible with'
3706
3189
branch_format='bzrlib.branch.BzrBranchFormat6',
3707
3190
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3708
3192
deprecated=True)
3709
format_registry.register_metadir('dirstate-with-subtree',
3193
register_metadir(controldir.format_registry, 'dirstate-with-subtree',
3710
3194
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
3711
3195
help='New in 0.15: Fast local operations and improved scaling for '
3712
3196
'network operations. Additionally adds support for versioning nested '
3716
3200
experimental=True,
3719
format_registry.register_metadir('pack-0.92',
3203
register_metadir(controldir.format_registry, 'pack-0.92',
3720
3204
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
3721
3205
help='New in 0.92: Pack-based format with data compatible with '
3722
3206
'dirstate-tags format repositories. Interoperates with '
3723
3207
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3724
'Previously called knitpack-experimental. '
3725
'For more information, see '
3726
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
3727
3209
branch_format='bzrlib.branch.BzrBranchFormat6',
3728
3210
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3730
format_registry.register_metadir('pack-0.92-subtree',
3212
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
3731
3213
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
3732
3214
help='New in 0.92: Pack-based format with data compatible with '
3733
3215
'dirstate-with-subtree format repositories. Interoperates with '
3734
3216
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3735
'Previously called knitpack-experimental. '
3736
'For more information, see '
3737
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
3738
3218
branch_format='bzrlib.branch.BzrBranchFormat6',
3739
3219
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3741
3221
experimental=True,
3743
format_registry.register_metadir('rich-root-pack',
3223
register_metadir(controldir.format_registry, 'rich-root-pack',
3744
3224
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3745
3225
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
3746
3226
'(needed for bzr-svn and bzr-git).',
3747
3227
branch_format='bzrlib.branch.BzrBranchFormat6',
3748
3228
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3750
format_registry.register_metadir('1.6',
3231
register_metadir(controldir.format_registry, '1.6',
3751
3232
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
3752
3233
help='A format that allows a branch to indicate that there is another '
3753
3234
'(stacked) repository that should be used to access data that is '
3754
3235
'not present locally.',
3755
3236
branch_format='bzrlib.branch.BzrBranchFormat7',
3756
3237
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3758
format_registry.register_metadir('1.6.1-rich-root',
3240
register_metadir(controldir.format_registry, '1.6.1-rich-root',
3759
3241
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
3760
3242
help='A variant of 1.6 that supports rich-root data '
3761
3243
'(needed for bzr-svn and bzr-git).',
3762
3244
branch_format='bzrlib.branch.BzrBranchFormat7',
3763
3245
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3765
format_registry.register_metadir('1.9',
3248
register_metadir(controldir.format_registry, '1.9',
3766
3249
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3767
3250
help='A repository format using B+tree indexes. These indexes '
3768
3251
'are smaller in size, have smarter caching and provide faster '
3769
3252
'performance for most operations.',
3770
3253
branch_format='bzrlib.branch.BzrBranchFormat7',
3771
3254
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3773
format_registry.register_metadir('1.9-rich-root',
3257
register_metadir(controldir.format_registry, '1.9-rich-root',
3774
3258
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3775
3259
help='A variant of 1.9 that supports rich-root data '
3776
3260
'(needed for bzr-svn and bzr-git).',
3777
3261
branch_format='bzrlib.branch.BzrBranchFormat7',
3778
3262
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3780
format_registry.register_metadir('1.14',
3265
register_metadir(controldir.format_registry, '1.14',
3781
3266
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3782
3267
help='A working-tree format that supports content filtering.',
3783
3268
branch_format='bzrlib.branch.BzrBranchFormat7',
3784
3269
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3786
format_registry.register_metadir('1.14-rich-root',
3271
register_metadir(controldir.format_registry, '1.14-rich-root',
3787
3272
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3788
3273
help='A variant of 1.14 that supports rich-root data '
3789
3274
'(needed for bzr-svn and bzr-git).',
3791
3276
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3793
3278
# The following un-numbered 'development' formats should always just be aliases.
3794
format_registry.register_metadir('development-rich-root',
3279
register_metadir(controldir.format_registry, 'development-rich-root',
3795
3280
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3796
3281
help='Current development format. Supports rich roots. Can convert data '
3797
3282
'to and from rich-root-pack (and anything compatible with '
3798
3283
'rich-root-pack) format repositories. Repositories and branches in '
3799
3284
'this format can only be read by bzr.dev. Please read '
3800
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3285
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3802
3287
branch_format='bzrlib.branch.BzrBranchFormat7',
3803
3288
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3804
3289
experimental=True,
3807
format_registry.register_metadir('development-subtree',
3293
register_metadir(controldir.format_registry, 'development-subtree',
3808
3294
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3809
3295
help='Current development format, subtree variant. Can convert data to and '
3810
3296
'from pack-0.92-subtree (and anything compatible with '
3811
3297
'pack-0.92-subtree) format repositories. Repositories and branches in '
3812
3298
'this format can only be read by bzr.dev. Please read '
3813
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3299
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3815
3301
branch_format='bzrlib.branch.BzrBranchFormat7',
3816
3302
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3817
3303
experimental=True,
3818
3305
alias=False, # Restore to being an alias when an actual development subtree format is added
3819
3306
# This current non-alias status is simply because we did not introduce a
3820
3307
# chk based subtree format.
3823
3310
# And the development formats above will have aliased one of the following:
3824
format_registry.register_metadir('development6-rich-root',
3311
register_metadir(controldir.format_registry, 'development6-rich-root',
3825
3312
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3826
3313
help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots '
3828
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3315
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3830
3317
branch_format='bzrlib.branch.BzrBranchFormat7',
3831
3318
tree_format='bzrlib.workingtree.WorkingTreeFormat6',