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._checklookup()' (= 'repo.status()') |
6 # - 'committablectx.markcommitted()' |
6 # - 'committablectx.markcommitted()' |
7 |
7 |
8 from mercurial import context, extensions, parsers, util |
8 from mercurial import context, dirstate, extensions, parsers, util |
9 |
9 |
10 def pack_dirstate(fakenow, orig, dmap, copymap, pl, now): |
10 def pack_dirstate(fakenow, orig, dmap, copymap, pl, now): |
11 # execute what original parsers.pack_dirstate should do actually |
11 # execute what original parsers.pack_dirstate should do actually |
12 # for consistency |
12 # for consistency |
13 actualnow = int(now) |
13 actualnow = int(now) |
32 # parsing 'fakenow' in YYYYmmddHHMM format makes comparison between |
32 # parsing 'fakenow' in YYYYmmddHHMM format makes comparison between |
33 # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy |
33 # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy |
34 fakenow = util.parsedate(fakenow, ['%Y%m%d%H%M'])[0] |
34 fakenow = util.parsedate(fakenow, ['%Y%m%d%H%M'])[0] |
35 |
35 |
36 orig_pack_dirstate = parsers.pack_dirstate |
36 orig_pack_dirstate = parsers.pack_dirstate |
|
37 orig_dirstate_getfsnow = dirstate._getfsnow |
37 wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args) |
38 wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args) |
38 |
39 |
39 parsers.pack_dirstate = wrapper |
40 parsers.pack_dirstate = wrapper |
|
41 dirstate._getfsnow = lambda *args: fakenow |
40 try: |
42 try: |
41 return func() |
43 return func() |
42 finally: |
44 finally: |
43 parsers.pack_dirstate = orig_pack_dirstate |
45 parsers.pack_dirstate = orig_pack_dirstate |
|
46 dirstate._getfsnow = orig_dirstate_getfsnow |
44 |
47 |
45 def _checklookup(orig, workingctx, files): |
48 def _checklookup(orig, workingctx, files): |
46 ui = workingctx.repo().ui |
49 ui = workingctx.repo().ui |
47 return fakewrite(ui, lambda : orig(workingctx, files)) |
50 return fakewrite(ui, lambda : orig(workingctx, files)) |
48 |
51 |