# HG changeset patch # User Pierre-Yves David # Date 2014-12-04 21:49:45 # Node ID 065c0334846f9cfacb0a8cf3f47b4b9464dd86ba # Parent 32e68271a0373de803bd3c105460cf6c462f89dd fncache: drop dedicated 'onclose' function in favor of 'tr.addfinalize' Now that we have a shiny generic mechanism, we can use it. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -883,9 +883,6 @@ class localrepository(object): _("abandoned transaction found"), hint=_("run 'hg recover' to clean up transaction")) - def onclose(): - self.store.write(self._transref()) - self._writejournal(desc) renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] rp = report and report or self.ui.warn @@ -893,8 +890,8 @@ class localrepository(object): tr = transaction.transaction(rp, self.sopener, vfsmap, "journal", aftertrans(renames), - self.store.createmode, - onclose) + self.store.createmode) + tr.addfinalize('repo.store.write', self.store.write) self._transref = weakref.ref(tr) return tr diff --git a/tests/test-fncache.t b/tests/test-fncache.t --- a/tests/test-fncache.t +++ b/tests/test-fncache.t @@ -210,19 +210,19 @@ Aborting transaction prevents fncache ch $ cat > ../exceptionext.py < import os - > from mercurial import commands, util, transaction + > from mercurial import commands, util, localrepo > from mercurial.extensions import wrapfunction > > def wrapper(orig, self, *args, **kwargs): - > origonclose = self.onclose - > def onclose(): - > origonclose() + > tr = orig(self, *args, **kwargs) + > def fail(tr): > raise util.Abort("forced transaction failure") - > self.onclose = onclose - > return orig(self, *args, **kwargs) + > # zzz prefix to ensure it sorted after store.write + > tr.addfinalize('zzz-forcefails', fail) + > return tr > > def uisetup(ui): - > wrapfunction(transaction.transaction, 'close', wrapper) + > wrapfunction(localrepo.localrepository, 'transaction', wrapper) > > cmdtable = {} >