diff --git a/swh/loader/cvs/loader.py b/swh/loader/cvs/loader.py --- a/swh/loader/cvs/loader.py +++ b/swh/loader/cvs/loader.py @@ -129,7 +129,7 @@ else: parents = () revision = self.build_swh_revision(k, logmsg, swh_dir.hash, parents) - self.log.debug("SWH revision ID: %s", hashutil.hash_to_hex(revision.id)) + self.log.info("SWH revision ID: %s", hashutil.hash_to_hex(revision.id)) self._last_revision = revision return (revision, swh_dir) @@ -461,6 +461,11 @@ try: data = next(self.swh_revision_gen) except StopIteration: + assert self._last_revision is not None + self.snapshot = self.generate_and_load_snapshot(self._last_revision) + self.log.info("SWH snapshot ID: %s", hashutil.hash_to_hex(self.snapshot.id)) + self.flush() + self.loaded_snapshot_id = self.snapshot.id return False except Exception: self.log.exception("Exception in fetch_data:") @@ -531,11 +536,7 @@ self.storage.content_add(self._contents) self.storage.directory_add(self._directories) self.storage.revision_add(self._revisions) - assert self._last_revision is not None - self.snapshot = self.generate_and_load_snapshot(self._last_revision) - self.log.debug("SWH snapshot ID: %s", hashutil.hash_to_hex(self.snapshot.id)) self.flush() - self.loaded_snapshot_id = self.snapshot.id self._skipped_contents = [] self._contents = [] self._directories = [] diff --git a/swh/loader/cvs/tests/test_loader.py b/swh/loader/cvs/tests/test_loader.py --- a/swh/loader/cvs/tests/test_loader.py +++ b/swh/loader/cvs/tests/test_loader.py @@ -151,7 +151,7 @@ "release": 0, "revision": 7, "skipped_content": 0, - "snapshot": 7, + "snapshot": 1, } check_snapshot(GREEK_SNAPSHOT, loader.storage) @@ -188,7 +188,7 @@ "release": 0, "revision": 7, "skipped_content": 0, - "snapshot": 7, + "snapshot": 1, } check_snapshot(GREEK_SNAPSHOT, loader.storage) @@ -230,7 +230,7 @@ "release": 0, "revision": 7, "skipped_content": 0, - "snapshot": 7, + "snapshot": 1, } archive_name2 = "greek-repository2" @@ -261,7 +261,7 @@ "release": 0, "revision": 8, "skipped_content": 0, - "snapshot": 8, + "snapshot": 2, } check_snapshot(GREEK_SNAPSHOT2, loader.storage) @@ -354,7 +354,7 @@ "release": 0, "revision": 8, "skipped_content": 0, - "snapshot": 8, + "snapshot": 1, } check_snapshot(GREEK_SNAPSHOT3, loader.storage) @@ -402,7 +402,7 @@ "release": 0, "revision": 11, "skipped_content": 0, - "snapshot": 11, + "snapshot": 1, } check_snapshot(GREEK_SNAPSHOT4, loader.storage) @@ -442,7 +442,7 @@ "release": 0, "revision": 11, "skipped_content": 0, - "snapshot": 11, + "snapshot": 1, } check_snapshot(GREEK_SNAPSHOT4, loader.storage) @@ -490,7 +490,7 @@ "release": 0, "revision": 8, "skipped_content": 0, - "snapshot": 8, + "snapshot": 1, } check_snapshot(GREEK_SNAPSHOT5, loader.storage) @@ -532,7 +532,7 @@ "release": 0, "revision": 8, "skipped_content": 0, - "snapshot": 8, + "snapshot": 1, } check_snapshot(GREEK_SNAPSHOT5, loader.storage) @@ -580,7 +580,7 @@ "release": 0, "revision": 35, "skipped_content": 0, - "snapshot": 35, + "snapshot": 1, } check_snapshot(DINO_SNAPSHOT, loader.storage) @@ -622,7 +622,7 @@ "release": 0, "revision": 35, "skipped_content": 0, - "snapshot": 35, + "snapshot": 1, } check_snapshot(DINO_SNAPSHOT, loader.storage) @@ -670,7 +670,7 @@ "release": 0, "revision": 18, "skipped_content": 0, - "snapshot": 18, + "snapshot": 1, } @@ -708,7 +708,7 @@ "release": 0, "revision": 18, "skipped_content": 0, - "snapshot": 18, + "snapshot": 1, } @@ -756,7 +756,7 @@ "release": 0, "revision": 8, "skipped_content": 0, - "snapshot": 8, + "snapshot": 1, } @@ -796,7 +796,7 @@ "release": 0, "revision": 8, "skipped_content": 0, - "snapshot": 8, + "snapshot": 1, } @@ -843,7 +843,7 @@ "release": 0, "revision": 8, "skipped_content": 0, - "snapshot": 8, + "snapshot": 1, } stats = get_stats(loader.storage) assert stats == expected_stats @@ -905,7 +905,7 @@ "release": 0, "revision": 11, "skipped_content": 0, - "snapshot": 11, + "snapshot": 1, } @@ -945,5 +945,5 @@ "release": 0, "revision": 11, "skipped_content": 0, - "snapshot": 11, + "snapshot": 1, }