Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/hgutil.py
import io | import io | ||||
import traceback | import traceback | ||||
from multiprocessing import Process, Queue | from multiprocessing import Process, Queue | ||||
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. | ||||
import mercurial.ui # type: ignore | import mercurial.ui # type: ignore | ||||
from mercurial import context, hg | 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 | |||||
def repository(path: str) -> hg.localrepo: | def repository(path: str) -> hg.localrepo: | ||||
ui = mercurial.ui.ui.load() | ui = mercurial.ui.ui.load() | ||||
return hg.repository(ui, path.encode()) | return hg.repository(ui, path.encode()) | ||||
def branches(repo: hg.localrepo) -> Dict[bytes, HgNodeId]: | def branches(repo: hg.localrepo) -> Dict[bytes, HgNodeId]: | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |