tests/test-revlog-raw.py
changeset 47214 906a7bcaac86
parent 47150 8d3c2f9d4af7
child 48529 c514936d92b4
equal deleted inserted replaced
47213:100f061d88f6 47214:906a7bcaac86
    16 from mercurial.revlogutils import (
    16 from mercurial.revlogutils import (
    17     constants,
    17     constants,
    18     deltas,
    18     deltas,
    19     flagutil,
    19     flagutil,
    20 )
    20 )
       
    21 
       
    22 
       
    23 class _NoTransaction(object):
       
    24     """transaction like object to update the nodemap outside a transaction"""
       
    25 
       
    26     def __init__(self):
       
    27         self._postclose = {}
       
    28 
       
    29     def addpostclose(self, callback_id, callback_func):
       
    30         self._postclose[callback_id] = callback_func
       
    31 
       
    32     def registertmp(self, *args, **kwargs):
       
    33         pass
       
    34 
       
    35     def addbackup(self, *args, **kwargs):
       
    36         pass
       
    37 
       
    38     def add(self, *args, **kwargs):
       
    39         pass
       
    40 
       
    41     def addabort(self, *args, **kwargs):
       
    42         pass
       
    43 
       
    44     def _report(self, *args):
       
    45         pass
       
    46 
    21 
    47 
    22 # TESTTMP is optional. This makes it convenient to run without run-tests.py
    48 # TESTTMP is optional. This makes it convenient to run without run-tests.py
    23 tvfs = vfs.vfs(encoding.environ.get(b'TESTTMP', b'/tmp'))
    49 tvfs = vfs.vfs(encoding.environ.get(b'TESTTMP', b'/tmp'))
    24 
    50 
    25 # Enable generaldelta otherwise revlog won't use delta as expected by the test
    51 # Enable generaldelta otherwise revlog won't use delta as expected by the test
   199                 ]
   225                 ]
   200             )
   226             )
   201             text = None
   227             text = None
   202             cachedelta = (deltaparent, rlog.revdiff(deltaparent, r))
   228             cachedelta = (deltaparent, rlog.revdiff(deltaparent, r))
   203         flags = rlog.flags(r)
   229         flags = rlog.flags(r)
   204         ifh = dfh = None
   230         with dlog._writing(_NoTransaction()):
   205         try:
       
   206             ifh = dlog.opener(dlog._indexfile, b'a+')
       
   207             if not dlog._inline:
       
   208                 dfh = dlog.opener(dlog._datafile, b'a+')
       
   209             dlog._addrevision(
   231             dlog._addrevision(
   210                 rlog.node(r), text, tr, r, p1, p2, flags, cachedelta, ifh, dfh
   232                 rlog.node(r),
       
   233                 text,
       
   234                 tr,
       
   235                 r,
       
   236                 p1,
       
   237                 p2,
       
   238                 flags,
       
   239                 cachedelta,
   211             )
   240             )
   212         finally:
       
   213             if dfh is not None:
       
   214                 dfh.close()
       
   215             if ifh is not None:
       
   216                 ifh.close()
       
   217     return dlog
   241     return dlog
   218 
   242 
   219 
   243 
   220 # Utilities to generate revisions for testing
   244 # Utilities to generate revisions for testing
   221 
   245