Mercurial > hg
changeset 23512:0ff6b65afeb0
transaction: remove the redundant 'onclose' mechanism
It is superseded by the 'addfinalize' function and all its user have been
migrated.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 04 Dec 2014 13:51:41 -0800 |
parents | acc73273b27e |
children | 4c7ea2d9bad9 |
files | mercurial/transaction.py tests/test-fncache.t |
diffstat | 2 files changed, 9 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/transaction.py Thu Dec 04 16:35:03 2014 -0800 +++ b/mercurial/transaction.py Thu Dec 04 13:51:41 2014 -0800 @@ -84,7 +84,7 @@ class transaction(object): def __init__(self, report, opener, vfsmap, journal, after=None, - createmode=None, onclose=None, onabort=None): + createmode=None, onabort=None): """Begin a new transaction Begins a new transaction that allows rolling back writes in the event of @@ -92,8 +92,6 @@ * `after`: called after the transaction has been committed * `createmode`: the mode of the journal file that will be created - * `onclose`: called as the transaction is closing, but before it is - closed * `onabort`: called as the transaction is aborting, but before any files have been truncated """ @@ -107,7 +105,6 @@ vfsmap[''] = opener # set default value self._vfsmap = vfsmap self.after = after - self.onclose = onclose self.onabort = onabort self.entries = [] self.map = {} @@ -375,8 +372,6 @@ categories = sorted(self._finalizecallback) for cat in categories: self._finalizecallback[cat](self) - if self.onclose is not None: - self.onclose() self.count -= 1 if self.count != 0:
--- a/tests/test-fncache.t Thu Dec 04 16:35:03 2014 -0800 +++ b/tests/test-fncache.t Thu Dec 04 13:51:41 2014 -0800 @@ -241,22 +241,22 @@ $ cat > ../exceptionext.py <<EOF > import os - > from mercurial import commands, util, transaction + > from mercurial import commands, util, transaction, localrepo > from mercurial.extensions import wrapfunction > - > def closewrapper(orig, self, *args, **kwargs): - > origonclose = self.onclose - > def onclose(): - > origonclose() + > def trwrapper(orig, self, *args, **kwargs): + > 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 abortwrapper(orig, self, *args, **kwargs): > raise util.Abort("forced transaction failure") > > def uisetup(ui): - > wrapfunction(transaction.transaction, 'close', closewrapper) + > wrapfunction(localrepo.localrepository, 'transaction', trwrapper) > wrapfunction(transaction.transaction, '_abort', abortwrapper) > > cmdtable = {}