~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Robert Collins
  • Date: 2009-02-19 02:06:54 UTC
  • mto: This revision was merged to the branch mainline in revision 4020.
  • Revision ID: robertc@robertcollins.net-20090219020654-1l19ged3zo7212jh
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1707
1707
 
1708
1708
    def initialize_on_transport(self, transport):
1709
1709
        """Initialize a new bzrdir in the base directory of a Transport."""
1710
 
        # 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
1711
1733
        # mode from the root directory
1712
1734
        temp_control = lockable_files.LockableFiles(transport,
1713
1735
                            '', lockable_files.TransportLock)
1737
1759
                    mode=file_mode)
1738
1760
        finally:
1739
1761
            control_files.unlock()
1740
 
        # If we initialized using VFS methods on a RemoteTransport, return a
1741
 
        # Remote object: No need for it to be slower than necessary.
1742
 
        if isinstance(transport, remote_transport.RemoteTransport):
1743
 
            return self.open(transport)
1744
 
        else:
1745
 
            return self.open(transport, _found=True)
 
1762
        return self.open(transport, _found=True)
1746
1763
 
1747
1764
    def is_supported(self):
1748
1765
        """Is this format supported?