view tests/test-storage.py @ 39859:32d3ed3023bb

upgrade: use rawsize() instead of revlog index The revlog index is a very low-level data structure and it shouldn't be exposed to the storage interface - at least not in its current form. upgrade.py is the only consumer of the index attribute on file storage in the repository. This commit rewrites that final consumer to use rawsize() instead of going through the index. This is actually the more proper API to use, as rawsize() will accurately report the size of revisions which have a negative size in the index. Differential Revision: https://phab.mercurial-scm.org/D4719
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 24 Sep 2018 09:38:27 -0700
parents ae531f5e583c
children a3a9b93bff80
line wrap: on
line source

# This test verifies the conformance of various classes to various
# storage interfaces.
from __future__ import absolute_import

import silenttestrunner

from mercurial import (
    filelog,
    transaction,
    ui as uimod,
    vfs as vfsmod,
)

from mercurial.testing import (
    storage as storagetesting,
)

STATE = {
    'lastindex': 0,
    'ui': uimod.ui(),
    'vfs': vfsmod.vfs(b'.', realpath=True),
}

def makefilefn(self):
    """Factory for filelog instances."""
    fl = filelog.filelog(STATE['vfs'], 'filelog-%d' % STATE['lastindex'])
    STATE['lastindex'] += 1
    return fl

def maketransaction(self):
    vfsmap = {'plain': STATE['vfs']}

    return transaction.transaction(STATE['ui'].warn, STATE['vfs'], vfsmap,
                                  'journal', 'undo')

# Assigning module-level attributes that inherit from unittest.TestCase
# is all that is needed to register tests.
filelogindextests = storagetesting.makeifileindextests(makefilefn,
                                                       maketransaction)
filelogdatatests = storagetesting.makeifiledatatests(makefilefn,
                                                     maketransaction)
filelogmutationtests = storagetesting.makeifilemutationtests(makefilefn,
                                                             maketransaction)

if __name__ == '__main__':
    silenttestrunner.main(__name__)