##// END OF EJS Templates
fncache: drop dedicated 'onclose' function in favor of 'tr.addfinalize'...
Pierre-Yves David -
r23510:065c0334 default
parent child Browse files
Show More
@@ -883,9 +883,6 b' class localrepository(object):'
883 _("abandoned transaction found"),
883 _("abandoned transaction found"),
884 hint=_("run 'hg recover' to clean up transaction"))
884 hint=_("run 'hg recover' to clean up transaction"))
885
885
886 def onclose():
887 self.store.write(self._transref())
888
889 self._writejournal(desc)
886 self._writejournal(desc)
890 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
887 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
891 rp = report and report or self.ui.warn
888 rp = report and report or self.ui.warn
@@ -893,8 +890,8 b' class localrepository(object):'
893 tr = transaction.transaction(rp, self.sopener, vfsmap,
890 tr = transaction.transaction(rp, self.sopener, vfsmap,
894 "journal",
891 "journal",
895 aftertrans(renames),
892 aftertrans(renames),
896 self.store.createmode,
893 self.store.createmode)
897 onclose)
894 tr.addfinalize('repo.store.write', self.store.write)
898 self._transref = weakref.ref(tr)
895 self._transref = weakref.ref(tr)
899 return tr
896 return tr
900
897
@@ -210,19 +210,19 b' Aborting transaction prevents fncache ch'
210
210
211 $ cat > ../exceptionext.py <<EOF
211 $ cat > ../exceptionext.py <<EOF
212 > import os
212 > import os
213 > from mercurial import commands, util, transaction
213 > from mercurial import commands, util, localrepo
214 > from mercurial.extensions import wrapfunction
214 > from mercurial.extensions import wrapfunction
215 >
215 >
216 > def wrapper(orig, self, *args, **kwargs):
216 > def wrapper(orig, self, *args, **kwargs):
217 > origonclose = self.onclose
217 > tr = orig(self, *args, **kwargs)
218 > def onclose():
218 > def fail(tr):
219 > origonclose()
220 > raise util.Abort("forced transaction failure")
219 > raise util.Abort("forced transaction failure")
221 > self.onclose = onclose
220 > # zzz prefix to ensure it sorted after store.write
222 > return orig(self, *args, **kwargs)
221 > tr.addfinalize('zzz-forcefails', fail)
222 > return tr
223 >
223 >
224 > def uisetup(ui):
224 > def uisetup(ui):
225 > wrapfunction(transaction.transaction, 'close', wrapper)
225 > wrapfunction(localrepo.localrepository, 'transaction', wrapper)
226 >
226 >
227 > cmdtable = {}
227 > cmdtable = {}
228 >
228 >
General Comments 0
You need to be logged in to leave comments. Login now