diff --git a/swh/loader/mercurial/from_disk.py b/swh/loader/mercurial/from_disk.py --- a/swh/loader/mercurial/from_disk.py +++ b/swh/loader/mercurial/from_disk.py @@ -321,24 +321,23 @@ """Return the hg revision numbers to load.""" assert self._repo is not None repo: hgutil.Repository = self._repo - if self._latest_heads: - existing_heads = [] # heads that still exist in the repository - for hg_nodeid in self._latest_heads: - try: - rev = repo[hg_nodeid].rev() - existing_heads.append(rev) - except KeyError: # the node does not exist anymore - pass - - # select revisions that are not ancestors of heads - # and not the heads themselves - new_revs = repo.revs("not ::(%ld)", existing_heads) - - if new_revs: - self.log.info("New revisions found: %d", len(new_revs)) - return new_revs - else: - return repo.revs("all()") + existing_heads = [] # heads that still exist in the repository + revs = self._latest_heads if self._latest_heads else repo.revs("all()") + + for hg_nodeid in revs: + try: + rev = repo[hg_nodeid].rev() + existing_heads.append(rev) + except KeyError: # the node does not exist anymore + pass + + # select revisions that are not ancestors of heads + # and not the heads themselves + new_revs = repo.revs("not ::(%ld)", existing_heads) + + if new_revs: + self.log.info("New revisions found: %d", len(new_revs)) + return new_revs def store_data(self): """Store fetched data in the database.""" @@ -425,7 +424,6 @@ snapshot = Snapshot(branches=snapshot_branches) self.storage.snapshot_add([snapshot]) - self.flush() self.loaded_snapshot_id = snapshot.id def load_status(self) -> Dict[str, str]: