Skip to content
Snippets Groups Projects
Commit 965c3de4 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

loader: Raise NotFound for missing CVS module when using pserver or ssh

That case was handled when using rsync protocol but not when using pserver
or ssh protocol.

Closes T4631
parent 356dfa27
No related branches found
No related tags found
1 merge request!61loader: Raise NotFound for missing CVS module when using pserver or ssh
......@@ -31,7 +31,7 @@ from swh.loader.cvs.cvs2gitdump.cvs2gitdump import (
RcsKeywords,
file_path,
)
from swh.loader.cvs.cvsclient import CVSClient, decode_path
from swh.loader.cvs.cvsclient import CVSClient, CVSProtocolError, decode_path
import swh.loader.cvs.rcsparse as rcsparse
from swh.loader.cvs.rlog import RlogConv
from swh.loader.exception import NotFound
......@@ -497,8 +497,16 @@ class CvsLoader(BaseLoader):
cvsroot_path,
self.cvs_module_name,
)
try:
main_rlog_file = self.cvsclient.fetch_rlog()
except CVSProtocolError as cvs_err:
if "cannot find module" in str(cvs_err):
raise NotFound(
f"CVS module named {self.cvs_module_name} cannot be found"
)
else:
raise
self.rlog = RlogConv(cvsroot_path, CHANGESET_FUZZ_SEC)
main_rlog_file = self.cvsclient.fetch_rlog()
self.rlog.parse_rlog(main_rlog_file)
# Find file deletion events only visible in Attic directories.
main_changesets = self.rlog.changesets
......
......@@ -48,6 +48,34 @@ def test_loader_cvs_not_found_no_mock(swh_storage, tmp_path):
)
def test_loader_cvs_ssh_module_not_found(swh_storage, tmp_path, mocker):
url = "ssh://anoncvs@anoncvs.example.org/cvsroot/foo"
mocker.patch("swh.loader.cvs.cvsclient.socket")
mocker.patch("swh.loader.cvs.cvsclient.subprocess")
from swh.loader.cvs.loader import CVSClient as Client
conn_read_line = mocker.patch.object(Client, "conn_read_line")
conn_read_line.side_effect = [
# server response lines when client is initialized
b"Valid-requests ",
b"ok\n",
# server response line when CVS module is missing
"E cvs rlog: cannot find module `foo' - ignored\n".encode(),
]
loader = CvsLoader(swh_storage, url, cvsroot_path=tmp_path)
assert loader.load() == {"status": "uneventful"}
assert_last_visit_matches(
swh_storage,
url,
status="not_found",
type="cvs",
)
def test_loader_cvs_visit(swh_storage, datadir, tmp_path):
"""Eventful visit should yield 1 snapshot"""
archive_name = "runbaby"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment