Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/loader.py
Show All 19 Lines | |||||
import datetime | import datetime | ||||
import os | import os | ||||
from queue import Empty | from queue import Empty | ||||
import random | import random | ||||
import re | import re | ||||
from shutil import rmtree | from shutil import rmtree | ||||
from tempfile import mkdtemp | from tempfile import mkdtemp | ||||
import time | import time | ||||
from typing import Dict, Iterable, List, Optional | from typing import Any, Dict, Iterable, List, Optional | ||||
import billiard | import billiard | ||||
from dateutil import parser | from dateutil import parser | ||||
import hglib | import hglib | ||||
from swh.core.config import merge_configs | |||||
from swh.loader.core.loader import DVCSLoader | from swh.loader.core.loader import DVCSLoader | ||||
from swh.loader.core.utils import clean_dangling_folders | from swh.loader.core.utils import clean_dangling_folders | ||||
from swh.model import identifiers | from swh.model import identifiers | ||||
from swh.model.hashutil import ( | from swh.model.hashutil import ( | ||||
DEFAULT_ALGORITHMS, | DEFAULT_ALGORITHMS, | ||||
MultiHash, | MultiHash, | ||||
hash_to_bytehex, | hash_to_bytehex, | ||||
hash_to_bytes, | hash_to_bytes, | ||||
Show All 30 Lines | |||||
HEAD_POINTER_NAME = b"tip" | HEAD_POINTER_NAME = b"tip" | ||||
class CloneTimeoutError(Exception): | class CloneTimeoutError(Exception): | ||||
pass | 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): | class HgBundle20Loader(DVCSLoader): | ||||
"""Mercurial loader able to deal with remote or local repository. | """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" | visit_type = "hg" | ||||
def __init__( | def __init__( | ||||
self, | self, | ||||
url, | url, | ||||
visit_date=None, | visit_date=None, | ||||
directory=None, | directory=None, | ||||
logging_class="swh.loader.mercurial.Bundle20Loader", | logging_class="swh.loader.mercurial.Bundle20Loader", | ||||
): | ): | ||||
super().__init__(logging_class=logging_class) | super().__init__(logging_class=logging_class) | ||||
self.config = merge_configs(DEFAULT_CONFIG, self.config) | |||||
self.origin_url = url | self.origin_url = url | ||||
self.visit_date = visit_date | self.visit_date = visit_date | ||||
self.directory = directory | self.directory = directory | ||||
self.bundle_filename = self.config["bundle_filename"] | self.bundle_filename = self.config["bundle_filename"] | ||||
self.reduce_effort_flag = self.config["reduce_effort"] | self.reduce_effort_flag = self.config["reduce_effort"] | ||||
self.empty_repository = None | self.empty_repository = None | ||||
self.temp_directory = self.config["temp_directory"] | self.temp_directory = self.config["temp_directory"] | ||||
self.cache1_size = self.config["cache1_size"] | self.cache1_size = self.config["cache1_size"] | ||||
▲ Show 20 Lines • Show All 527 Lines • Show Last 20 Lines |