~cjwatson/brz-svn/fix-http-probe

« back to all changes in this revision

Viewing changes to errors.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-03 09:16:45 UTC
  • Revision ID: jelmer@jelmer.uk-20200203091645-q0f1yq77zkr1s3cz
More Python3 / formatting / breezy fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from __future__ import absolute_import
21
21
 
22
22
import subvertpy
23
 
import urllib
24
23
 
25
24
from breezy import (
26
25
    trace,
 
26
    urlutils,
27
27
    )
28
28
import breezy.errors
29
29
from breezy.errors import (
30
30
    BzrError,
31
31
    ConnectionError,
32
32
    ConnectionReset,
33
 
    DependencyNotPresent,
34
33
    DivergedBranches,
35
 
    InvalidRevisionSpec,
36
34
    LockActive,
37
35
    PermissionDenied,
38
36
    NoRepositoryPresent,
59
57
 
60
58
    def __init__(self, branch_path, mapping=None):
61
59
        BzrError.__init__(self)
62
 
        self.branch_path = urllib.quote(branch_path)
 
60
        self.branch_path = urlutils.quote(branch_path)
63
61
        self.mapping = mapping
64
62
 
65
63
 
127
125
    if num == subvertpy.ERR_RA_DAV_PROPPATCH_FAILED:
128
126
        return PropertyChangeFailed(msg)
129
127
    if (num > subvertpy.ERR_APR_OS_START_EAIERR and
130
 
        num < subvertpy.ERR_APR_OS_START_EAIERR + subvertpy.ERR_CATEGORY_SIZE):
 
128
            num < subvertpy.ERR_APR_OS_START_EAIERR +
 
129
            subvertpy.ERR_CATEGORY_SIZE):
131
130
        # Newer versions of subvertpy (>= 0.7.6) do this for us.
132
131
        return ConnectionError(msg=msg)
133
132
    else:
157
156
 
158
157
class InvalidPropertyValue(BzrError):
159
158
 
160
 
    _fmt = 'Invalid property value for Subversion property %(property)s: %(msg)s'
 
159
    _fmt = ('Invalid property value for Subversion property %(property)s: '
 
160
            '%(msg)s')
161
161
 
162
162
    def __init__(self, property, msg):
163
163
        BzrError.__init__(self)
167
167
 
168
168
class InvalidFileName(BzrError):
169
169
 
170
 
    _fmt = "Unable to convert Subversion path %(path)s because it contains characters invalid in Bazaar."
 
170
    _fmt = ("Unable to convert Subversion path %(path)s because it contains "
 
171
            "characters invalid in Bazaar.")
171
172
 
172
173
    def __init__(self, path):
173
174
        BzrError.__init__(self)
176
177
 
177
178
class SymlinkTargetContainsNewline(BzrError):
178
179
 
179
 
    _fmt = "Unable to convert target of symlink %(path)s because it contains newlines."
 
180
    _fmt = ("Unable to convert target of symlink %(path)s because "
 
181
            "it contains newlines.")
180
182
 
181
183
    def __init__(self, path):
182
184
        BzrError.__init__(self)
185
187
 
186
188
class CorruptMappingData(BzrError):
187
189
 
188
 
    _fmt = "An invalid change was made to the bzr-specific properties in %(path)s."
 
190
    _fmt = ("An invalid change was made to the bzr-specific "
 
191
            "properties in %(path)s.")
189
192
 
190
193
    def __init__(self, path):
191
194
        BzrError.__init__(self)
210
213
 
211
214
class FileIdMapIncomplete(BzrError):
212
215
 
213
 
    _fmt = "Unable to find file id for child '%(child)s' in '%(parent)s' in %(revmeta)r."
 
216
    _fmt = ("Unable to find file id for child '%(child)s' in '%(parent)s' "
 
217
            "in %(revmeta)r.")
214
218
 
215
219
    def __init__(self, child, parent, revmeta):
216
220
        BzrError.__init__(self)
274
278
 
275
279
class PropertyChangeFailed(BzrError):
276
280
 
277
 
    _fmt = """Unable to set DAV properties: %(msg)s. Perhaps LimitXMLRequestBody is set too low in the server."""
 
281
    _fmt = ("Unable to set DAV properties: %(msg)s. "
 
282
            "Perhaps LimitXMLRequestBody is set too low in the server.")
278
283
 
279
284
    def __init__(self, msg):
280
285
        BzrError.__init__(self, msg=msg)
282
287
 
283
288
class RequiresMetadataInFileProps(BzrError):
284
289
 
285
 
    _fmt = """This operation requires storing bzr-svn metadata in Subversion file properties. These file properties may cause spurious conflicts for other Subversion users during merges. To allow this, set `allow_metadata_in_file_properties = True` in your configuration and try again."""
 
290
    _fmt = ("This operation requires storing bzr-svn metadata in Subversion "
 
291
            "file properties. These file properties may cause spurious "
 
292
            "conflicts for other Subversion users during merges. "
 
293
            "To allow this, set "
 
294
            "`allow_metadata_in_file_properties = True` in your "
 
295
            "configuration and try again.")
286
296
 
287
297
 
288
298
class TextChecksumMismatch(VersionedFileInvalidChecksum):
289
299
 
290
 
    _fmt = """checksum mismatch: %(expected_checksum)r != %(actual_checksum)r in %(path)s:%(revnum)d"""
 
300
    _fmt = ("checksum mismatch: %(expected_checksum)r != %(actual_checksum)r "
 
301
            "in %(path)s:%(revnum)d")
291
302
 
292
303
    def __init__(self, expected_checksum, actual_checksum, path, revnum):
293
304
        self.expected_checksum = expected_checksum
298
309
 
299
310
class SubversionBranchDiverged(DivergedBranches):
300
311
 
301
 
    _fmt = "Subversion branch at %(branch_path)s has diverged from %(source_repo)r."
 
312
    _fmt = ("Subversion branch at %(branch_path)s has diverged "
 
313
            "from %(source_repo)r.")
302
314
 
303
 
    def __init__(self, source_repo, source_revid, target_repo, branch_path, target_revid):
 
315
    def __init__(self, source_repo, source_revid, target_repo, branch_path,
 
316
                 target_revid):
304
317
        self.branch_path = branch_path
305
318
        self.target_repo = target_repo
306
319
        self.source_repo = source_repo
310
323
 
311
324
class NoLayoutTagSetSupport(TagsNotSupported):
312
325
 
313
 
    _fmt = "Creating tags is not possible with the current layout %(layout)r%(extra)s"
 
326
    _fmt = ("Creating tags is not possible with the current layout "
 
327
            "%(layout)r%(extra)s")
314
328
 
315
329
    def __init__(self, layout, extra=None):
316
330
        self.layout = layout
329
343
 
330
344
 
331
345
_reuse_uuids_warned = set()
 
346
 
 
347
 
332
348
def warn_uuid_reuse(uuid, location):
333
349
    """Warn that a UUID is being reused for different repositories."""
334
350
    global _reuse_uuids_warned
335
351
    if uuid in _reuse_uuids_warned:
336
352
        return
337
 
    trace.warning("Repository with UUID %s at %s contains fewer revisions "
338
 
         "than cache. This either means that this repository contains an out "
339
 
         "of date mirror of another repository (harmless), or that the UUID "
340
 
         "is being used for two different Subversion repositories ("
341
 
         "potential repository corruption).",
342
 
         uuid, location)
 
353
    trace.warning(
 
354
        "Repository with UUID %s at %s contains fewer revisions "
 
355
        "than cache. This either means that this repository contains an out "
 
356
        "of date mirror of another repository (harmless), or that the UUID "
 
357
        "is being used for two different Subversion repositories ("
 
358
        "potential repository corruption).",
 
359
        uuid, location)
343
360
    _reuse_uuids_warned.add(uuid)