fix: handle E155037 interrupt error, increase SVN timeouts for large branches

This commit is contained in:
2026-06-29 22:54:49 +02:00
parent 3c5e9f9944
commit 0035596551
+18 -12
View File
@@ -6,6 +6,7 @@ commits, maintaining the mapping DB so that SVN→Git sync skips them.
import logging import logging
import os import os
import re
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from typing import Dict, List, Optional, Tuple from typing import Dict, List, Optional, Tuple
@@ -138,32 +139,37 @@ def _ensure_wc(mirror: Mirror, svn_branch: str):
else: else:
_try_revert(wc, auth_args) _try_revert(wc, auth_args)
try: try:
_run_svn(["update", "--ignore-externals"], timeout=120, _run_svn(["update", "--ignore-externals"], timeout=600,
wc=wc, auth_args=auth_args) wc=wc, auth_args=auth_args)
except GitToSVNError as e: except GitToSVNError as e:
if _is_lock_error(e): if _is_with_cleanup_recoverable(e):
logger.warning("WC locked running cleanup for %s", svn_branch) logger.warning("WC interrupted running cleanup for %s", svn_branch)
_run_svn(["cleanup"], timeout=120, wc=wc, auth_args=auth_args) _run_svn(["cleanup"], timeout=600, wc=wc, auth_args=auth_args)
_try_revert(wc, auth_args) _try_revert(wc, auth_args)
_run_svn(["update", "--ignore-externals"], timeout=120, _run_svn(["update", "--ignore-externals"], timeout=600,
wc=wc, auth_args=auth_args) wc=wc, auth_args=auth_args)
else: else:
raise raise
return wc return wc
def _is_lock_error(e: GitToSVNError) -> bool: _INTERRUPTED_MSGS = ["E155004", "E155037", "previous operation",
return "E155004" in str(e) or "locked" in str(e).lower() "run.*cleanup", "locked"]
def _is_with_cleanup_recoverable(e: GitToSVNError) -> bool:
msg = str(e).lower()
return any(re.search(p.lower(), msg) for p in _INTERRUPTED_MSGS)
def _try_revert(wc: Path, auth_args: Optional[list]): def _try_revert(wc: Path, auth_args: Optional[list]):
try: try:
_run_svn(["revert", "-R", "."], timeout=120, wc=wc, auth_args=auth_args) _run_svn(["revert", "-R", "."], timeout=600, wc=wc, auth_args=auth_args)
except GitToSVNError as e: except GitToSVNError as e:
if _is_lock_error(e): if _is_with_cleanup_recoverable(e):
logger.warning("WC locked during revert running cleanup") logger.warning("WC interrupted during revert running cleanup")
_run_svn(["cleanup"], timeout=120, wc=wc, auth_args=auth_args) _run_svn(["cleanup"], timeout=600, wc=wc, auth_args=auth_args)
_run_svn(["revert", "-R", "."], timeout=120, _run_svn(["revert", "-R", "."], timeout=600,
wc=wc, auth_args=auth_args) wc=wc, auth_args=auth_args)
else: else:
raise raise