Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/hgutil.py
# Copyright (C) 2020-2021 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 | |||||
import io | import io | ||||
import traceback | |||||
from multiprocessing import Process, Queue | from multiprocessing import Process, Queue | ||||
import traceback | |||||
from typing import Dict, NewType | from typing import Dict, NewType | ||||
# The internal Mercurial API is not guaranteed to be stable. | # The internal Mercurial API is not guaranteed to be stable. | ||||
from mercurial import context, hg, util # type: ignore | |||||
import mercurial.ui # type: ignore | import mercurial.ui # type: ignore | ||||
from mercurial import context, hg, util | |||||
NULLID = mercurial.node.nullid | NULLID = mercurial.node.nullid | ||||
HgNodeId = NewType("HgNodeId", bytes) | HgNodeId = NewType("HgNodeId", bytes) | ||||
Repository = hg.localrepo | Repository = hg.localrepo | ||||
BaseContext = context.basectx | BaseContext = context.basectx | ||||
LRUCacheDict = util.lrucachedict | LRUCacheDict = util.lrucachedict | ||||
Show All 24 Lines | def _clone_task(src: str, dest: str, errors: Queue) -> None: | ||||
"""Clone task to run in a subprocess. | """Clone task to run in a subprocess. | ||||
Args: | Args: | ||||
src: clone source | src: clone source | ||||
dest: clone destination | dest: clone destination | ||||
errors: message queue to communicate errors | errors: message queue to communicate errors | ||||
""" | """ | ||||
try: | try: | ||||
hg.clone(mercurial.ui.ui.load(), {}, src.encode(), dest.encode()) | hg.clone( | ||||
ui=mercurial.ui.ui.load(), | |||||
peeropts={}, | |||||
source=src.encode(), | |||||
dest=dest.encode(), | |||||
update=False, | |||||
) | |||||
except Exception as e: | except Exception as e: | ||||
exc_buffer = io.StringIO() | exc_buffer = io.StringIO() | ||||
traceback.print_exc(file=exc_buffer) | traceback.print_exc(file=exc_buffer) | ||||
errors.put_nowait(exc_buffer.getvalue()) | errors.put_nowait(exc_buffer.getvalue()) | ||||
raise e | raise e | ||||
def clone(src: str, dest: str, timeout: int) -> None: | def clone(src: str, dest: str, timeout: int) -> None: | ||||
Show All 21 Lines |