comparison mercurial/error.py @ 43077:687b865b95ad

formatting: byteify all mercurial/ and hgext/ string literals Done with python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py') black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**') # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6972
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:48:39 -0400
parents 2372284d9457
children 40bf3d7ecc42
comparison
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
71 self.lookupmessage = message 71 self.lookupmessage = message
72 if isinstance(name, bytes) and len(name) == 20: 72 if isinstance(name, bytes) and len(name) == 20:
73 from .node import short 73 from .node import short
74 74
75 name = short(name) 75 name = short(name)
76 RevlogError.__init__(self, '%s@%s: %s' % (index, name, message)) 76 RevlogError.__init__(self, b'%s@%s: %s' % (index, name, message))
77 77
78 def __bytes__(self): 78 def __bytes__(self):
79 return RevlogError.__bytes__(self) 79 return RevlogError.__bytes__(self)
80 80
81 def __str__(self): 81 def __str__(self):
148 """Raised when an EOF is received for a prompt""" 148 """Raised when an EOF is received for a prompt"""
149 149
150 def __init__(self): 150 def __init__(self):
151 from .i18n import _ 151 from .i18n import _
152 152
153 Abort.__init__(self, _('response expected')) 153 Abort.__init__(self, _(b'response expected'))
154 154
155 155
156 class OutOfBandError(Hint, Exception): 156 class OutOfBandError(Hint, Exception):
157 """Exception raised when a remote repo reports failure""" 157 """Exception raised when a remote repo reports failure"""
158 158
173 """Exception raised when a {rev,file}set references an unknown identifier""" 173 """Exception raised when a {rev,file}set references an unknown identifier"""
174 174
175 def __init__(self, function, symbols): 175 def __init__(self, function, symbols):
176 from .i18n import _ 176 from .i18n import _
177 177
178 ParseError.__init__(self, _("unknown identifier: %s") % function) 178 ParseError.__init__(self, _(b"unknown identifier: %s") % function)
179 self.function = function 179 self.function = function
180 self.symbols = symbols 180 self.symbols = symbols
181 181
182 182
183 class RepoError(Hint, Exception): 183 class RepoError(Hint, Exception):
212 class UnsupportedMergeRecords(Abort): 212 class UnsupportedMergeRecords(Abort):
213 def __init__(self, recordtypes): 213 def __init__(self, recordtypes):
214 from .i18n import _ 214 from .i18n import _
215 215
216 self.recordtypes = sorted(recordtypes) 216 self.recordtypes = sorted(recordtypes)
217 s = ' '.join(self.recordtypes) 217 s = b' '.join(self.recordtypes)
218 Abort.__init__( 218 Abort.__init__(
219 self, 219 self,
220 _('unsupported merge state records: %s') % s, 220 _(b'unsupported merge state records: %s') % s,
221 hint=_( 221 hint=_(
222 'see https://mercurial-scm.org/wiki/MergeStateRecords for ' 222 b'see https://mercurial-scm.org/wiki/MergeStateRecords for '
223 'more information' 223 b'more information'
224 ), 224 ),
225 ) 225 )
226 226
227 227
228 class UnknownVersion(Abort): 228 class UnknownVersion(Abort):
242 # no __bytes__() because error message is derived from the standard IOError 242 # no __bytes__() because error message is derived from the standard IOError
243 243
244 244
245 class LockHeld(LockError): 245 class LockHeld(LockError):
246 def __init__(self, errno, filename, desc, locker): 246 def __init__(self, errno, filename, desc, locker):
247 LockError.__init__(self, errno, 'Lock held', filename, desc) 247 LockError.__init__(self, errno, b'Lock held', filename, desc)
248 self.locker = locker 248 self.locker = locker
249 249
250 250
251 class LockUnavailable(LockError): 251 class LockUnavailable(LockError):
252 pass 252 pass
320 def __init__(self, parttype=None, params=(), values=()): 320 def __init__(self, parttype=None, params=(), values=()):
321 self.parttype = parttype 321 self.parttype = parttype
322 self.params = params 322 self.params = params
323 self.values = values 323 self.values = values
324 if self.parttype is None: 324 if self.parttype is None:
325 msg = 'Stream Parameter' 325 msg = b'Stream Parameter'
326 else: 326 else:
327 msg = parttype 327 msg = parttype
328 entries = self.params 328 entries = self.params
329 if self.params and self.values: 329 if self.params and self.values:
330 assert len(self.params) == len(self.values) 330 assert len(self.params) == len(self.values)
332 for idx, par in enumerate(self.params): 332 for idx, par in enumerate(self.params):
333 val = self.values[idx] 333 val = self.values[idx]
334 if val is None: 334 if val is None:
335 entries.append(val) 335 entries.append(val)
336 else: 336 else:
337 entries.append("%s=%r" % (par, pycompat.maybebytestr(val))) 337 entries.append(b"%s=%r" % (par, pycompat.maybebytestr(val)))
338 if entries: 338 if entries:
339 msg = '%s - %s' % (msg, ', '.join(entries)) 339 msg = b'%s - %s' % (msg, b', '.join(entries))
340 ValueError.__init__(self, msg) 340 ValueError.__init__(self, msg)
341 341
342 342
343 class ReadOnlyPartError(RuntimeError): 343 class ReadOnlyPartError(RuntimeError):
344 """error raised when code tries to alter a part being generated""" 344 """error raised when code tries to alter a part being generated"""
358 self.new = new 358 self.new = new
359 self.old = old 359 self.old = old
360 self.ret = ret 360 self.ret = ret
361 # no i18n expected to be processed into a better message 361 # no i18n expected to be processed into a better message
362 Abort.__init__( 362 Abort.__init__(
363 self, 'failed to update value for "%s/%s"' % (namespace, key) 363 self, b'failed to update value for "%s/%s"' % (namespace, key)
364 ) 364 )
365 365
366 366
367 class CensoredNodeError(StorageError): 367 class CensoredNodeError(StorageError):
368 """error raised when content verification fails on a censored node 368 """error raised when content verification fails on a censored node
371 """ 371 """
372 372
373 def __init__(self, filename, node, tombstone): 373 def __init__(self, filename, node, tombstone):
374 from .node import short 374 from .node import short
375 375
376 StorageError.__init__(self, '%s:%s' % (filename, short(node))) 376 StorageError.__init__(self, b'%s:%s' % (filename, short(node)))
377 self.tombstone = tombstone 377 self.tombstone = tombstone
378 378
379 379
380 class CensoredBaseError(StorageError): 380 class CensoredBaseError(StorageError):
381 """error raised when a delta is rejected because its base is censored 381 """error raised when a delta is rejected because its base is censored