226 > ) |
226 > ) |
227 > |
227 > |
228 > configtable = {} |
228 > configtable = {} |
229 > configitem = registrar.configitem(configtable) |
229 > configitem = registrar.configitem(configtable) |
230 > |
230 > |
231 > configitem('ui', 'ioerrors', |
231 > configitem(b'ui', b'ioerrors', |
232 > default=list, |
232 > default=list, |
233 > ) |
233 > ) |
234 > |
234 > |
235 > def pretxncommit(ui, repo, **kwargs): |
235 > def pretxncommit(ui, repo, **kwargs): |
236 > ui.warn('warn during pretxncommit\n') |
236 > ui.warn(b'warn during pretxncommit\n') |
237 > |
237 > |
238 > def pretxnclose(ui, repo, **kwargs): |
238 > def pretxnclose(ui, repo, **kwargs): |
239 > ui.warn('warn during pretxnclose\n') |
239 > ui.warn(b'warn during pretxnclose\n') |
240 > |
240 > |
241 > def txnclose(ui, repo, **kwargs): |
241 > def txnclose(ui, repo, **kwargs): |
242 > ui.warn('warn during txnclose\n') |
242 > ui.warn(b'warn during txnclose\n') |
243 > |
243 > |
244 > def txnabort(ui, repo, **kwargs): |
244 > def txnabort(ui, repo, **kwargs): |
245 > ui.warn('warn during abort\n') |
245 > ui.warn(b'warn during abort\n') |
246 > |
246 > |
247 > class fdproxy(object): |
247 > class fdproxy(object): |
248 > def __init__(self, ui, o): |
248 > def __init__(self, ui, o): |
249 > self._ui = ui |
249 > self._ui = ui |
250 > self._o = o |
250 > self._o = o |
251 > |
251 > |
252 > def __getattr__(self, attr): |
252 > def __getattr__(self, attr): |
253 > return getattr(self._o, attr) |
253 > return getattr(self._o, attr) |
254 > |
254 > |
255 > def write(self, msg): |
255 > def write(self, msg): |
256 > errors = set(self._ui.configlist('ui', 'ioerrors')) |
256 > errors = set(self._ui.configlist(b'ui', b'ioerrors')) |
257 > pretxncommit = msg == 'warn during pretxncommit\n' |
257 > pretxncommit = msg == b'warn during pretxncommit\n' |
258 > pretxnclose = msg == 'warn during pretxnclose\n' |
258 > pretxnclose = msg == b'warn during pretxnclose\n' |
259 > txnclose = msg == 'warn during txnclose\n' |
259 > txnclose = msg == b'warn during txnclose\n' |
260 > txnabort = msg == 'warn during abort\n' |
260 > txnabort = msg == b'warn during abort\n' |
261 > msgabort = msg == _('transaction abort!\n') |
261 > msgabort = msg == _(b'transaction abort!\n') |
262 > msgrollback = msg == _('rollback completed\n') |
262 > msgrollback = msg == _(b'rollback completed\n') |
263 > |
263 > |
264 > if pretxncommit and 'pretxncommit' in errors: |
264 > if pretxncommit and b'pretxncommit' in errors: |
265 > raise IOError(errno.EPIPE, 'simulated epipe') |
265 > raise IOError(errno.EPIPE, 'simulated epipe') |
266 > if pretxnclose and 'pretxnclose' in errors: |
266 > if pretxnclose and b'pretxnclose' in errors: |
267 > raise IOError(errno.EIO, 'simulated eio') |
267 > raise IOError(errno.EIO, 'simulated eio') |
268 > if txnclose and 'txnclose' in errors: |
268 > if txnclose and b'txnclose' in errors: |
269 > raise IOError(errno.EBADF, 'simulated badf') |
269 > raise IOError(errno.EBADF, 'simulated badf') |
270 > if txnabort and 'txnabort' in errors: |
270 > if txnabort and b'txnabort' in errors: |
271 > raise IOError(errno.EPIPE, 'simulated epipe') |
271 > raise IOError(errno.EPIPE, 'simulated epipe') |
272 > if msgabort and 'msgabort' in errors: |
272 > if msgabort and b'msgabort' in errors: |
273 > raise IOError(errno.EBADF, 'simulated ebadf') |
273 > raise IOError(errno.EBADF, 'simulated ebadf') |
274 > if msgrollback and 'msgrollback' in errors: |
274 > if msgrollback and b'msgrollback' in errors: |
275 > raise IOError(errno.EIO, 'simulated eio') |
275 > raise IOError(errno.EIO, 'simulated eio') |
276 > |
276 > |
277 > return self._o.write(msg) |
277 > return self._o.write(msg) |
278 > |
278 > |
279 > def uisetup(ui): |
279 > def uisetup(ui): |
287 > self.ferr = olderr |
287 > self.ferr = olderr |
288 > |
288 > |
289 > ui.__class__ = badui |
289 > ui.__class__ = badui |
290 > |
290 > |
291 > def reposetup(ui, repo): |
291 > def reposetup(ui, repo): |
292 > ui.setconfig('hooks', 'pretxnclose.badui', pretxnclose, 'badui') |
292 > ui.setconfig(b'hooks', b'pretxnclose.badui', pretxnclose, b'badui') |
293 > ui.setconfig('hooks', 'txnclose.badui', txnclose, 'badui') |
293 > ui.setconfig(b'hooks', b'txnclose.badui', txnclose, b'badui') |
294 > ui.setconfig('hooks', 'pretxncommit.badui', pretxncommit, 'badui') |
294 > ui.setconfig(b'hooks', b'pretxncommit.badui', pretxncommit, b'badui') |
295 > ui.setconfig('hooks', 'txnabort.badui', txnabort, 'badui') |
295 > ui.setconfig(b'hooks', b'txnabort.badui', txnabort, b'badui') |
296 > EOF |
296 > EOF |
297 |
297 |
298 $ cat >> $HGRCPATH << EOF |
298 $ cat >> $HGRCPATH << EOF |
299 > [extensions] |
299 > [extensions] |
300 > badui = $TESTTMP/badui.py |
300 > badui = $TESTTMP/badui.py |