comparison tests/fakepatchtime.py @ 25756:a4a41525180c

tests: add extension to emulate invoking internalpatch at the specific time This extension fakes "mtime" of patched files to emulate invoking 'patch.internalpatch()' at the specific time. This is useful to reproduce timing critical issues fixed in subsequent patches.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 08 Jul 2015 17:01:09 +0900
parents
children f624b0e69105
comparison
equal deleted inserted replaced
25755:72d395e399c1 25756:a4a41525180c
1 # extension to emulate invoking 'patch.internalpatch()' at the time
2 # specified by '[fakepatchtime] fakenow'
3
4 from mercurial import extensions, patch as patchmod, util
5
6 def internalpatch(orig, ui, repo, patchobj, strip,
7 prefix='', files=None,
8 eolmode='strict', similarity=0):
9 if files is None:
10 files = set()
11 r = orig(ui, repo, patchobj, strip,
12 prefix=prefix, files=files,
13 eolmode=eolmode, similarity=similarity)
14
15 fakenow = ui.config('fakepatchtime', 'fakenow')
16 if fakenow:
17 # parsing 'fakenow' in YYYYmmddHHMM format makes comparison between
18 # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy
19 fakenow = util.parsedate(fakenow, ['%Y%m%d%H%M'])[0]
20 for f in files:
21 repo.wvfs.utime(f, (fakenow, fakenow))
22
23 return r
24
25 def extsetup(ui):
26 extensions.wrapfunction(patchmod, 'internalpatch', internalpatch)