913 |
913 |
914 self._writejournal(desc) |
914 self._writejournal(desc) |
915 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
915 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
916 rp = report and report or self.ui.warn |
916 rp = report and report or self.ui.warn |
917 vfsmap = {'plain': self.vfs} # root of .hg/ |
917 vfsmap = {'plain': self.vfs} # root of .hg/ |
918 tr = transaction.transaction(rp, self.svfs, vfsmap, |
918 # we must avoid cyclic reference between repo and transaction. |
|
919 reporef = weakref.ref(self) |
|
920 def validate(tr): |
|
921 """will run pre-closing hooks""" |
|
922 pending = lambda: tr.writepending() and self.root or "" |
|
923 reporef().hook('pretxnclose', throw=True, pending=pending, |
|
924 xnname=desc) |
|
925 |
|
926 tr = transaction.transaction(rp, self.sopener, vfsmap, |
919 "journal", |
927 "journal", |
920 "undo", |
928 "undo", |
921 aftertrans(renames), |
929 aftertrans(renames), |
922 self.store.createmode) |
930 self.store.createmode, |
|
931 validator=validate) |
923 # note: writing the fncache only during finalize mean that the file is |
932 # note: writing the fncache only during finalize mean that the file is |
924 # outdated when running hooks. As fncache is used for streaming clone, |
933 # outdated when running hooks. As fncache is used for streaming clone, |
925 # this is not expected to break anything that happen during the hooks. |
934 # this is not expected to break anything that happen during the hooks. |
926 tr.addfinalize('flush-fncache', self.store.write) |
935 tr.addfinalize('flush-fncache', self.store.write) |
927 # we must avoid cyclic reference between repo and transaction. |
|
928 reporef = weakref.ref(self) |
|
929 def txnclosehook(tr2): |
936 def txnclosehook(tr2): |
930 """To be run if transaction is successful, will schedule a hook run |
937 """To be run if transaction is successful, will schedule a hook run |
931 """ |
938 """ |
932 def hook(): |
939 def hook(): |
933 reporef().hook('txnclose', throw=False, txnname=desc, |
940 reporef().hook('txnclose', throw=False, txnname=desc, |