Mercurial > hg > mercurial-source
comparison tests/fakedirstatewritetime.py @ 33595:add613cddcb6
workingctx: factor out post-status dirstate fixup
We want to allow extensions to be able to add code to run inside the wlock.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 12 Jun 2017 13:54:59 -0700 |
parents | df448de7cf3b |
children | 6d73b7ff8f92 |
comparison
equal
deleted
inserted
replaced
33594:ff02bb5979c1 | 33595:add613cddcb6 |
---|---|
1 # extension to emulate invoking 'dirstate.write()' at the time | 1 # extension to emulate invoking 'dirstate.write()' at the time |
2 # specified by '[fakedirstatewritetime] fakenow', only when | 2 # specified by '[fakedirstatewritetime] fakenow', only when |
3 # 'dirstate.write()' is invoked via functions below: | 3 # 'dirstate.write()' is invoked via functions below: |
4 # | 4 # |
5 # - 'workingctx._checklookup()' (= 'repo.status()') | 5 # - 'workingctx._poststatusfixup()' (= 'repo.status()') |
6 # - 'committablectx.markcommitted()' | 6 # - 'committablectx.markcommitted()' |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 from mercurial import ( | 10 from mercurial import ( |
53 return func() | 53 return func() |
54 finally: | 54 finally: |
55 parsers.pack_dirstate = orig_pack_dirstate | 55 parsers.pack_dirstate = orig_pack_dirstate |
56 dirstate._getfsnow = orig_dirstate_getfsnow | 56 dirstate._getfsnow = orig_dirstate_getfsnow |
57 | 57 |
58 def _checklookup(orig, workingctx, files): | 58 def _poststatusfixup(orig, workingctx, fixup): |
59 ui = workingctx.repo().ui | 59 ui = workingctx.repo().ui |
60 return fakewrite(ui, lambda : orig(workingctx, files)) | 60 return fakewrite(ui, lambda : orig(workingctx, fixup)) |
61 | 61 |
62 def markcommitted(orig, committablectx, node): | 62 def markcommitted(orig, committablectx, node): |
63 ui = committablectx.repo().ui | 63 ui = committablectx.repo().ui |
64 return fakewrite(ui, lambda : orig(committablectx, node)) | 64 return fakewrite(ui, lambda : orig(committablectx, node)) |
65 | 65 |
66 def extsetup(ui): | 66 def extsetup(ui): |
67 extensions.wrapfunction(context.workingctx, '_checklookup', | 67 extensions.wrapfunction(context.workingctx, '_poststatusfixup', |
68 _checklookup) | 68 _poststatusfixup) |
69 extensions.wrapfunction(context.committablectx, 'markcommitted', | 69 extensions.wrapfunction(context.committablectx, 'markcommitted', |
70 markcommitted) | 70 markcommitted) |