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 @@ -783,8 +783,8 @@ # subversion origin and get the number of the last one last_loaded_svn_rev = self.get_last_loaded_svn_rev(self.svn_url) - # Then check if the last loaded revision in the archive is different - # from the last revision on the remote subversion server. + # Then for stale repository, check if the last loaded revision in the archive + # is different from the last revision on the remote subversion server. # Skip the dump of all revisions and the loading process if they are identical # to save some disk space and processing time. last_loaded_snp_and_rev = self._latest_snapshot_revision(self.origin_url) @@ -793,7 +793,10 @@ self.svnrepo = SvnRepo( self.origin_url, self.origin_url, self.temp_dir, self.max_content_size ) - if self.check_history_not_altered(last_loaded_svn_rev, last_loaded_rev): + stale_repository = self.svnrepo.head_revision() == last_loaded_svn_rev + if stale_repository and self.check_history_not_altered( + last_loaded_svn_rev, last_loaded_rev + ): self._snapshot = last_loaded_snp self._last_revision = last_loaded_rev self.done = True 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 @@ -803,7 +803,7 @@ assert loaderFromDump.load() == {"status": "uneventful"} -def test_svn_loader_from_remote_dump_multiple_load_on_stale_repo( +def test_svn_loader_from_remote_dump_incremental_load_on_stale_repo( swh_storage, datadir, tmp_path, mocker ): archive_name = "pkg-gourmet" @@ -856,6 +856,36 @@ loaderFromDump._check_revision_divergence.assert_not_called() +def test_svn_loader_from_remote_dump_incremental_load_on_non_stale_repo( + swh_storage, datadir, tmp_path, mocker +): + archive_name = "pkg-gourmet" + archive_path = os.path.join(datadir, f"{archive_name}.tgz") + repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) + + # first load + loader = SvnLoaderFromRemoteDump(swh_storage, repo_url, temp_directory=tmp_path) + loader.load() + + archive_path = os.path.join(datadir, "pkg-gourmet-with-updates.tgz") + repo_updated_url = prepare_repository_from_archive( + archive_path, archive_name, tmp_path + ) + + # second load + loader = SvnLoaderFromRemoteDump( + swh_storage, repo_updated_url, temp_directory=tmp_path + ) + + dump_svn_revisions = mocker.spy(loader, "dump_svn_revisions") + process_svn_revisions = mocker.spy(loader, "process_svn_revisions") + + loader.load() + + dump_svn_revisions.assert_called() + process_svn_revisions.assert_called() + + def test_loader_user_defined_svn_properties(swh_storage, datadir, tmp_path): """Edge cases: The repository held some user defined svn-properties with special encodings, this prevented the repository from being loaded even though we do not