# HG changeset patch # User Pierre-Yves David # Date 1730718453 -3600 # Node ID 2efcacc03010beeb11369c703b8038b9b01d78a1 # Parent 237f99ee3d649643cd5b032f6266cc79d83ba166 obshashrange: avoid executing too many DELETE requests at once While running such delete requests, the process ignores keyboard interrupts, which is not great, especially when there are half a million of them… Avoiding to run that many will be covered in the next changeset. diff -r 237f99ee3d64 -r 2efcacc03010 hgext3rd/evolve/obsdiscovery.py --- a/hgext3rd/evolve/obsdiscovery.py Mon Nov 11 10:39:57 2024 +0400 +++ b/hgext3rd/evolve/obsdiscovery.py Mon Nov 04 12:07:33 2024 +0100 @@ -323,6 +323,10 @@ return affected_nodes +def _chunks(items, size=1024): + for i in range(0, len(items), size): + yield items[i:i + size] + # if there is that many new obsmarkers, reset without analysing them RESET_ABOVE = 10000 @@ -441,9 +445,10 @@ self._data.clear() else: ranges = repo.stablerange.contains(repo, affected) - con.executemany(_delete, ranges) - for r in ranges: - self._data.pop(r, None) + for chunk in _chunks(ranges): + con.executemany(_delete, chunk) + for r in chunk: + self._data.pop(r, None) except (sqlite3.DatabaseError, sqlite3.OperationalError) as exc: repo.ui.log(b'evoext-cache', b'error while updating obshashrange cache: %s\n'