annotate tests/fakepatchtime.py @ 48670:6d2ddea0721a stable

stream-clone: filter possible missing requirements using all supported one The `supportedformat` requirements is missing some important requirements and it seems better to filter out with all requirements we know, not just an "arbitrary" subset. The `supportedformat` set is lacking some important requirements (for example `revlog-compression-zstd`). This is getting fixed on default (for Mercurial 6.1) However, fixing that in 6.1 means the stream requirements sent over the wire will contains more items. And if we don't apply this fix on older version, they might end up complaining about lacking support for feature they actually support for years. This patch does not fix the deeper problem (advertised stream requirement lacking some of them), but focus on the trivial part : Lets use the full set of supported requirement for looking for unsupported ones. This patch should be simple to backport to older version of Mercurial and packager should be encouraged to do so. This is a graft of d9017df70135 from default. Differential Revision: https://phab.mercurial-scm.org/D12091
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 24 Jan 2022 11:49:06 +0100
parents 89a2afe31e82
children 6000f5b25c9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25756
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
1 # extension to emulate invoking 'patch.internalpatch()' at the time
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
2 # specified by '[fakepatchtime] fakenow'
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
3
27284
f624b0e69105 tests/fakepatchtime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25756
diff changeset
4 from __future__ import absolute_import
f624b0e69105 tests/fakepatchtime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25756
diff changeset
5
f624b0e69105 tests/fakepatchtime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25756
diff changeset
6 from mercurial import (
f624b0e69105 tests/fakepatchtime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25756
diff changeset
7 extensions,
f624b0e69105 tests/fakepatchtime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25756
diff changeset
8 patch as patchmod,
34772
7be2f229285b configitems: register the test 'fakepatchtime.fakenow' config
Boris Feld <boris.feld@octobus.net>
parents: 27284
diff changeset
9 registrar,
27284
f624b0e69105 tests/fakepatchtime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25756
diff changeset
10 )
36607
c6061cadb400 util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents: 36325
diff changeset
11 from mercurial.utils import dateutil
25756
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
12
34772
7be2f229285b configitems: register the test 'fakepatchtime.fakenow' config
Boris Feld <boris.feld@octobus.net>
parents: 27284
diff changeset
13 configtable = {}
7be2f229285b configitems: register the test 'fakepatchtime.fakenow' config
Boris Feld <boris.feld@octobus.net>
parents: 27284
diff changeset
14 configitem = registrar.configitem(configtable)
7be2f229285b configitems: register the test 'fakepatchtime.fakenow' config
Boris Feld <boris.feld@octobus.net>
parents: 27284
diff changeset
15
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
16 configitem(
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43076
diff changeset
17 b'fakepatchtime',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43076
diff changeset
18 b'fakenow',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43076
diff changeset
19 default=None,
34772
7be2f229285b configitems: register the test 'fakepatchtime.fakenow' config
Boris Feld <boris.feld@octobus.net>
parents: 27284
diff changeset
20 )
7be2f229285b configitems: register the test 'fakepatchtime.fakenow' config
Boris Feld <boris.feld@octobus.net>
parents: 27284
diff changeset
21
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
22
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
23 def internalpatch(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
24 orig,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
25 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
26 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
27 patchobj,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
28 strip,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
29 prefix=b'',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
30 files=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
31 eolmode=b'strict',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
32 similarity=0,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
33 ):
25756
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
34 if files is None:
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
35 files = set()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
36 r = orig(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
37 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
38 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
39 patchobj,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
40 strip,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
41 prefix=prefix,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
42 files=files,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
43 eolmode=eolmode,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
44 similarity=similarity,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
45 )
25756
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
46
36325
9a75619776ca py3: add b'' prefixes in fakepatchtime.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34772
diff changeset
47 fakenow = ui.config(b'fakepatchtime', b'fakenow')
25756
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
48 if fakenow:
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
49 # parsing 'fakenow' in YYYYmmddHHMM format makes comparison between
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
50 # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy
36607
c6061cadb400 util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents: 36325
diff changeset
51 fakenow = dateutil.parsedate(fakenow, [b'%Y%m%d%H%M'])[0]
25756
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
52 for f in files:
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
53 repo.wvfs.utime(f, (fakenow, fakenow))
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
54
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
55 return r
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
56
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36607
diff changeset
57
25756
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
58 def extsetup(ui):
a4a41525180c tests: add extension to emulate invoking internalpatch at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
59 extensions.wrapfunction(patchmod, 'internalpatch', internalpatch)