841
1018
raise errors.NotBranchError(location)
842
1019
return tree, branch, branch.repository, relpath
1021
def open_repository(self, _unsupported=False):
1022
"""Open the repository object at this BzrDir if one is present.
1024
This will not follow the Branch object pointer - it's strictly a direct
1025
open facility. Most client code should use open_branch().repository to
1026
get at a repository.
1028
:param _unsupported: a private parameter, not part of the api.
1029
TODO: static convenience version of this?
1031
raise NotImplementedError(self.open_repository)
1033
def open_workingtree(self, _unsupported=False,
1034
recommend_upgrade=True, from_branch=None):
1035
"""Open the workingtree object at this BzrDir if one is present.
1037
:param recommend_upgrade: Optional keyword parameter, when True (the
1038
default), emit through the ui module a recommendation that the user
1039
upgrade the working tree when the workingtree being opened is old
1040
(but still fully supported).
1041
:param from_branch: override bzrdir branch (for lightweight checkouts)
1043
raise NotImplementedError(self.open_workingtree)
1045
def has_branch(self, name=None):
1046
"""Tell if this bzrdir contains a branch.
1048
Note: if you're going to open the branch, you should just go ahead
1049
and try, and not ask permission first. (This method just opens the
1050
branch and discards it, and that's somewhat expensive.)
1053
self.open_branch(name)
1055
except errors.NotBranchError:
1058
def has_workingtree(self):
1059
"""Tell if this bzrdir contains a working tree.
1061
This will still raise an exception if the bzrdir has a workingtree that
1062
is remote & inaccessible.
1064
Note: if you're going to open the working tree, you should just go ahead
1065
and try, and not ask permission first. (This method just opens the
1066
workingtree and discards it, and that's somewhat expensive.)
1069
self.open_workingtree(recommend_upgrade=False)
1071
except errors.NoWorkingTree:
844
1074
def _cloning_metadir(self):
845
1075
"""Produce a metadir suitable for cloning with.
904
1134
format.require_stacking()
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.
1137
def checkout_metadir(self):
1138
return self.cloning_metadir()
1140
def sprout(self, url, revision_id=None, force_new_repo=False,
1141
recurse='down', possible_transports=None,
1142
accelerator_tree=None, hardlink=False, stacked=False,
1143
source_branch=None, create_tree_if_local=True):
1144
"""Create a copy of this bzrdir prepared for use as a new line of
1147
If url's last component does not exist, it will be created.
1149
Attributes related to the identity of the source branch like
1150
branch nickname will be cleaned, a working tree is created
1151
whether one existed before or not; and a local branch is always
1154
if revision_id is not None, then the clone operation may tune
1155
itself to download less data.
1156
:param accelerator_tree: A tree which can be used for retrieving file
1157
contents more quickly than the revision tree, i.e. a workingtree.
1158
The revision tree will be used for cases where accelerator_tree's
1159
content is different.
1160
:param hardlink: If true, hard-link files from accelerator_tree,
1162
:param stacked: If true, create a stacked branch referring to the
1163
location of this control directory.
1164
:param create_tree_if_local: If true, a working-tree will be created
1165
when working locally.
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)
1167
target_transport = get_transport(url, possible_transports)
1168
target_transport.ensure_base()
1169
cloning_format = self.cloning_metadir(stacked)
1170
# Create/update the result branch
1171
result = cloning_format.initialize_on_transport(target_transport)
1172
# if a stacked branch wasn't requested, we don't create one
1173
# even if the origin was stacked
1174
stacked_branch_url = None
1175
if source_branch is not None:
1177
stacked_branch_url = self.root_transport.base
1178
source_repository = source_branch.repository
1181
source_branch = self.open_branch()
1182
source_repository = source_branch.repository
1184
stacked_branch_url = self.root_transport.base
1185
except errors.NotBranchError:
1186
source_branch = None
1188
source_repository = self.open_repository()
1189
except errors.NoRepositoryPresent:
1190
source_repository = None
1191
repository_policy = result.determine_repository_policy(
1192
force_new_repo, stacked_branch_url, require_stacking=stacked)
1193
result_repo, is_new_repo = repository_policy.acquire_repository()
1194
if is_new_repo and revision_id is not None and not stacked:
1195
fetch_spec = graph.PendingAncestryResult(
1196
[revision_id], source_repository)
1199
if source_repository is not None:
1200
# Fetch while stacked to prevent unstacked fetch from
1202
if fetch_spec is None:
1203
result_repo.fetch(source_repository, revision_id=revision_id)
1205
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
1207
if source_branch is None:
1208
# this is for sprouting a bzrdir without a branch; is that
1210
# Not especially, but it's part of the contract.
1211
result_branch = result.create_branch()
1213
result_branch = source_branch.sprout(result,
1214
revision_id=revision_id, repository_policy=repository_policy)
1215
mutter("created new branch %r" % (result_branch,))
1217
# Create/update the result working tree
1218
if (create_tree_if_local and
1219
isinstance(target_transport, local.LocalTransport) and
1220
(result_repo is None or result_repo.make_working_trees())):
1221
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
1225
if wt.path2id('') is None:
1227
wt.set_root_id(self.open_workingtree.get_root_id())
1228
except errors.NoWorkingTree:
1234
if recurse == 'down':
1236
basis = wt.basis_tree()
1238
subtrees = basis.iter_references()
1239
elif result_branch is not None:
1240
basis = result_branch.basis_tree()
1242
subtrees = basis.iter_references()
1243
elif source_branch is not None:
1244
basis = source_branch.basis_tree()
1246
subtrees = basis.iter_references()
1251
for path, file_id in subtrees:
1252
target = urlutils.join(url, urlutils.escape(path))
1253
sublocation = source_branch.reference_parent(file_id, path)
1254
sublocation.bzrdir.sprout(target,
1255
basis.get_reference_revision(file_id, path),
1256
force_new_repo=force_new_repo, recurse=recurse,
1259
if basis is not None:
1263
def push_branch(self, source, revision_id=None, overwrite=False,
1264
remember=False, create_prefix=False):
1265
"""Push the source branch into this BzrDir."""
1267
# If we can open a branch, use its direct repository, otherwise see
1268
# if there is a repository without a branch.
1270
br_to = self.open_branch()
1271
except errors.NotBranchError:
1272
# Didn't find a branch, can we find a repository?
1273
repository_to = self.find_repository()
1275
# Found a branch, so we must have found a repository
1276
repository_to = br_to.repository
1278
push_result = PushResult()
1279
push_result.source_branch = source
1281
# We have a repository but no branch, copy the revisions, and then
1283
repository_to.fetch(source.repository, revision_id=revision_id)
1284
br_to = source.clone(self, revision_id=revision_id)
1285
if source.get_push_location() is None or remember:
1286
source.set_push_location(br_to.base)
1287
push_result.stacked_on = None
1288
push_result.branch_push_result = None
1289
push_result.old_revno = None
1290
push_result.old_revid = _mod_revision.NULL_REVISION
1291
push_result.target_branch = br_to
1292
push_result.master_branch = None
1293
push_result.workingtree_updated = False
1295
# We have successfully opened the branch, remember if necessary:
1296
if source.get_push_location() is None or remember:
1297
source.set_push_location(br_to.base)
1299
tree_to = self.open_workingtree()
1300
except errors.NotLocalUrl:
1301
push_result.branch_push_result = source.push(br_to,
1302
overwrite, stop_revision=revision_id)
1303
push_result.workingtree_updated = False
1304
except errors.NoWorkingTree:
1305
push_result.branch_push_result = source.push(br_to,
1306
overwrite, stop_revision=revision_id)
1307
push_result.workingtree_updated = None # Not applicable
1309
tree_to.lock_write()
1311
push_result.branch_push_result = source.push(
1312
tree_to.branch, overwrite, stop_revision=revision_id)
1316
push_result.workingtree_updated = True
1317
push_result.old_revno = push_result.branch_push_result.old_revno
1318
push_result.old_revid = push_result.branch_push_result.old_revid
1319
push_result.target_branch = \
1320
push_result.branch_push_result.target_branch
927
1324
class BzrDirHooks(hooks.Hooks):
933
1330
self.create_hook(hooks.HookPoint('pre_open',
934
1331
"Invoked before attempting to open a BzrDir with the transport "
935
1332
"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.",
942
1334
# install the default hooks
943
1335
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__,
982
1338
class BzrDirPreSplitOut(BzrDir):
983
1339
"""A common class for the all-in-one formats."""
1440
1796
return config.TransportConfig(self.transport, 'control.conf')
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.
1799
class BzrDirFormat(object):
1800
"""An encapsulation of the initialization and open routines for a format.
1802
Formats provide three things:
1803
* An initialization routine,
1504
1807
Formats are placed in a dict by their format string for reference
1505
1808
during bzrdir opening. These should be subclasses of BzrDirFormat
1508
1811
Once a format is deprecated, just deprecate the initialize and open
1509
1812
methods on the format class. Do not deprecate the object, as the
1510
1813
object will be created every system load.
1815
:cvar colocated_branches: Whether this formats supports colocated branches.
1818
_default_format = None
1819
"""The default format used for new .bzr dirs."""
1822
"""The known formats."""
1824
_control_formats = []
1825
"""The registered control formats - .bzr, ....
1827
This is a list of BzrDirFormat objects.
1830
_control_server_formats = []
1831
"""The registered control server formats, e.g. RemoteBzrDirs.
1833
This is a list of BzrDirFormat objects.
1513
1836
_lock_file_name = 'branch-lock'
1838
colocated_branches = False
1839
"""Whether co-located branches are supported for this control dir format.
1515
1842
# _lock_class must be set in subclasses to the lock type, typ.
1516
1843
# TransportLock or LockDir
1846
def find_format(klass, transport, _server_formats=True):
1847
"""Return the format present at transport."""
1849
formats = klass._control_server_formats + klass._control_formats
1851
formats = klass._control_formats
1852
for format in formats:
1854
return format.probe_transport(transport)
1855
except errors.NotBranchError:
1856
# this format does not find a control dir here.
1858
raise errors.NotBranchError(path=transport.base)
1861
def probe_transport(klass, transport):
1862
"""Return the .bzrdir style format present in a directory."""
1864
format_string = transport.get_bytes(".bzr/branch-format")
1865
except errors.NoSuchFile:
1866
raise errors.NotBranchError(path=transport.base)
1869
return klass._formats[format_string]
1871
raise errors.UnknownFormatError(format=format_string, kind='bzrdir')
1874
def get_default_format(klass):
1875
"""Return the current default format."""
1876
return klass._default_format
1518
1878
def get_format_string(self):
1519
1879
"""Return the ASCII format string that identifies this format."""
1520
1880
raise NotImplementedError(self.get_format_string)
1882
def get_format_description(self):
1883
"""Return the short description for this format."""
1884
raise NotImplementedError(self.get_format_description)
1886
def get_converter(self, format=None):
1887
"""Return the converter to use to convert bzrdirs needing converts.
1889
This returns a bzrlib.bzrdir.Converter object.
1891
This should return the best upgrader to step this format towards the
1892
current default format. In the case of plugins we can/should provide
1893
some means for them to extend the range of returnable converters.
1895
:param format: Optional format to override the default format of the
1898
raise NotImplementedError(self.get_converter)
1900
def initialize(self, url, possible_transports=None):
1901
"""Create a bzr control dir at this url and return an opened copy.
1903
While not deprecated, this method is very specific and its use will
1904
lead to many round trips to setup a working environment. See
1905
initialize_on_transport_ex for a [nearly] all-in-one method.
1907
Subclasses should typically override initialize_on_transport
1908
instead of this method.
1910
return self.initialize_on_transport(get_transport(url,
1911
possible_transports))
1522
1913
def initialize_on_transport(self, transport):
1523
1914
"""Initialize a new bzrdir in the base directory of a Transport."""
1672
2063
control_files.unlock()
1673
2064
return self.open(transport, _found=True)
2066
def is_supported(self):
2067
"""Is this format supported?
2069
Supported formats must be initializable and openable.
2070
Unsupported formats may not support initialization or committing or
2071
some other features depending on the reason for not being supported.
2075
def network_name(self):
2076
"""A simple byte string uniquely identifying this format for RPC calls.
2078
Bzr control formats use thir disk format string to identify the format
2079
over the wire. Its possible that other control formats have more
2080
complex detection requirements, so we permit them to use any unique and
2081
immutable string they desire.
2083
raise NotImplementedError(self.network_name)
2085
def same_model(self, target_format):
2086
return (self.repository_format.rich_root_data ==
2087
target_format.rich_root_data)
2090
def known_formats(klass):
2091
"""Return all the known formats.
2093
Concrete formats should override _known_formats.
2095
# There is double indirection here to make sure that control
2096
# formats used by more than one dir format will only be probed
2097
# once. This can otherwise be quite expensive for remote connections.
2099
for format in klass._control_formats:
2100
result.update(format._known_formats())
2104
def _known_formats(klass):
2105
"""Return the known format instances for this control format."""
2106
return set(klass._formats.values())
1675
2108
def open(self, transport, _found=False):
1676
2109
"""Return an instance of this format for the dir transport points at.
1678
2111
_found is a private parameter, do not use it.
1681
found_format = controldir.ControlDirFormat.find_format(transport)
2114
found_format = BzrDirFormat.find_format(transport)
1682
2115
if not isinstance(found_format, self.__class__):
1683
2116
raise AssertionError("%s was asked to open %s, but it seems to need "
1700
2133
def register_format(klass, format):
1701
BzrProber.register_bzrdir_format(format)
2134
klass._formats[format.get_format_string()] = format
1702
2135
# bzr native formats have a network name of their format string.
1703
controldir.network_format_registry.register(format.get_format_string(), format.__class__)
1704
controldir.ControlDirFormat.register_format(format)
2136
network_format_registry.register(format.get_format_string(), format.__class__)
2139
def register_control_format(klass, format):
2140
"""Register a format that does not use '.bzr' for its control dir.
2142
TODO: This should be pulled up into a 'ControlDirFormat' base class
2143
which BzrDirFormat can inherit from, and renamed to register_format
2144
there. It has been done without that for now for simplicity of
2147
klass._control_formats.append(format)
2150
def register_control_server_format(klass, format):
2151
"""Register a control format for client-server environments.
2153
These formats will be tried before ones registered with
2154
register_control_format. This gives implementations that decide to the
2155
chance to grab it before anything looks at the contents of the format
2158
klass._control_server_formats.append(format)
2161
def _set_default_format(klass, format):
2162
"""Set default format (for testing behavior of defaults only)"""
2163
klass._default_format = format
2167
return self.get_format_description().rstrip()
1706
2169
def _supply_sub_formats_to(self, other_format):
1707
2170
"""Give other_format the same values for sub formats as this has.
2908
3401
BzrDirMetaFormat1._set_repository_format) #.im_func)
2911
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
3404
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
3407
class BzrDirFormatInfo(object):
3409
def __init__(self, native, deprecated, hidden, experimental):
3410
self.deprecated = deprecated
3411
self.native = native
3412
self.hidden = hidden
3413
self.experimental = experimental
3416
class BzrDirFormatRegistry(registry.Registry):
3417
"""Registry of user-selectable BzrDir subformats.
3419
Differs from BzrDirFormat._control_formats in that it provides sub-formats,
3420
e.g. BzrDirMeta1 with weave repository. Also, it's more user-oriented.
3424
"""Create a BzrDirFormatRegistry."""
3425
self._aliases = set()
3426
self._registration_order = list()
3427
super(BzrDirFormatRegistry, self).__init__()
3430
"""Return a set of the format names which are aliases."""
3431
return frozenset(self._aliases)
3433
def register_metadir(self, key,
3434
repository_format, help, native=True, deprecated=False,
3440
"""Register a metadir subformat.
3442
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
3443
by the Repository/Branch/WorkingTreeformats.
3445
:param repository_format: The fully-qualified repository format class
3447
:param branch_format: Fully-qualified branch format class name as
3449
:param tree_format: Fully-qualified tree format class name as
3452
# This should be expanded to support setting WorkingTree and Branch
3453
# formats, once BzrDirMetaFormat1 supports that.
3454
def _load(full_name):
3455
mod_name, factory_name = full_name.rsplit('.', 1)
3457
mod = __import__(mod_name, globals(), locals(),
3459
except ImportError, e:
3460
raise ImportError('failed to load %s: %s' % (full_name, e))
3462
factory = getattr(mod, factory_name)
3463
except AttributeError:
3464
raise AttributeError('no factory %s in module %r'
3469
bd = BzrDirMetaFormat1()
3470
if branch_format is not None:
3471
bd.set_branch_format(_load(branch_format))
3472
if tree_format is not None:
3473
bd.workingtree_format = _load(tree_format)
3474
if repository_format is not None:
3475
bd.repository_format = _load(repository_format)
3477
self.register(key, helper, help, native, deprecated, hidden,
3478
experimental, alias)
3480
def register(self, key, factory, help, native=True, deprecated=False,
3481
hidden=False, experimental=False, alias=False):
3482
"""Register a BzrDirFormat factory.
3484
The factory must be a callable that takes one parameter: the key.
3485
It must produce an instance of the BzrDirFormat when called.
3487
This function mainly exists to prevent the info object from being
3490
registry.Registry.register(self, key, factory, help,
3491
BzrDirFormatInfo(native, deprecated, hidden, experimental))
3493
self._aliases.add(key)
3494
self._registration_order.append(key)
3496
def register_lazy(self, key, module_name, member_name, help, native=True,
3497
deprecated=False, hidden=False, experimental=False, alias=False):
3498
registry.Registry.register_lazy(self, key, module_name, member_name,
3499
help, BzrDirFormatInfo(native, deprecated, hidden, experimental))
3501
self._aliases.add(key)
3502
self._registration_order.append(key)
3504
def set_default(self, key):
3505
"""Set the 'default' key to be a clone of the supplied key.
3507
This method must be called once and only once.
3509
registry.Registry.register(self, 'default', self.get(key),
3510
self.get_help(key), info=self.get_info(key))
3511
self._aliases.add('default')
3513
def set_default_repository(self, key):
3514
"""Set the FormatRegistry default and Repository default.
3516
This is a transitional method while Repository.set_default_format
3519
if 'default' in self:
3520
self.remove('default')
3521
self.set_default(key)
3522
format = self.get('default')()
3524
def make_bzrdir(self, key):
3525
return self.get(key)()
3527
def help_topic(self, topic):
3529
default_realkey = None
3530
default_help = self.get_help('default')
3532
for key in self._registration_order:
3533
if key == 'default':
3535
help = self.get_help(key)
3536
if help == default_help:
3537
default_realkey = key
3539
help_pairs.append((key, help))
3541
def wrapped(key, help, info):
3543
help = '(native) ' + help
3544
return ':%s:\n%s\n\n' % (key,
3545
textwrap.fill(help, initial_indent=' ',
3546
subsequent_indent=' ',
3547
break_long_words=False))
3548
if default_realkey is not None:
3549
output += wrapped(default_realkey, '(default) %s' % default_help,
3550
self.get_info('default'))
3551
deprecated_pairs = []
3552
experimental_pairs = []
3553
for key, help in help_pairs:
3554
info = self.get_info(key)
3557
elif info.deprecated:
3558
deprecated_pairs.append((key, help))
3559
elif info.experimental:
3560
experimental_pairs.append((key, help))
3562
output += wrapped(key, help, info)
3563
output += "\nSee :doc:`formats-help` for more about storage formats."
3565
if len(experimental_pairs) > 0:
3566
other_output += "Experimental formats are shown below.\n\n"
3567
for key, help in experimental_pairs:
3568
info = self.get_info(key)
3569
other_output += wrapped(key, help, info)
3572
"No experimental formats are available.\n\n"
3573
if len(deprecated_pairs) > 0:
3574
other_output += "\nDeprecated formats are shown below.\n\n"
3575
for key, help in deprecated_pairs:
3576
info = self.get_info(key)
3577
other_output += wrapped(key, help, info)
3580
"\nNo deprecated formats are available.\n\n"
3582
"\nSee :doc:`formats-help` for more about storage formats."
3584
if topic == 'other-formats':
2914
3590
class RepositoryAcquisitionPolicy(object):
3068
3744
return self._repository, False
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)
3747
# Please register new formats after old formats so that formats
3748
# appear in chronological order and format descriptions can build
3750
format_registry = BzrDirFormatRegistry()
3118
3751
# The pre-0.8 formats have their repository format network name registered in
3119
3752
# repository.py. MetaDir formats have their repository format network name
3120
3753
# inferred from their disk format string.
3121
controldir.format_registry.register('weave', BzrDirFormat6,
3754
format_registry.register('weave', BzrDirFormat6,
3122
3755
'Pre-0.8 format. Slower than knit and does not'
3123
3756
' support checkouts or shared repositories.',
3125
3758
deprecated=True)
3126
register_metadir(controldir.format_registry, 'metaweave',
3759
format_registry.register_metadir('metaweave',
3127
3760
'bzrlib.repofmt.weaverepo.RepositoryFormat7',
3128
3761
'Transitional format in 0.8. Slower than knit.',
3129
3762
branch_format='bzrlib.branch.BzrBranchFormat5',
3130
3763
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3132
3765
deprecated=True)
3133
register_metadir(controldir.format_registry, 'knit',
3766
format_registry.register_metadir('knit',
3134
3767
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3135
3768
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
3136
3769
branch_format='bzrlib.branch.BzrBranchFormat5',
3137
3770
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3139
3772
deprecated=True)
3140
register_metadir(controldir.format_registry, 'dirstate',
3773
format_registry.register_metadir('dirstate',
3141
3774
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3142
3775
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
3143
3776
'above when accessed over the network.',