Mercurial > evolve
changeset 6932:2efcacc03010 stable
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.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 04 Nov 2024 12:07:33 +0100 |
parents | 237f99ee3d64 |
children | 7fcf18ea7813 |
files | hgext3rd/evolve/obsdiscovery.py |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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'