403 raise |
403 raise |
404 # Abort may be raise by read only opener |
404 # Abort may be raise by read only opener |
405 self.report("couldn't remote %s: %s\n" |
405 self.report("couldn't remote %s: %s\n" |
406 % (vfs.join(b), inst)) |
406 % (vfs.join(b), inst)) |
407 self.entries = [] |
407 self.entries = [] |
|
408 self._writeundo() |
408 if self.after: |
409 if self.after: |
409 self.after() |
410 self.after() |
410 if self.opener.isfile(self.journal): |
411 if self.opener.isfile(self.journal): |
411 self.opener.unlink(self.journal) |
412 self.opener.unlink(self.journal) |
412 if self.opener.isfile(self._backupjournal): |
413 if self.opener.isfile(self._backupjournal): |
438 '''abort the transaction (generally called on error, or when the |
439 '''abort the transaction (generally called on error, or when the |
439 transaction is not explicitly committed before going out of |
440 transaction is not explicitly committed before going out of |
440 scope)''' |
441 scope)''' |
441 self._abort() |
442 self._abort() |
442 |
443 |
|
444 def _writeundo(self): |
|
445 """write transaction data for possible future undo call""" |
|
446 if self.undoname is None: |
|
447 return |
|
448 undobackupfile = self.opener.open("%s.backupfiles" % self.undoname, 'w') |
|
449 undobackupfile.write('%d\n' % version) |
|
450 for l, f, b, c in self._backupentries: |
|
451 if not f: # temporary file |
|
452 continue |
|
453 if not b: |
|
454 u = '' |
|
455 else: |
|
456 if l not in self._vfsmap and c: |
|
457 self.report("couldn't remote %s: unknown cache location" |
|
458 "%s\n" % (b, l)) |
|
459 continue |
|
460 vfs = self._vfsmap[l] |
|
461 base, name = vfs.split(b) |
|
462 assert name.startswith(self.journal), name |
|
463 uname = name.replace(self.journal, self.undoname, 1) |
|
464 u = vfs.reljoin(base, uname) |
|
465 util.copyfile(vfs.join(b), vfs.join(u), hardlink=True) |
|
466 undobackupfile.write("%s\0%s\0%s\0%d\n" % (l, f, u, c)) |
|
467 undobackupfile.close() |
|
468 |
|
469 |
443 def _abort(self): |
470 def _abort(self): |
444 self.count = 0 |
471 self.count = 0 |
445 self.usages = 0 |
472 self.usages = 0 |
446 self.file.close() |
473 self.file.close() |
447 self._backupsfile.close() |
474 self._backupsfile.close() |