refactor: split core.upstream by subject

HTTP to the forges moves to core.forgehttp, comparisons, trees and
clone history to core.upstreamtree. core.upstream keeps repositories,
the cache and revisions.
This commit is contained in:
Abdessamad Derraz committed 2026-11-24 06:20:52 +01:00
1 parent ce92eff0aa
commit 263a64c0e0
65 files changed
+1417 -1337

No files matched your search

+3 -3
View File
@@ -12,7 +12,7 @@ from dataclasses import dataclass, field
from pathlib import Path
from acquire.placement import ACQUIRE_DIR, Placement, keep_acquired, place_file
from core import upstream
from core import forgehttp
from core.hashing import parse_hash_list
from core.paths import EMULATORS_DIR, PLATFORMS_DIR, REPO_ROOT
from resolve.lookup import held_record_for
@@ -193,10 +193,10 @@ def _get(url: str, unanswered: list[str], timeout: float = 30) -> bytes | None:
report every file as needing a community contribution.
"""
try:
return upstream.fetch_body(
return forgehttp.fetch_body(
url, timeout=timeout, max_bytes=MAX_DOWNLOAD, user_agent="retrobios-fetch/1.0"
)
except upstream.UpstreamError as exc:
except forgehttp.UpstreamError as exc:
unanswered.append(f"{url}: {exc}")
except ValueError:
pass
+2 -1
View File
@@ -5,6 +5,7 @@ from __future__ import annotations
import hashlib
from core import upstream
from core import forgehttp
# Commits listed per page and the most pages walked: a data file older than
@@ -34,7 +35,7 @@ def find_revision(
"""The newest revision whose copy of the path has this md5, and its bytes."""
wanted = md5.lower()
for sha in path_history(repo, path, cache_dir):
data = upstream.fetch_body(upstream.content_url(repo, sha, path))
data = forgehttp.fetch_body(upstream.content_url(repo, sha, path))
if data is not None and hashlib.md5(data).hexdigest() == wanted:
return sha, data
return None