995 def validate(tr): |
995 def validate(tr): |
996 """will run pre-closing hooks""" |
996 """will run pre-closing hooks""" |
997 pending = lambda: tr.writepending() and self.root or "" |
997 pending = lambda: tr.writepending() and self.root or "" |
998 reporef().hook('pretxnclose', throw=True, pending=pending, |
998 reporef().hook('pretxnclose', throw=True, pending=pending, |
999 txnname=desc, **tr.hookargs) |
999 txnname=desc, **tr.hookargs) |
|
1000 def releasefn(tr, success): |
|
1001 repo = reporef() |
|
1002 if success: |
|
1003 repo.dirstate.write() |
|
1004 else: |
|
1005 # prevent in-memory changes from being written out at |
|
1006 # the end of outer wlock scope or so |
|
1007 repo.dirstate.invalidate() |
|
1008 |
|
1009 # discard all changes (including ones already written |
|
1010 # out) in this transaction |
|
1011 repo.vfs.rename('journal.dirstate', 'dirstate') |
1000 |
1012 |
1001 tr = transaction.transaction(rp, self.svfs, vfsmap, |
1013 tr = transaction.transaction(rp, self.svfs, vfsmap, |
1002 "journal", |
1014 "journal", |
1003 "undo", |
1015 "undo", |
1004 aftertrans(renames), |
1016 aftertrans(renames), |
1005 self.store.createmode, |
1017 self.store.createmode, |
1006 validator=validate) |
1018 validator=validate, |
|
1019 releasefn=releasefn) |
1007 |
1020 |
1008 tr.hookargs['txnid'] = txnid |
1021 tr.hookargs['txnid'] = txnid |
1009 # note: writing the fncache only during finalize mean that the file is |
1022 # note: writing the fncache only during finalize mean that the file is |
1010 # outdated when running hooks. As fncache is used for streaming clone, |
1023 # outdated when running hooks. As fncache is used for streaming clone, |
1011 # this is not expected to break anything that happen during the hooks. |
1024 # this is not expected to break anything that happen during the hooks. |