fix: handle E155037 interrupt error, increase SVN timeouts for large branches
This commit is contained in:
+18
-12
@@ -6,6 +6,7 @@ commits, maintaining the mapping DB so that SVN→Git sync skips them.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
@@ -138,32 +139,37 @@ def _ensure_wc(mirror: Mirror, svn_branch: str):
|
||||
else:
|
||||
_try_revert(wc, auth_args)
|
||||
try:
|
||||
_run_svn(["update", "--ignore-externals"], timeout=120,
|
||||
_run_svn(["update", "--ignore-externals"], timeout=600,
|
||||
wc=wc, auth_args=auth_args)
|
||||
except GitToSVNError as e:
|
||||
if _is_lock_error(e):
|
||||
logger.warning("WC locked – running cleanup for %s", svn_branch)
|
||||
_run_svn(["cleanup"], timeout=120, wc=wc, auth_args=auth_args)
|
||||
if _is_with_cleanup_recoverable(e):
|
||||
logger.warning("WC interrupted – running cleanup for %s", svn_branch)
|
||||
_run_svn(["cleanup"], timeout=600, wc=wc, auth_args=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)
|
||||
else:
|
||||
raise
|
||||
return wc
|
||||
|
||||
|
||||
def _is_lock_error(e: GitToSVNError) -> bool:
|
||||
return "E155004" in str(e) or "locked" in str(e).lower()
|
||||
_INTERRUPTED_MSGS = ["E155004", "E155037", "previous operation",
|
||||
"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]):
|
||||
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:
|
||||
if _is_lock_error(e):
|
||||
logger.warning("WC locked during revert – running cleanup")
|
||||
_run_svn(["cleanup"], timeout=120, wc=wc, auth_args=auth_args)
|
||||
_run_svn(["revert", "-R", "."], timeout=120,
|
||||
if _is_with_cleanup_recoverable(e):
|
||||
logger.warning("WC interrupted during revert – running cleanup")
|
||||
_run_svn(["cleanup"], timeout=600, wc=wc, auth_args=auth_args)
|
||||
_run_svn(["revert", "-R", "."], timeout=600,
|
||||
wc=wc, auth_args=auth_args)
|
||||
else:
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user