2761
2761
self.branch.unlock()
2764
class WorkingTreeFormatRegistry(registry.FormatRegistry):
2764
class WorkingTreeFormatRegistry(controldir.ControlComponentFormatRegistry):
2765
2765
"""Registry for working tree formats."""
2767
2767
def __init__(self, other_registry=None):
2768
2768
super(WorkingTreeFormatRegistry, self).__init__(other_registry)
2769
self._extra_formats = []
2770
2769
self._default_format = None
2772
def register(self, format):
2773
"""Register a new repository format."""
2774
super(WorkingTreeFormatRegistry, self).register(
2775
format.get_format_string(), format)
2777
def remove(self, format):
2778
"""Remove a registered repository format."""
2779
super(WorkingTreeFormatRegistry, self).remove(format.get_format_string())
2781
def register_extra(self, format):
2782
"""Register a repository format that can not be used in a metadir.
2784
This is mainly useful to allow custom repository formats, such as older
2785
Bazaar formats and foreign formats, to be tested.
2787
self._extra_formats.append(registry._ObjectGetter(format))
2789
def remove_extra(self, format):
2790
"""Remove an extra repository format.
2792
self._extra_formats.remove(registry._ObjectGetter(format))
2794
def register_extra_lazy(self, module_name, member_name):
2795
"""Register a repository format lazily.
2797
self._extra_formats.append(
2798
registry._LazyObjectGetter(module_name, member_name))
2800
2771
def get_default(self):
2801
2772
"""Return the current default format."""
2802
2773
return self._default_format
2804
2775
def set_default(self, format):
2805
2776
self._default_format = format
2807
def _get_extra(self):
2809
for getter in self._extra_formats:
2810
f = getter.get_obj()
2817
"""Return all repository formats, even those not usable in metadirs.
2819
return [self.get(k) for k in self.keys()] + self._get_extra()
2822
2779
format_registry = WorkingTreeFormatRegistry()
2825
class WorkingTreeFormat(object):
2782
class WorkingTreeFormat(controldir.ControlComponentFormat):
2826
2783
"""An encapsulation of the initialization and open routines for a format.
2828
2785
Formats provide three things:
2864
2821
raise errors.UnknownFormatError(format=format_string,
2865
2822
kind="working tree")
2824
def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
2825
accelerator_tree=None, hardlink=False):
2826
"""Initialize a new working tree in a_bzrdir.
2828
:param a_bzrdir: BzrDir to initialize the working tree in.
2829
:param revision_id: allows creating a working tree at a different
2830
revision than the branch is at.
2831
:param from_branch: Branch to checkout
2832
:param accelerator_tree: A tree which can be used for retrieving file
2833
contents more quickly than the revision tree, i.e. a workingtree.
2834
The revision tree will be used for cases where accelerator_tree's
2835
content is different.
2836
:param hardlink: If true, hard-link files from accelerator_tree,
2839
raise NotImplementedError(self.initialize)
2867
2841
def __eq__(self, other):
2868
2842
return self.__class__ is other.__class__