diff --git a/swh/loader/mercurial/loader.py b/swh/loader/mercurial/loader.py --- a/swh/loader/mercurial/loader.py +++ b/swh/loader/mercurial/loader.py @@ -25,12 +25,13 @@ from shutil import rmtree from tempfile import mkdtemp import time -from typing import Dict, Iterable, List, Optional +from typing import Any, Dict, Iterable, List, Optional import billiard from dateutil import parser import hglib +from swh.core.config import merge_configs from swh.loader.core.loader import DVCSLoader from swh.loader.core.utils import clean_dangling_folders from swh.model import identifiers @@ -77,22 +78,21 @@ pass +DEFAULT_CONFIG: Dict[str, Any] = { + "bundle_filename": "HG20_none_bundle", + "reduce_effort": False, + "temp_directory": "/tmp", + "cache1_size": 800 * 1024 * 1024, + "cache2_size": 800 * 1024 * 1024, + "clone_timeout_seconds": 7200, +} + + class HgBundle20Loader(DVCSLoader): """Mercurial loader able to deal with remote or local repository. """ - CONFIG_BASE_FILENAME = "loader/mercurial" - - ADDITIONAL_CONFIG = { - "bundle_filename": ("str", "HG20_none_bundle"), - "reduce_effort": ("bool", False), - "temp_directory": ("str", "/tmp"), - "cache1_size": ("int", 800 * 1024 * 1024), - "cache2_size": ("int", 800 * 1024 * 1024), - "clone_timeout_seconds": ("int", 7200), - } - visit_type = "hg" def __init__( @@ -103,6 +103,7 @@ logging_class="swh.loader.mercurial.Bundle20Loader", ): super().__init__(logging_class=logging_class) + self.config = merge_configs(DEFAULT_CONFIG, self.config) self.origin_url = url self.visit_date = visit_date self.directory = directory diff --git a/swh/loader/mercurial/tests/test_tasks.py b/swh/loader/mercurial/tests/test_tasks.py --- a/swh/loader/mercurial/tests/test_tasks.py +++ b/swh/loader/mercurial/tests/test_tasks.py @@ -1,10 +1,12 @@ -# Copyright (C) 2018-2019 The Software Heritage developers +# Copyright (C) 2018-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -def test_loader(mocker, swh_scheduler_celery_app, swh_scheduler_celery_worker): +def test_loader( + mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker +): mock_loader = mocker.patch("swh.loader.mercurial.loader.HgBundle20Loader.load") mock_loader.return_value = {"status": "eventful"} @@ -21,7 +23,9 @@ mock_loader.assert_called_once_with() -def test_archive_loader(mocker, swh_scheduler_celery_app, swh_scheduler_celery_worker): +def test_archive_loader( + mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker +): mock_loader = mocker.patch( "swh.loader.mercurial.loader.HgArchiveBundle20Loader.load" )