tests/testlib/ext-sidedata.py
changeset 46114 59fa3890d40a
parent 46050 f105c49e89cd
child 46722 3d740058b467
equal deleted inserted replaced
46113:d6afa9c149c3 46114:59fa3890d40a
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 import hashlib
    10 import hashlib
    11 import struct
    11 import struct
    12 
    12 
       
    13 from mercurial.node import (
       
    14     nullid,
       
    15     nullrev,
       
    16 )
    13 from mercurial import (
    17 from mercurial import (
    14     extensions,
    18     extensions,
    15     node,
       
    16     requirements,
    19     requirements,
    17     revlog,
    20     revlog,
    18 )
    21 )
    19 
    22 
    20 from mercurial.upgrade_utils import engine as upgrade_engine
    23 from mercurial.upgrade_utils import engine as upgrade_engine
    39 
    42 
    40 def wraprevision(orig, self, nodeorrev, *args, **kwargs):
    43 def wraprevision(orig, self, nodeorrev, *args, **kwargs):
    41     text = orig(self, nodeorrev, *args, **kwargs)
    44     text = orig(self, nodeorrev, *args, **kwargs)
    42     if getattr(self, 'sidedatanocheck', False):
    45     if getattr(self, 'sidedatanocheck', False):
    43         return text
    46         return text
    44     if nodeorrev != node.nullrev and nodeorrev != node.nullid:
    47     if nodeorrev != nullrev and nodeorrev != nullid:
    45         sd = self.sidedata(nodeorrev)
    48         sd = self.sidedata(nodeorrev)
    46         if len(text) != struct.unpack('>I', sd[sidedata.SD_TEST1])[0]:
    49         if len(text) != struct.unpack('>I', sd[sidedata.SD_TEST1])[0]:
    47             raise RuntimeError('text size mismatch')
    50             raise RuntimeError('text size mismatch')
    48         expected = sd[sidedata.SD_TEST2]
    51         expected = sd[sidedata.SD_TEST2]
    49         got = hashlib.sha256(text).digest()
    52         got = hashlib.sha256(text).digest()