From patchwork Sat Jan 11 17:02:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7833: transaction: allow finalizer to add finalizer From: phabricator X-Patchwork-Id: 44258 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Sat, 11 Jan 2020 17:02:57 +0000 marmoute created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY It will make some code (persistent nodemap related) simpler to write, because higher level code can blindly queue finalization without thinking too hard about the context. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7833 AFFECTED FILES mercurial/transaction.py CHANGE DETAILS To: marmoute, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/transaction.py b/mercurial/transaction.py --- a/mercurial/transaction.py +++ b/mercurial/transaction.py @@ -506,9 +506,12 @@ self._validator(self) # will raise exception if needed self._validator = None # Help prevent cycles. self._generatefiles(group=gengroupprefinalize) - categories = sorted(self._finalizecallback) - for cat in categories: - self._finalizecallback[cat](self) + while self._finalizecallback: + callbacks = self._finalizecallback + self._finalizecallback = {} + categories = sorted(callbacks) + for cat in categories: + callbacks[cat](self) # Prevent double usage and help clear cycles. self._finalizecallback = None self._generatefiles(group=gengrouppostfinalize)