/breezy-svn/trunk

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy-svn/trunk

« back to all changes in this revision

Viewing changes to remote.py

  • Committer: Jelmer Vernooij
  • Date: 2020-01-31 19:40:01 UTC
  • Revision ID: jelmer@jelmer.uk-20200131194001-ri4z8wyq0cvymo20
More python3/breezy compat fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
        import subvertpy
108
108
        try:
109
109
            return SvnRemoteAccess(transport, self)
110
 
        except subvertpy.SubversionException, (_, num):
111
 
            if num in (subvertpy.ERR_RA_DAV_REQUEST_FAILED,
112
 
                       subvertpy.ERR_RA_DAV_NOT_VCC,
113
 
                       subvertpy.ERR_RA_LOCAL_REPOS_OPEN_FAILED):
 
110
        except subvertpy.SubversionException as e:
 
111
            if e.args[1] in (
 
112
                    subvertpy.ERR_RA_DAV_REQUEST_FAILED,
 
113
                    subvertpy.ERR_RA_DAV_NOT_VCC,
 
114
                    subvertpy.ERR_RA_LOCAL_REPOS_OPEN_FAILED):
114
115
                raise errors.NotBranchError(transport.base)
115
 
            if num == subvertpy.ERR_XML_MALFORMED:
 
116
            if e.args[1] == subvertpy.ERR_XML_MALFORMED:
116
117
                # This *could* be an indication of an actual corrupt
117
118
                # svn server, but usually it just means a broken
118
119
                # xml page
165
166
        import os
166
167
        import subvertpy
167
168
        from subvertpy import repos
 
169
        # For subvertpy < 0.8.6
168
170
        ERR_REPOS_BAD_ARGS = getattr(subvertpy, "ERR_REPOS_BAD_ARGS", 165002)
169
 
        # For subvertpy < 0.8.6
170
171
 
171
172
        if not isinstance(transport, LocalTransport):
172
173
            raise UninitializableOnRemoteTransports(self)
173
174
 
174
 
        local_path = transport.local_abspath(".").rstrip("/").encode(osutils._fs_enc)
175
 
        assert type(local_path) == str
 
175
        local_path = transport.local_abspath(".").rstrip("/").encode(
 
176
            osutils._fs_enc)
176
177
        try:
177
178
            repos.create(local_path)
178
 
        except subvertpy.SubversionException, (_, num):
179
 
            if num == subvertpy.ERR_DIR_NOT_EMPTY:
 
179
        except subvertpy.SubversionException as e:
 
180
            if e.args[1] == subvertpy.ERR_DIR_NOT_EMPTY:
180
181
                raise errors.BzrError("Directory is not empty")
181
 
            if num == ERR_REPOS_BAD_ARGS:
 
182
            if e.args[1] == ERR_REPOS_BAD_ARGS:
182
183
                raise errors.AlreadyControlDirError(local_path)
183
184
            raise
184
185
        # All revision property changes
185
 
        revprop_hook = os.path.join(local_path, "hooks", "pre-revprop-change")
 
186
        revprop_hook = os.path.join(
 
187
            local_path, b"hooks", b"pre-revprop-change")
186
188
        open(revprop_hook, 'w').write("#!/bin/sh")
187
 
        os.chmod(revprop_hook, os.stat(revprop_hook).st_mode | 0111)
 
189
        os.chmod(revprop_hook, os.stat(revprop_hook).st_mode | 0o111)
188
190
        return self.open(transport, _found=True)
189
191
 
190
192
    def supports_transport(self, transport):
582
584
                with ce.open_root() as root:
583
585
                    try:
584
586
                        root.delete_entry(basename)
585
 
                    except subvertpy.SubversionException, (_, num):
586
 
                        if num == subvertpy.ERR_FS_TXN_OUT_OF_DATE:
 
587
                    except subvertpy.SubversionException as e:
 
588
                        if e.args[1] == subvertpy.ERR_FS_TXN_OUT_OF_DATE:
587
589
                            # Make sure the branch still exists
588
590
                            self.open_branch(branch_name)
589
591
                        raise