/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Andrew Bennetts
  • Date: 2009-02-20 06:16:22 UTC
  • mfrom: (4023 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4027.
  • Revision ID: andrew.bennetts@canonical.com-20090220061622-te9miq29rlfqiwwv
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
    do_catching_redirections,
65
65
    get_transport,
66
66
    local,
 
67
    remote as remote_transport,
67
68
    )
68
69
from bzrlib.weave import Weave
69
70
""")
187
188
        """
188
189
        transport.ensure_base()
189
190
        require_stacking = (stacked_on is not None)
190
 
        metadir = self.cloning_metadir(require_stacking)
191
 
        result = metadir.initialize_on_transport(transport)
 
191
        format = self.cloning_metadir(require_stacking)
 
192
        result = format.initialize_on_transport(transport)
192
193
        repository_policy = None
193
194
        try:
194
195
            local_repo = self.find_repository()
1706
1707
 
1707
1708
    def initialize_on_transport(self, transport):
1708
1709
        """Initialize a new bzrdir in the base directory of a Transport."""
1709
 
        # Since we don't have a .bzr directory, inherit the
 
1710
        try:
 
1711
            # can we hand off the request to the smart server rather than using
 
1712
            # vfs calls?
 
1713
            client_medium = transport.get_smart_medium()
 
1714
        except errors.NoSmartMedium:
 
1715
            return self._initialize_on_transport_vfs(transport)
 
1716
        else:
 
1717
            # Current RPC's only know how to create bzr metadir1 instances, so
 
1718
            # we still delegate to vfs methods if the requested format is not a
 
1719
            # metadir1
 
1720
            if type(self) != BzrDirMetaFormat1:
 
1721
                return self._initialize_on_transport_vfs(transport)
 
1722
            remote_format = RemoteBzrDirFormat()
 
1723
            self._supply_sub_formats_to(remote_format)
 
1724
            return remote_format.initialize_on_transport(transport)
 
1725
 
 
1726
    def _initialize_on_transport_vfs(self, transport):
 
1727
        """Initialize a new bzrdir using VFS calls.
 
1728
        
 
1729
        :param transport: The transport to create the .bzr directory in.
 
1730
        :return: A
 
1731
        """
 
1732
        # Since we are creating a .bzr directory, inherit the
1710
1733
        # mode from the root directory
1711
1734
        temp_control = lockable_files.LockableFiles(transport,
1712
1735
                            '', lockable_files.TransportLock)
1781
1804
                raise AssertionError("%s was asked to open %s, but it seems to need "
1782
1805
                        "format %s" 
1783
1806
                        % (self, transport, found_format))
 
1807
            # Allow subclasses - use the found format.
 
1808
            self._supply_sub_formats_to(found_format)
 
1809
            return found_format._open(transport)
1784
1810
        return self._open(transport)
1785
1811
 
1786
1812
    def _open(self, transport):
1826
1852
        # Trim the newline
1827
1853
        return self.get_format_string().rstrip()
1828
1854
 
 
1855
    def _supply_sub_formats_to(self, other_format):
 
1856
        """Give other_format the same values for sub formats as this has.
 
1857
 
 
1858
        This method is expected to be used when parameterising a
 
1859
        RemoteBzrDirFormat instance with the parameters from a
 
1860
        BzrDirMetaFormat1 instance.
 
1861
 
 
1862
        :param other_format: other_format is a format which should be
 
1863
            compatible with whatever sub formats are supported by self.
 
1864
        :return: None.
 
1865
        """
 
1866
 
1829
1867
    @classmethod
1830
1868
    def unregister_format(klass, format):
1831
1869
        del klass._formats[format.get_format_string()]
2088
2126
        from bzrlib.repository import RepositoryFormat
2089
2127
        return RepositoryFormat.get_default_format()
2090
2128
 
2091
 
    def __set_repository_format(self, value):
 
2129
    def _set_repository_format(self, value):
2092
2130
        """Allow changing the repository format for metadir formats."""
2093
2131
        self._repository_format = value
2094
2132
 
2095
 
    repository_format = property(__return_repository_format, __set_repository_format)
 
2133
    repository_format = property(__return_repository_format,
 
2134
        _set_repository_format)
 
2135
 
 
2136
    def _supply_sub_formats_to(self, other_format):
 
2137
        """Give other_format the same values for sub formats as this has.
 
2138
 
 
2139
        This method is expected to be used when parameterising a
 
2140
        RemoteBzrDirFormat instance with the parameters from a
 
2141
        BzrDirMetaFormat1 instance.
 
2142
 
 
2143
        :param other_format: other_format is a format which should be
 
2144
            compatible with whatever sub formats are supported by self.
 
2145
        :return: None.
 
2146
        """
 
2147
        if getattr(self, '_repository_format', None) is not None:
 
2148
            other_format.repository_format = self.repository_format
 
2149
        if self._branch_format is not None:
 
2150
            other_format._branch_format = self._branch_format
 
2151
        if self._workingtree_format is not None:
 
2152
            other_format.workingtree_format = self.workingtree_format
2096
2153
 
2097
2154
    def __get_workingtree_format(self):
2098
2155
        if self._workingtree_format is None:
2679
2736
        response = client.call('BzrDirFormat.initialize', path)
2680
2737
        if response[0] != 'ok':
2681
2738
            raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2682
 
        return remote.RemoteBzrDir(transport)
 
2739
        format = RemoteBzrDirFormat()
 
2740
        self._supply_sub_formats_to(format)
 
2741
        return remote.RemoteBzrDir(transport, format)
2683
2742
 
2684
2743
    def _open(self, transport):
2685
 
        return remote.RemoteBzrDir(transport)
 
2744
        return remote.RemoteBzrDir(transport, self)
2686
2745
 
2687
2746
    def __eq__(self, other):
2688
2747
        if not isinstance(other, RemoteBzrDirFormat):
2689
2748
            return False
2690
2749
        return self.get_format_description() == other.get_format_description()
2691
2750
 
2692
 
    @property
2693
 
    def repository_format(self):
2694
 
        # Using a property to avoid early loading of remote
2695
 
        return remote.RemoteRepositoryFormat()
 
2751
    def __return_repository_format(self):
 
2752
        # Always return a RemoteRepositoryFormat object, but if a specific bzr
 
2753
        # repository format has been asked for, tell the RemoteRepositoryFormat
 
2754
        # that it should use that for init() etc.
 
2755
        result =  remote.RemoteRepositoryFormat()
 
2756
        custom_format = getattr(self, '_repository_format', None)
 
2757
        if custom_format:
 
2758
            # We will use the custom format to create repositories over the
 
2759
            # wire; expose its details like rich_root_data for code to query
 
2760
            if isinstance(custom_format, remote.RemoteRepositoryFormat):
 
2761
                result._custom_format = custom_format._custom_format
 
2762
            else:
 
2763
                result._custom_format = custom_format
 
2764
            result.rich_root_data = custom_format.rich_root_data
 
2765
        return result
 
2766
 
 
2767
    repository_format = property(__return_repository_format,
 
2768
        BzrDirMetaFormat1._set_repository_format) #.im_func)
2696
2769
 
2697
2770
 
2698
2771
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
3021
3094
# appear in chronological order and format descriptions can build
3022
3095
# on previous ones.
3023
3096
format_registry = BzrDirFormatRegistry()
 
3097
# The pre-0.8 formats have their repository format network name registered in
 
3098
# repository.py. MetaDir formats have their repository format network name
 
3099
# inferred from their disk format string.
3024
3100
format_registry.register('weave', BzrDirFormat6,
3025
3101
    'Pre-0.8 format.  Slower than knit and does not'
3026
3102
    ' support checkouts or shared repositories.',
3136
3212
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3137
3213
    help='A working-tree format that supports views and content filtering.',
3138
3214
    branch_format='bzrlib.branch.BzrBranchFormat7',
3139
 
    tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
 
3215
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3140
3216
    experimental=True,
3141
3217
    )
3142
3218
format_registry.register_metadir('development-wt5-rich-root',
3144
3220
    help='A variant of development-wt5 that supports rich-root data '
3145
3221
         '(needed for bzr-svn).',
3146
3222
    branch_format='bzrlib.branch.BzrBranchFormat7',
3147
 
    tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
 
3223
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3148
3224
    experimental=True,
3149
3225
    )
3150
3226
# The following two formats should always just be aliases.