view tests/testlib/ext-stream-clone-steps.py @ 52390:11484a19cd77

stream: rename all test hook point one number up This leave room for a new hook point earlier to detect some race condition with caches.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 04 Dec 2024 17:13:39 +0100
parents c2633c69cbe0
children 3f0cf7bb3086
line wrap: on
line source

# A utility extension that help taking a break during streamclone operation
#
# This extension is used through two environment variable
#
# HG_TEST_STREAM_WALKED_FILE_3
#
#   path of a file created by the process generating the streaming clone when
#   it is done gathering data and is ready to unlock the repository and move
#   to the streaming of content.
#
# HG_TEST_STREAM_WALKED_FILE_4
#
#   path of a file to be manually created to let the process generating the
#   streaming clone proceed to streaming file content.

from mercurial import (
    encoding,
    extensions,
    streamclone,
    testing,
)


WALKED_FILE_3 = encoding.environ[b'HG_TEST_STREAM_WALKED_FILE_3']
WALKED_FILE_4 = encoding.environ[b'HG_TEST_STREAM_WALKED_FILE_4']


def _test_sync_point_walk_3(orig, repo):
    testing.write_file(WALKED_FILE_3)


def _test_sync_point_walk_4(orig, repo):
    assert repo._currentlock(repo._lockref) is None
    testing.wait_file(WALKED_FILE_4)


def uisetup(ui):
    extensions.wrapfunction(
        streamclone, '_test_sync_point_walk_3', _test_sync_point_walk_3
    )

    extensions.wrapfunction(
        streamclone, '_test_sync_point_walk_4', _test_sync_point_walk_4
    )