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 @@ -50,6 +50,8 @@ TEMPORARY_DIR_PREFIX_PATTERN = "swh.loader.svn." +SUBVERSION_NOT_FOUND = re.compile(r".*E170013:.*") + class SvnLoader(BaseLoader): """Swh svn loader. @@ -659,6 +661,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] @@ -681,6 +686,8 @@ stderr_lines += lines for line in lines: self.log.debug(line) + if SUBVERSION_NOT_FOUND.match(line): + raise NotFound(line) svnrdump.wait() os.close(stderr_r) 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"