feat: thread SVN auth (username/password) through all svn call sites

This commit is contained in:
2026-06-23 13:23:44 +02:00
parent 45fb8c40d0
commit 99a056d9fb
7 changed files with 56 additions and 20 deletions
+7 -2
View File
@@ -91,8 +91,11 @@ def _wc_path(mirror: Mirror, svn_branch: str) -> Path:
def _run_svn(args: list, input: bytes = None, timeout: int = 120,
wc: Optional[Path] = None):
wc: Optional[Path] = None,
auth_args: Optional[list] = None):
"""Run an svn command. If *wc* is given, run from that directory."""
if auth_args:
args = auth_args + args
env = {**os.environ, "LC_ALL": "C"}
try:
r = subprocess.run(
@@ -116,12 +119,14 @@ def _run_svn(args: list, input: bytes = None, timeout: int = 120,
def _ensure_wc(mirror: Mirror, svn_branch: str):
"""Ensure the SVN working copy for *svn_branch* exists and is at HEAD."""
auth_args = mirror.config.svn.auth_args()
wc = _wc_path(mirror, svn_branch)
svn_url = mirror.config.svn.url.rstrip("/") + "/" + svn_branch
if not (wc / ".svn").exists():
logger.info("Checking out SVN WC for %s", svn_branch)
wc.mkdir(parents=True, exist_ok=True)
_run_svn(["checkout", svn_url, str(wc)], timeout=300)
_run_svn(["checkout", svn_url, str(wc)], timeout=300,
auth_args=auth_args)
else:
logger.debug("Updating SVN WC for %s", svn_branch)
_run_svn(["revert", "-R", "."], timeout=120, wc=wc)