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 @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2020 The Software Heritage developers +# Copyright (C) 2015-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -16,9 +16,12 @@ import tempfile from typing import Any, Dict, Iterator, List, Optional, Tuple +from subvertpy import SubversionException + from swh.core.config import merge_configs from swh.loader.core.loader import BaseLoader from swh.loader.core.utils import clean_dangling_folders +from swh.loader.exception import NotFound from swh.model import from_disk, hashutil from swh.model.model import ( Content, @@ -398,9 +401,13 @@ dir=self.temp_directory, ) - self.svnrepo = svn.SvnRepo( - self.svn_url, self.origin_url, local_dirname, self.max_content_length - ) + try: + self.svnrepo = svn.SvnRepo( + self.svn_url, self.origin_url, local_dirname, self.max_content_length + ) + except SubversionException as e: + self._load_status = "uneventful" + raise NotFound(e) try: revision_start, revision_end, revision_parents = self.start_from( 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 @@ -36,6 +36,18 @@ ) +def test_loader_svn_not_found(swh_config, tmp_path): + """Given an unknown repository, the loader visit ends up in status not_found""" + unknown_repo_url = "unknown-repository" + loader = SvnLoader(unknown_repo_url, destination_path=tmp_path) + + assert loader.load() == {"status": "uneventful"} + + assert_last_visit_matches( + loader.storage, unknown_repo_url, status="not_found", type="svn", + ) + + def test_loader_svn_new_visit(swh_config, datadir, tmp_path): """Eventful visit should yield 1 snapshot""" archive_name = "pkg-gourmet"