/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 breezy/bzrdir.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
import sys
31
31
 
32
 
from breezy.lazy_import import lazy_import
 
32
from .lazy_import import lazy_import
33
33
lazy_import(globals(), """
34
34
import breezy
35
35
from breezy import (
62
62
from breezy.i18n import gettext
63
63
""")
64
64
 
65
 
from breezy.trace import (
 
65
from .trace import (
66
66
    mutter,
67
67
    note,
68
68
    )
69
69
 
70
 
from breezy import (
 
70
from . import (
71
71
    config,
72
72
    controldir,
73
73
    registry,
74
74
    )
75
 
from breezy.symbol_versioning import (
 
75
from .symbol_versioning import (
76
76
    deprecated_in,
77
77
    deprecated_method,
78
78
    )
592
592
            # directories and files are read-write for this user. This is
593
593
            # mostly a workaround for filesystems which lie about being able to
594
594
            # write to a directory (cygwin & win32)
595
 
            if (st.st_mode & 07777 == 00000):
 
595
            if (st.st_mode & 0o7777 == 00000):
596
596
                # FTP allows stat but does not return dir/file modes
597
597
                self._dir_mode = None
598
598
                self._file_mode = None
599
599
            else:
600
 
                self._dir_mode = (st.st_mode & 07777) | 00700
 
600
                self._dir_mode = (st.st_mode & 0o7777) | 0o0700
601
601
                # Remove the sticky and execute bits for files
602
 
                self._file_mode = self._dir_mode & ~07111
 
602
                self._file_mode = self._dir_mode & ~0o7111
603
603
 
604
604
    def _get_file_mode(self):
605
605
        """Return Unix mode for newly created files, or None.
925
925
 
926
926
        This might be a synthetic object for e.g. RemoteBranch and SVN.
927
927
        """
928
 
        from breezy.branch import BranchFormatMetadir
 
928
        from .branch import BranchFormatMetadir
929
929
        return BranchFormatMetadir.find_format(self, name=name)
930
930
 
931
931
    def _get_mkdir_mode(self):
936
936
 
937
937
    def get_branch_reference(self, name=None):
938
938
        """See BzrDir.get_branch_reference()."""
939
 
        from breezy.branch import BranchFormatMetadir
 
939
        from .branch import BranchFormatMetadir
940
940
        format = BranchFormatMetadir.find_format(self, name=name)
941
941
        return format.get_reference(self, name=name)
942
942
 
1031
1031
        Note: if you're going to open the working tree, you should just go
1032
1032
        ahead and try, and not ask permission first.
1033
1033
        """
1034
 
        from breezy.workingtree import WorkingTreeFormatMetaDir
 
1034
        from .workingtree import WorkingTreeFormatMetaDir
1035
1035
        try:
1036
1036
            WorkingTreeFormatMetaDir.find_format_string(self)
1037
1037
        except errors.NoWorkingTree:
1080
1080
 
1081
1081
    def open_repository(self, unsupported=False):
1082
1082
        """See BzrDir.open_repository."""
1083
 
        from breezy.repository import RepositoryFormatMetaDir
 
1083
        from .repository import RepositoryFormatMetaDir
1084
1084
        format = RepositoryFormatMetaDir.find_format(self)
1085
1085
        format.check_support_status(unsupported)
1086
1086
        return format.open(self, _found=True)
1088
1088
    def open_workingtree(self, unsupported=False,
1089
1089
            recommend_upgrade=True):
1090
1090
        """See BzrDir.open_workingtree."""
1091
 
        from breezy.workingtree import WorkingTreeFormatMetaDir
 
1091
        from .workingtree import WorkingTreeFormatMetaDir
1092
1092
        format = WorkingTreeFormatMetaDir.find_format(self)
1093
1093
        format.check_support_status(unsupported, recommend_upgrade,
1094
1094
            basedir=self.root_transport.base)
1285
1285
                    raise errors.NotBranchError(path=transport.base)
1286
1286
                if server_version != '2':
1287
1287
                    raise errors.NotBranchError(path=transport.base)
1288
 
            from breezy.remote import RemoteBzrDirFormat
 
1288
            from .remote import RemoteBzrDirFormat
1289
1289
            return RemoteBzrDirFormat()
1290
1290
 
1291
1291
    @classmethod
1292
1292
    def known_formats(cls):
1293
 
        from breezy.remote import RemoteBzrDirFormat
1294
 
        return set([RemoteBzrDirFormat()])
 
1293
        from .remote import RemoteBzrDirFormat
 
1294
        return {RemoteBzrDirFormat()}
1295
1295
 
1296
1296
 
1297
1297
class BzrDirFormat(BzrFormat, controldir.ControlDirFormat):
1323
1323
            # Current RPC's only know how to create bzr metadir1 instances, so
1324
1324
            # we still delegate to vfs methods if the requested format is not a
1325
1325
            # metadir1
1326
 
            if type(self) != BzrDirMetaFormat1:
 
1326
            if not isinstance(self, BzrDirMetaFormat1):
1327
1327
                return self._initialize_on_transport_vfs(transport)
1328
 
            from breezy.remote import RemoteBzrDirFormat
 
1328
            from .remote import RemoteBzrDirFormat
1329
1329
            remote_format = RemoteBzrDirFormat()
1330
1330
            self._supply_sub_formats_to(remote_format)
1331
1331
            return remote_format.initialize_on_transport(transport)
1369
1369
            except errors.NoSmartMedium:
1370
1370
                pass
1371
1371
            else:
1372
 
                from breezy.remote import RemoteBzrDirFormat
 
1372
                from .remote import RemoteBzrDirFormat
1373
1373
                # TODO: lookup the local format from a server hint.
1374
1374
                remote_dir_format = RemoteBzrDirFormat()
1375
1375
                remote_dir_format._network_name = self.network_name()
1560
1560
 
1561
1561
    def get_branch_format(self):
1562
1562
        if self._branch_format is None:
1563
 
            from breezy.branch import format_registry as branch_format_registry
 
1563
            from .branch import format_registry as branch_format_registry
1564
1564
            self._branch_format = branch_format_registry.get_default()
1565
1565
        return self._branch_format
1566
1566
 
1647
1647
            if target_branch is None:
1648
1648
                if do_upgrade:
1649
1649
                    # TODO: bad monkey, hard-coded formats...
1650
 
                    from breezy.branch import BzrBranchFormat7
 
1650
                    from .branch import BzrBranchFormat7
1651
1651
                    new_branch_format = BzrBranchFormat7()
1652
1652
            else:
1653
1653
                new_branch_format = target_branch._format
1664
1664
        """See BzrDirFormat.get_converter()."""
1665
1665
        if format is None:
1666
1666
            format = BzrDirFormat.get_default_format()
1667
 
        if (type(self) is BzrDirMetaFormat1 and
1668
 
            type(format) is BzrDirMetaFormat1Colo):
 
1667
        if (isinstance(self, BzrDirMetaFormat1) and
 
1668
            isinstance(format, BzrDirMetaFormat1Colo)):
1669
1669
            return ConvertMetaToColo(format)
1670
 
        if (type(self) is BzrDirMetaFormat1Colo and
1671
 
            type(format) is BzrDirMetaFormat1):
 
1670
        if (isinstance(self, BzrDirMetaFormat1Colo) and
 
1671
            isinstance(format, BzrDirMetaFormat1)):
1672
1672
            return ConvertMetaToColo(format)
1673
1673
        if not isinstance(self, format.__class__):
1674
1674
            # converting away from metadir is not implemented
1697
1697
        """Circular import protection."""
1698
1698
        if self._repository_format:
1699
1699
            return self._repository_format
1700
 
        from breezy.repository import format_registry
 
1700
        from .repository import format_registry
1701
1701
        return format_registry.get_default()
1702
1702
 
1703
1703
    def _set_repository_format(self, value):
1728
1728
 
1729
1729
    def __get_workingtree_format(self):
1730
1730
        if self._workingtree_format is None:
1731
 
            from breezy.workingtree import (
 
1731
            from .workingtree import (
1732
1732
                format_registry as wt_format_registry,
1733
1733
                )
1734
1734
            self._workingtree_format = wt_format_registry.get_default()
1801
1801
            pass
1802
1802
        else:
1803
1803
            if not isinstance(repo._format, self.target_format.repository_format.__class__):
1804
 
                from breezy.repository import CopyConverter
 
1804
                from .repository import CopyConverter
1805
1805
                ui.ui_factory.note(gettext('starting repository conversion'))
1806
1806
                converter = CopyConverter(self.target_format.repository_format)
1807
1807
                converter.convert(repo, pb)
2092
2092
        mod_name, factory_name = full_name.rsplit('.', 1)
2093
2093
        try:
2094
2094
            factory = pyutils.get_named_object(mod_name, factory_name)
2095
 
        except ImportError, e:
 
2095
        except ImportError as e:
2096
2096
            raise ImportError('failed to load %s: %s' % (full_name, e))
2097
2097
        except AttributeError:
2098
2098
            raise AttributeError('no factory %s in module %r'