Show More
@@ -84,7 +84,7 b' def _playback(journal, report, opener, v' | |||
|
84 | 84 | |
|
85 | 85 | class transaction(object): |
|
86 | 86 | def __init__(self, report, opener, vfsmap, journal, after=None, |
|
87 |
createmode |
|
|
87 | createmode=None, onabort=None): | |
|
88 | 88 | """Begin a new transaction |
|
89 | 89 | |
|
90 | 90 | Begins a new transaction that allows rolling back writes in the event of |
@@ -92,8 +92,6 b' class transaction(object):' | |||
|
92 | 92 | |
|
93 | 93 | * `after`: called after the transaction has been committed |
|
94 | 94 | * `createmode`: the mode of the journal file that will be created |
|
95 | * `onclose`: called as the transaction is closing, but before it is | |
|
96 | closed | |
|
97 | 95 | * `onabort`: called as the transaction is aborting, but before any files |
|
98 | 96 | have been truncated |
|
99 | 97 | """ |
@@ -107,7 +105,6 b' class transaction(object):' | |||
|
107 | 105 | vfsmap[''] = opener # set default value |
|
108 | 106 | self._vfsmap = vfsmap |
|
109 | 107 | self.after = after |
|
110 | self.onclose = onclose | |
|
111 | 108 | self.onabort = onabort |
|
112 | 109 | self.entries = [] |
|
113 | 110 | self.map = {} |
@@ -375,8 +372,6 b' class transaction(object):' | |||
|
375 | 372 | categories = sorted(self._finalizecallback) |
|
376 | 373 | for cat in categories: |
|
377 | 374 | self._finalizecallback[cat](self) |
|
378 | if self.onclose is not None: | |
|
379 | self.onclose() | |
|
380 | 375 | |
|
381 | 376 | self.count -= 1 |
|
382 | 377 | if self.count != 0: |
@@ -241,22 +241,22 b' Aborted transactions can be recovered la' | |||
|
241 | 241 | |
|
242 | 242 | $ cat > ../exceptionext.py <<EOF |
|
243 | 243 | > import os |
|
244 | > from mercurial import commands, util, transaction | |
|
244 | > from mercurial import commands, util, transaction, localrepo | |
|
245 | 245 | > from mercurial.extensions import wrapfunction |
|
246 | 246 | > |
|
247 |
> def |
|
|
248 | > origonclose = self.onclose | |
|
249 |
> def |
|
|
250 | > origonclose() | |
|
247 | > def trwrapper(orig, self, *args, **kwargs): | |
|
248 | > tr = orig(self, *args, **kwargs) | |
|
249 | > def fail(tr): | |
|
251 | 250 | > raise util.Abort("forced transaction failure") |
|
252 | > self.onclose = onclose | |
|
253 | > return orig(self, *args, **kwargs) | |
|
251 | > # zzz prefix to ensure it sorted after store.write | |
|
252 | > tr.addfinalize('zzz-forcefails', fail) | |
|
253 | > return tr | |
|
254 | 254 | > |
|
255 | 255 | > def abortwrapper(orig, self, *args, **kwargs): |
|
256 | 256 | > raise util.Abort("forced transaction failure") |
|
257 | 257 | > |
|
258 | 258 | > def uisetup(ui): |
|
259 |
> wrapfunction( |
|
|
259 | > wrapfunction(localrepo.localrepository, 'transaction', trwrapper) | |
|
260 | 260 | > wrapfunction(transaction.transaction, '_abort', abortwrapper) |
|
261 | 261 | > |
|
262 | 262 | > cmdtable = {} |
General Comments 0
You need to be logged in to leave comments.
Login now