diff --git a/swh/loader/svn/loader.py b/swh/loader/svn/loader.py --- a/swh/loader/svn/loader.py +++ b/swh/loader/svn/loader.py @@ -659,6 +659,9 @@ If the svnrdump command failed somehow, the produced dump file is analyzed to determine if a partial loading is still feasible. + + Raises: + NotFound when the repository is no longer found at url """ # Build the svnrdump command line svnrdump_cmd = ["svnrdump", "dump", svn_url] @@ -741,6 +744,12 @@ % (last_dumped_rev, last_loaded_svn_rev) ) + if svnrdump.returncode == 1: + # Try to detect not found repositories + for stderr_line in stderr_lines: + if "E170013:" in stderr_line: + raise NotFound(stderr_line) + raise Exception( "An error occurred when running svnrdump and " "no exploitable dump file has been generated." diff --git a/swh/loader/svn/tests/test_loader.py b/swh/loader/svn/tests/test_loader.py --- a/swh/loader/svn/tests/test_loader.py +++ b/swh/loader/svn/tests/test_loader.py @@ -41,13 +41,13 @@ def test_loader_svn_not_found_no_mock(swh_storage, tmp_path): """Given an unknown repository, the loader visit ends up in status not_found""" - unknown_repo_url = "unknown-repository" - loader = SvnLoader(swh_storage, unknown_repo_url, destination_path=tmp_path) + repo_url = "unknown-repository" + loader = SvnLoader(swh_storage, repo_url, destination_path=tmp_path) assert loader.load() == {"status": "uneventful"} assert_last_visit_matches( - swh_storage, unknown_repo_url, status="not_found", type="svn", + swh_storage, repo_url, status="not_found", type="svn", ) @@ -92,6 +92,21 @@ ) +def test_loader_svnrdump_not_found(swh_storage, tmp_path, mocker): + """Given any errors raised, the loader visit ends up in status failed""" + unknown_repo_url = "file:///tmp/svn.code.sf.net/p/white-rats-studios/svn" + + loader = SvnLoaderFromRemoteDump( + swh_storage, unknown_repo_url, destination_path=tmp_path + ) + + assert loader.load() == {"status": "uneventful"} + + assert_last_visit_matches( + swh_storage, unknown_repo_url, status="not_found", type="svn", + ) + + def test_loader_svn_new_visit(swh_storage, datadir, tmp_path): """Eventful visit should yield 1 snapshot""" archive_name = "pkg-gourmet"