mercurial/revlogutils/revlogv0.py
changeset 47400 ac60a1366a49
parent 47279 9d1a8829f959
child 47403 8f87dcb46f53
equal deleted inserted replaced
47399:7a0ec25d5836 47400:ac60a1366a49
    16 
    16 
    17 from .. import (
    17 from .. import (
    18     error,
    18     error,
    19     node,
    19     node,
    20     pycompat,
    20     pycompat,
       
    21     revlogutils,
    21     util,
    22     util,
    22 )
    23 )
    23 
    24 
    24 from . import (
    25 from . import (
    25     flagutil,
    26     flagutil,
    31     return int(q >> 16)
    32     return int(q >> 16)
    32 
    33 
    33 
    34 
    34 def gettype(q):
    35 def gettype(q):
    35     return int(q & 0xFFFF)
    36     return int(q & 0xFFFF)
    36 
       
    37 
       
    38 def offset_type(offset, type):
       
    39     if (type & ~flagutil.REVIDX_KNOWN_FLAGS) != 0:
       
    40         raise ValueError(b'unknown revlog index flags')
       
    41     return int(int(offset) << 16 | type)
       
    42 
    37 
    43 
    38 
    44 class revlogoldindex(list):
    39 class revlogoldindex(list):
    45     rust_ext_compat = 0
    40     rust_ext_compat = 0
    46     entry_size = INDEX_ENTRY_V0.size
    41     entry_size = INDEX_ENTRY_V0.size
   141         cur = data[off : off + s]
   136         cur = data[off : off + s]
   142         off += s
   137         off += s
   143         e = INDEX_ENTRY_V0.unpack(cur)
   138         e = INDEX_ENTRY_V0.unpack(cur)
   144         # transform to revlogv1 format
   139         # transform to revlogv1 format
   145         e2 = (
   140         e2 = (
   146             offset_type(e[0], 0),
   141             revlogutils.offset_type(e[0], 0),
   147             e[1],
   142             e[1],
   148             -1,
   143             -1,
   149             e[2],
   144             e[2],
   150             e[3],
   145             e[3],
   151             nodemap.get(e[4], node.nullrev),
   146             nodemap.get(e[4], node.nullrev),