2416 ha = hex(hashutil.sha1(idbase).digest()) |
2416 ha = hex(hashutil.sha1(idbase).digest()) |
2417 txnid = b'TXN:' + ha |
2417 txnid = b'TXN:' + ha |
2418 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid) |
2418 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid) |
2419 |
2419 |
2420 self._writejournal(desc) |
2420 self._writejournal(desc) |
2421 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
|
2422 if report: |
2421 if report: |
2423 rp = report |
2422 rp = report |
2424 else: |
2423 else: |
2425 rp = self.ui.warn |
2424 rp = self.ui.warn |
2426 vfsmap = self.vfs_map |
2425 vfsmap = self.vfs_map |
3547 raise error.ProgrammingError(msg % category) |
3546 raise error.ProgrammingError(msg % category) |
3548 self._sidedata_computers.setdefault(kind, {}) |
3547 self._sidedata_computers.setdefault(kind, {}) |
3549 self._sidedata_computers[kind][category] = (keys, computer, flags) |
3548 self._sidedata_computers[kind][category] = (keys, computer, flags) |
3550 |
3549 |
3551 |
3550 |
3552 # used to avoid circular references so destructors work |
|
3553 def aftertrans(files): |
|
3554 renamefiles = [tuple(t) for t in files] |
|
3555 |
|
3556 def a(): |
|
3557 for vfs, src, dest in renamefiles: |
|
3558 # if src and dest refer to a same file, vfs.rename is a no-op, |
|
3559 # leaving both src and dest on disk. delete dest to make sure |
|
3560 # the rename couldn't be such a no-op. |
|
3561 vfs.tryunlink(dest) |
|
3562 try: |
|
3563 vfs.rename(src, dest) |
|
3564 except FileNotFoundError: # journal file does not yet exist |
|
3565 pass |
|
3566 |
|
3567 return a |
|
3568 |
|
3569 |
|
3570 def undoname(fn: bytes) -> bytes: |
3551 def undoname(fn: bytes) -> bytes: |
3571 base, name = os.path.split(fn) |
3552 base, name = os.path.split(fn) |
3572 assert name.startswith(b'journal') |
3553 assert name.startswith(b'journal') |
3573 return os.path.join(base, name.replace(b'journal', b'undo', 1)) |
3554 return os.path.join(base, name.replace(b'journal', b'undo', 1)) |
3574 |
3555 |