comparison mercurial/revlog.py @ 7633:08cabecfa8a8

errors: move revlog errors - create error.py for exception classes to reduce demandloading - move revlog exceptions to it - change users to import error and drop revlog import if possible
author Matt Mackall <mpm@selenic.com>
date Sun, 11 Jan 2009 22:48:28 -0600
parents ec3aafa84d44
children 4a4c7f6a5912 baaa832fd253
comparison
equal deleted inserted replaced
7632:9626819b2e3d 7633:08cabecfa8a8
11 """ 11 """
12 12
13 from node import bin, hex, nullid, nullrev, short 13 from node import bin, hex, nullid, nullrev, short
14 from i18n import _ 14 from i18n import _
15 import changegroup, errno, ancestor, mdiff, parsers 15 import changegroup, errno, ancestor, mdiff, parsers
16 import struct, util, zlib 16 import struct, util, zlib, error
17 17
18 _pack = struct.pack 18 _pack = struct.pack
19 _unpack = struct.unpack 19 _unpack = struct.unpack
20 _compress = zlib.compress 20 _compress = zlib.compress
21 _decompress = zlib.decompress 21 _decompress = zlib.decompress
27 REVLOGNGINLINEDATA = (1 << 16) 27 REVLOGNGINLINEDATA = (1 << 16)
28 REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA 28 REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA
29 REVLOG_DEFAULT_FORMAT = REVLOGNG 29 REVLOG_DEFAULT_FORMAT = REVLOGNG
30 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS 30 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
31 31
32 class RevlogError(Exception): 32 RevlogError = error.RevlogError
33 pass 33 LookupError = error.LookupError
34
35 class LookupError(RevlogError, KeyError):
36 def __init__(self, name, index, message):
37 self.name = name
38 if isinstance(name, str) and len(name) == 20:
39 name = short(name)
40 RevlogError.__init__(self, _('%s@%s: %s') % (index, name, message))
41
42 def __str__(self):
43 return RevlogError.__str__(self)
44 34
45 def getoffset(q): 35 def getoffset(q):
46 return int(q >> 16) 36 return int(q >> 16)
47 37
48 def gettype(q): 38 def gettype(q):