Show More
@@ -212,7 +212,11 b' class bmstore(object):' | |||
|
212 | 212 | The transaction is then responsible for updating the file content.""" |
|
213 | 213 | location = b'' if bookmarksinstore(self._repo) else b'plain' |
|
214 | 214 | tr.addfilegenerator( |
|
215 | b'bookmarks', (b'bookmarks',), self._write, location=location | |
|
215 | b'bookmarks', | |
|
216 | (b'bookmarks',), | |
|
217 | self._write, | |
|
218 | location=location, | |
|
219 | post_finalize=True, | |
|
216 | 220 | ) |
|
217 | 221 | tr.hookargs[b'bookmark_moved'] = b'1' |
|
218 | 222 |
@@ -730,12 +730,14 b' class dirstate(object):' | |||
|
730 | 730 | (self._filename_tk,), |
|
731 | 731 | lambda f: self._write_tracked_key(tr, f), |
|
732 | 732 | location=b'plain', |
|
733 | post_finalize=True, | |
|
733 | 734 | ) |
|
734 | 735 | tr.addfilegenerator( |
|
735 | 736 | b'dirstate-1-main', |
|
736 | 737 | (self._filename,), |
|
737 | 738 | lambda f: self._writedirstate(tr, f), |
|
738 | 739 | location=b'plain', |
|
740 | post_finalize=True, | |
|
739 | 741 | ) |
|
740 | 742 | if write_key: |
|
741 | 743 | tr.addfilegenerator( |
@@ -743,6 +745,7 b' class dirstate(object):' | |||
|
743 | 745 | (self._filename_tk,), |
|
744 | 746 | lambda f: self._write_tracked_key(tr, f), |
|
745 | 747 | location=b'plain', |
|
748 | post_finalize=True, | |
|
746 | 749 | ) |
|
747 | 750 | return |
|
748 | 751 | |
@@ -1425,6 +1428,7 b' class dirstate(object):' | |||
|
1425 | 1428 | (self._filename,), |
|
1426 | 1429 | lambda f: self._writedirstate(tr, f), |
|
1427 | 1430 | location=b'plain', |
|
1431 | post_finalize=True, | |
|
1428 | 1432 | ) |
|
1429 | 1433 | |
|
1430 | 1434 | # ensure that pending file written above is unlinked at |
@@ -25,16 +25,6 b' from .utils import stringutil' | |||
|
25 | 25 | |
|
26 | 26 | version = 2 |
|
27 | 27 | |
|
28 | # These are the file generators that should only be executed after the | |
|
29 | # finalizers are done, since they rely on the output of the finalizers (like | |
|
30 | # the changelog having been written). | |
|
31 | postfinalizegenerators = { | |
|
32 | b'bookmarks', | |
|
33 | b'dirstate-0-key-pre', | |
|
34 | b'dirstate-1-main', | |
|
35 | b'dirstate-2-key-post', | |
|
36 | } | |
|
37 | ||
|
38 | 28 | GEN_GROUP_ALL = b'all' |
|
39 | 29 | GEN_GROUP_PRE_FINALIZE = b'prefinalize' |
|
40 | 30 | GEN_GROUP_POST_FINALIZE = b'postfinalize' |
@@ -339,7 +329,13 b' class transaction(util.transactional):' | |||
|
339 | 329 | |
|
340 | 330 | @active |
|
341 | 331 | def addfilegenerator( |
|
342 | self, genid, filenames, genfunc, order=0, location=b'' | |
|
332 | self, | |
|
333 | genid, | |
|
334 | filenames, | |
|
335 | genfunc, | |
|
336 | order=0, | |
|
337 | location=b'', | |
|
338 | post_finalize=False, | |
|
343 | 339 | ): |
|
344 | 340 | """add a function to generates some files at transaction commit |
|
345 | 341 | |
@@ -362,10 +358,14 b' class transaction(util.transactional):' | |||
|
362 | 358 | The `location` arguments may be used to indicate the files are located |
|
363 | 359 | outside of the the standard directory for transaction. It should match |
|
364 | 360 | one of the key of the `transaction.vfsmap` dictionary. |
|
361 | ||
|
362 | The `post_finalize` argument can be set to `True` for file generation | |
|
363 | that must be run after the transaction has been finalized. | |
|
365 | 364 | """ |
|
366 | 365 | # For now, we are unable to do proper backup and restore of custom vfs |
|
367 | 366 | # but for bookmarks that are handled outside this mechanism. |
|
368 |
|
|
|
367 | entry = (order, filenames, genfunc, location, post_finalize) | |
|
368 | self._filegenerators[genid] = entry | |
|
369 | 369 | |
|
370 | 370 | @active |
|
371 | 371 | def removefilegenerator(self, genid): |
@@ -385,13 +385,12 b' class transaction(util.transactional):' | |||
|
385 | 385 | |
|
386 | 386 | for id, entry in sorted(pycompat.iteritems(self._filegenerators)): |
|
387 | 387 | any = True |
|
388 | order, filenames, genfunc, location = entry | |
|
388 | order, filenames, genfunc, location, post_finalize = entry | |
|
389 | 389 | |
|
390 | 390 | # for generation at closing, check if it's before or after finalize |
|
391 |
i |
|
|
392 | if skip_post and is_post: | |
|
391 | if skip_post and post_finalize: | |
|
393 | 392 | continue |
|
394 |
elif skip_pre and not |
|
|
393 | elif skip_pre and not post_finalize: | |
|
395 | 394 | continue |
|
396 | 395 | |
|
397 | 396 | vfs = self._vfsmap[location] |
@@ -9,7 +9,6 b' from __future__ import absolute_import' | |||
|
9 | 9 | |
|
10 | 10 | from mercurial import ( |
|
11 | 11 | error, |
|
12 | transaction, | |
|
13 | 12 | ) |
|
14 | 13 | |
|
15 | 14 | |
@@ -18,14 +17,15 b' def abort(fp):' | |||
|
18 | 17 | |
|
19 | 18 | |
|
20 | 19 | def reposetup(ui, repo): |
|
21 | ||
|
22 | transaction.postfinalizegenerators.add(b'late-abort') | |
|
23 | ||
|
24 | 20 | class LateAbortRepo(repo.__class__): |
|
25 | 21 | def transaction(self, *args, **kwargs): |
|
26 | 22 | tr = super(LateAbortRepo, self).transaction(*args, **kwargs) |
|
27 | 23 | tr.addfilegenerator( |
|
28 |
b'late-abort', |
|
|
24 | b'late-abort', | |
|
25 | [b'late-abort'], | |
|
26 | abort, | |
|
27 | order=9999999, | |
|
28 | post_finalize=True, | |
|
29 | 29 | ) |
|
30 | 30 | return tr |
|
31 | 31 |
General Comments 0
You need to be logged in to leave comments.
Login now