1532
1532
raise AssertionError("invalid heads: %r" % (heads,))
1535
class BranchFormat(object):
1535
class BranchFormat(controldir.ControlComponentFormat):
1536
1536
"""An encapsulation of the initialization and open routines for a format.
1538
1538
Formats provide three things:
2359
class BranchFormatRegistry(registry.FormatRegistry):
2359
class BranchFormatRegistry(controldir.ControlComponentFormatRegistry):
2360
2360
"""Branch format registry."""
2362
2362
def __init__(self, other_registry=None):
2363
2363
super(BranchFormatRegistry, self).__init__(other_registry)
2364
2364
self._default_format = None
2365
self._extra_formats = []
2367
def register(self, format):
2368
"""Register a new branch format."""
2369
super(BranchFormatRegistry, self).register(
2370
format.get_format_string(), format)
2372
def remove(self, format):
2373
"""Remove a registered branch format."""
2374
super(BranchFormatRegistry, self).remove(
2375
format.get_format_string())
2377
def register_extra(self, format):
2378
"""Register a branch format that can not be part of a metadir.
2380
This is mainly useful to allow custom branch formats, such as
2381
older Bazaar formats and foreign formats, to be tested
2383
self._extra_formats.append(registry._ObjectGetter(format))
2384
network_format_registry.register(
2385
format.network_name(), format.__class__)
2387
def register_extra_lazy(self, module_name, member_name):
2388
"""Register a branch format lazily.
2390
self._extra_formats.append(
2391
registry._LazyObjectGetter(module_name, member_name))
2394
def unregister_extra(self, format):
2395
self._extra_formats.remove(registry._ObjectGetter(format))
2399
for name, fmt in self.iteritems():
2403
for objgetter in self._extra_formats:
2404
fmt = objgetter.get_obj()
2410
2366
def set_default(self, format):
2411
2367
self._default_format = format
2428
2384
# formats which have no format string are not discoverable
2429
2385
# and not independently creatable, so are not registered.
2386
__format4 = BzrBranchFormat4()
2430
2387
__format5 = BzrBranchFormat5()
2431
2388
__format6 = BzrBranchFormat6()
2432
2389
__format7 = BzrBranchFormat7()
2437
2394
format_registry.register(__format7)
2438
2395
format_registry.register(__format8)
2439
2396
format_registry.set_default(__format7)
2440
format_registry.register_extra(BzrBranchFormat4())
2397
format_registry.register_extra(__format4)
2398
network_format_registry.register(__format4.network_name(), __format4)
2443
2401
class BranchWriteLockResult(LogicalLockResult):