Mercurial > hg
comparison tests/common-pattern.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | c7652f7440d9 |
children | edc8504bc26b |
comparison
equal
deleted
inserted
replaced
43075:57875cf423c9 | 43076:2372284d9457 |
---|---|
3 | 3 |
4 import os | 4 import os |
5 | 5 |
6 substitutions = [ | 6 substitutions = [ |
7 # list of possible compressions | 7 # list of possible compressions |
8 (br'(zstd,)?zlib,none,bzip2', | 8 (br'(zstd,)?zlib,none,bzip2', br'$USUAL_COMPRESSIONS$'), |
9 br'$USUAL_COMPRESSIONS$' | 9 (br'=(zstd,)?zlib', br'=$BUNDLE2_COMPRESSIONS$'), |
10 # capabilities sent through http | |
11 ( | |
12 br'bundlecaps=HG20%2Cbundle2%3DHG20%250A' | |
13 br'bookmarks%250A' | |
14 br'changegroup%253D01%252C02%250A' | |
15 br'digests%253Dmd5%252Csha1%252Csha512%250A' | |
16 br'error%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250A' | |
17 br'hgtagsfnodes%250A' | |
18 br'listkeys%250A' | |
19 br'phases%253Dheads%250A' | |
20 br'pushkey%250A' | |
21 br'remote-changegroup%253Dhttp%252Chttps%250A' | |
22 br'rev-branch-cache%250A' | |
23 br'stream%253Dv2', | |
24 # (the replacement patterns) | |
25 br'$USUAL_BUNDLE_CAPS$', | |
10 ), | 26 ), |
11 (br'=(zstd,)?zlib', | 27 ( |
12 br'=$BUNDLE2_COMPRESSIONS$' | 28 br'bundlecaps=HG20%2Cbundle2%3DHG20%250A' |
29 br'bookmarks%250A' | |
30 br'changegroup%253D01%252C02%250A' | |
31 br'digests%253Dmd5%252Csha1%252Csha512%250A' | |
32 br'error%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250A' | |
33 br'hgtagsfnodes%250A' | |
34 br'listkeys%250A' | |
35 br'phases%253Dheads%250A' | |
36 br'pushkey%250A' | |
37 br'remote-changegroup%253Dhttp%252Chttps', | |
38 # (the replacement patterns) | |
39 br'$USUAL_BUNDLE_CAPS_SERVER$', | |
13 ), | 40 ), |
14 # capabilities sent through http | |
15 (br'bundlecaps=HG20%2Cbundle2%3DHG20%250A' | |
16 br'bookmarks%250A' | |
17 br'changegroup%253D01%252C02%250A' | |
18 br'digests%253Dmd5%252Csha1%252Csha512%250A' | |
19 br'error%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250A' | |
20 br'hgtagsfnodes%250A' | |
21 br'listkeys%250A' | |
22 br'phases%253Dheads%250A' | |
23 br'pushkey%250A' | |
24 br'remote-changegroup%253Dhttp%252Chttps%250A' | |
25 br'rev-branch-cache%250A' | |
26 br'stream%253Dv2', | |
27 # (the replacement patterns) | |
28 br'$USUAL_BUNDLE_CAPS$' | |
29 ), | |
30 (br'bundlecaps=HG20%2Cbundle2%3DHG20%250A' | |
31 br'bookmarks%250A' | |
32 br'changegroup%253D01%252C02%250A' | |
33 br'digests%253Dmd5%252Csha1%252Csha512%250A' | |
34 br'error%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250A' | |
35 br'hgtagsfnodes%250A' | |
36 br'listkeys%250A' | |
37 br'phases%253Dheads%250A' | |
38 br'pushkey%250A' | |
39 br'remote-changegroup%253Dhttp%252Chttps', | |
40 # (the replacement patterns) | |
41 br'$USUAL_BUNDLE_CAPS_SERVER$' | |
42 ), | |
43 # bundle2 capabilities sent through ssh | 41 # bundle2 capabilities sent through ssh |
44 (br'bundle2=HG20%0A' | 42 ( |
45 br'bookmarks%0A' | 43 br'bundle2=HG20%0A' |
46 br'changegroup%3D01%2C02%0A' | 44 br'bookmarks%0A' |
47 br'digests%3Dmd5%2Csha1%2Csha512%0A' | 45 br'changegroup%3D01%2C02%0A' |
48 br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' | 46 br'digests%3Dmd5%2Csha1%2Csha512%0A' |
49 br'hgtagsfnodes%0A' | 47 br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' |
50 br'listkeys%0A' | 48 br'hgtagsfnodes%0A' |
51 br'phases%3Dheads%0A' | 49 br'listkeys%0A' |
52 br'pushkey%0A' | 50 br'phases%3Dheads%0A' |
53 br'remote-changegroup%3Dhttp%2Chttps%0A' | 51 br'pushkey%0A' |
54 br'rev-branch-cache%0A' | 52 br'remote-changegroup%3Dhttp%2Chttps%0A' |
55 br'stream%3Dv2', | 53 br'rev-branch-cache%0A' |
56 # (replacement patterns) | 54 br'stream%3Dv2', |
57 br'$USUAL_BUNDLE2_CAPS$' | 55 # (replacement patterns) |
56 br'$USUAL_BUNDLE2_CAPS$', | |
58 ), | 57 ), |
59 # bundle2 capabilities advertised by the server | 58 # bundle2 capabilities advertised by the server |
60 (br'bundle2=HG20%0A' | |
61 br'bookmarks%0A' | |
62 br'changegroup%3D01%2C02%0A' | |
63 br'digests%3Dmd5%2Csha1%2Csha512%0A' | |
64 br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' | |
65 br'hgtagsfnodes%0A' | |
66 br'listkeys%0A' | |
67 br'phases%3Dheads%0A' | |
68 br'pushkey%0A' | |
69 br'remote-changegroup%3Dhttp%2Chttps%0A' | |
70 br'rev-branch-cache', | |
71 # (replacement patterns) | |
72 br'$USUAL_BUNDLE2_CAPS_SERVER$' | |
73 ), | |
74 ( | 59 ( |
75 br'bundle2=HG20%0A' | 60 br'bundle2=HG20%0A' |
76 br'bookmarks%0A' | 61 br'bookmarks%0A' |
77 br'changegroup%3D01%2C02%0A' | 62 br'changegroup%3D01%2C02%0A' |
78 br'digests%3Dmd5%2Csha1%2Csha512%0A' | 63 br'digests%3Dmd5%2Csha1%2Csha512%0A' |
79 br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' | 64 br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' |
80 br'hgtagsfnodes%0A' | 65 br'hgtagsfnodes%0A' |
81 br'listkeys%0A' | 66 br'listkeys%0A' |
82 br'pushkey%0A' | 67 br'phases%3Dheads%0A' |
83 br'remote-changegroup%3Dhttp%2Chttps%0A' | 68 br'pushkey%0A' |
84 br'rev-branch-cache%0A' | 69 br'remote-changegroup%3Dhttp%2Chttps%0A' |
85 br'stream%3Dv2', | 70 br'rev-branch-cache', |
86 # (replacement patterns) | 71 # (replacement patterns) |
87 br'$USUAL_BUNDLE2_CAPS_NO_PHASES$' | 72 br'$USUAL_BUNDLE2_CAPS_SERVER$', |
73 ), | |
74 ( | |
75 br'bundle2=HG20%0A' | |
76 br'bookmarks%0A' | |
77 br'changegroup%3D01%2C02%0A' | |
78 br'digests%3Dmd5%2Csha1%2Csha512%0A' | |
79 br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' | |
80 br'hgtagsfnodes%0A' | |
81 br'listkeys%0A' | |
82 br'pushkey%0A' | |
83 br'remote-changegroup%3Dhttp%2Chttps%0A' | |
84 br'rev-branch-cache%0A' | |
85 br'stream%3Dv2', | |
86 # (replacement patterns) | |
87 br'$USUAL_BUNDLE2_CAPS_NO_PHASES$', | |
88 ), | 88 ), |
89 # HTTP access log dates | 89 # HTTP access log dates |
90 (br' - - \[\d\d/.../2\d\d\d \d\d:\d\d:\d\d] "(GET|PUT|POST)', | 90 ( |
91 lambda m: br' - - [$LOGDATE$] "' + m.group(1) | 91 br' - - \[\d\d/.../2\d\d\d \d\d:\d\d:\d\d] "(GET|PUT|POST)', |
92 lambda m: br' - - [$LOGDATE$] "' + m.group(1), | |
92 ), | 93 ), |
93 # HTTP error log dates | 94 # HTTP error log dates |
94 (br' - - \[\d\d/.../2\d\d\d \d\d:\d\d:\d\d] (HG error:|Exception)', | 95 ( |
95 lambda m: br' - - [$ERRDATE$] ' + m.group(1) | 96 br' - - \[\d\d/.../2\d\d\d \d\d:\d\d:\d\d] (HG error:|Exception)', |
97 lambda m: br' - - [$ERRDATE$] ' + m.group(1), | |
96 ), | 98 ), |
97 # HTTP header dates- RFC 1123 | 99 # HTTP header dates- RFC 1123 |
98 (br'([Dd]ate): [A-Za-z]{3}, \d\d [A-Za-z]{3} \d{4} \d\d:\d\d:\d\d GMT', | 100 ( |
99 lambda m: br'%s: $HTTP_DATE$' % m.group(1) | 101 br'([Dd]ate): [A-Za-z]{3}, \d\d [A-Za-z]{3} \d{4} \d\d:\d\d:\d\d GMT', |
102 lambda m: br'%s: $HTTP_DATE$' % m.group(1), | |
100 ), | 103 ), |
101 # LFS expiration value | 104 # LFS expiration value |
102 (br'"expires_at": "\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ"', | 105 ( |
103 br'"expires_at": "$ISO_8601_DATE_TIME$"' | 106 br'"expires_at": "\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ"', |
107 br'"expires_at": "$ISO_8601_DATE_TIME$"', | |
104 ), | 108 ), |
105 # Windows has an extra '/' in the following lines that get globbed away: | 109 # Windows has an extra '/' in the following lines that get globbed away: |
106 # pushing to file:/*/$TESTTMP/r2 (glob) | 110 # pushing to file:/*/$TESTTMP/r2 (glob) |
107 # comparing with file:/*/$TESTTMP/r2 (glob) | 111 # comparing with file:/*/$TESTTMP/r2 (glob) |
108 # sub/maybelarge.dat: largefile 34..9c not available from | 112 # sub/maybelarge.dat: largefile 34..9c not available from |
109 # file:/*/$TESTTMP/largefiles-repo (glob) | 113 # file:/*/$TESTTMP/largefiles-repo (glob) |
110 (br'(.*file:/)/?(/\$TESTTMP.*)', | 114 ( |
111 lambda m: m.group(1) + b'*' + m.group(2) + b' (glob)' | 115 br'(.*file:/)/?(/\$TESTTMP.*)', |
116 lambda m: m.group(1) + b'*' + m.group(2) + b' (glob)', | |
112 ), | 117 ), |
113 ] | 118 ] |
114 | 119 |
115 # Various platform error strings, keyed on a common replacement string | 120 # Various platform error strings, keyed on a common replacement string |
116 _errors = { | 121 _errors = { |
117 br'$ENOENT$': ( | 122 br'$ENOENT$': ( |
118 # IOError in Python does not have the same error message | 123 # IOError in Python does not have the same error message |
119 # than in Rust, and automatic conversion is not possible | 124 # than in Rust, and automatic conversion is not possible |
120 # because of module member privacy. | 125 # because of module member privacy. |
121 br'No such file or directory \(os error 2\)', | 126 br'No such file or directory \(os error 2\)', |
122 | |
123 # strerror() | 127 # strerror() |
124 br'No such file or directory', | 128 br'No such file or directory', |
125 | |
126 # FormatMessage(ERROR_FILE_NOT_FOUND) | 129 # FormatMessage(ERROR_FILE_NOT_FOUND) |
127 br'The system cannot find the file specified', | 130 br'The system cannot find the file specified', |
128 ), | 131 ), |
129 br'$ENOTDIR$': ( | 132 br'$ENOTDIR$': ( |
130 # strerror() | 133 # strerror() |
131 br'Not a directory', | 134 br'Not a directory', |
132 | |
133 # FormatMessage(ERROR_PATH_NOT_FOUND) | 135 # FormatMessage(ERROR_PATH_NOT_FOUND) |
134 br'The system cannot find the path specified', | 136 br'The system cannot find the path specified', |
135 ), | 137 ), |
136 br'$ECONNRESET$': ( | 138 br'$ECONNRESET$': ( |
137 # strerror() | 139 # strerror() |
138 br'Connection reset by peer', | 140 br'Connection reset by peer', |
139 | |
140 # FormatMessage(WSAECONNRESET) | 141 # FormatMessage(WSAECONNRESET) |
141 br'An existing connection was forcibly closed by the remote host', | 142 br'An existing connection was forcibly closed by the remote host', |
142 ), | 143 ), |
143 br'$EADDRINUSE$': ( | 144 br'$EADDRINUSE$': ( |
144 # strerror() | 145 # strerror() |
145 br'Address already in use', | 146 br'Address already in use', |
146 | |
147 # FormatMessage(WSAEADDRINUSE) | 147 # FormatMessage(WSAEADDRINUSE) |
148 br'Only one usage of each socket address' | 148 br'Only one usage of each socket address' |
149 br' \(protocol/network address/port\) is normally permitted', | 149 br' \(protocol/network address/port\) is normally permitted', |
150 ), | 150 ), |
151 br'$EADDRNOTAVAIL$': ( | 151 br'$EADDRNOTAVAIL$': ( |
152 # strerror() | 152 # strerror() |
153 br'Cannot assign requested address', | 153 br'Cannot assign requested address', |
154 | |
155 # FormatMessage(WSAEADDRNOTAVAIL) | 154 # FormatMessage(WSAEADDRNOTAVAIL) |
156 ) | 155 ), |
157 } | 156 } |
158 | 157 |
159 for replace, msgs in _errors.items(): | 158 for replace, msgs in _errors.items(): |
160 substitutions.extend((m, replace) for m in msgs) | 159 substitutions.extend((m, replace) for m in msgs) |
161 | 160 |
163 # differences. | 162 # differences. |
164 _winpathfixes = [ | 163 _winpathfixes = [ |
165 # cloning subrepo s\ss from $TESTTMP/t/s/ss | 164 # cloning subrepo s\ss from $TESTTMP/t/s/ss |
166 # cloning subrepo foo\bar from http://localhost:$HGPORT/foo/bar | 165 # cloning subrepo foo\bar from http://localhost:$HGPORT/foo/bar |
167 br'(?m)^cloning subrepo \S+\\.*', | 166 br'(?m)^cloning subrepo \S+\\.*', |
168 | |
169 # pulling from $TESTTMP\issue1852a | 167 # pulling from $TESTTMP\issue1852a |
170 br'(?m)^pulling from \$TESTTMP\\.*', | 168 br'(?m)^pulling from \$TESTTMP\\.*', |
171 | |
172 # pushing to $TESTTMP\a | 169 # pushing to $TESTTMP\a |
173 br'(?m)^pushing to \$TESTTMP\\.*', | 170 br'(?m)^pushing to \$TESTTMP\\.*', |
174 | |
175 # pushing subrepo s\ss to $TESTTMP/t/s/ss | 171 # pushing subrepo s\ss to $TESTTMP/t/s/ss |
176 br'(?m)^pushing subrepo \S+\\\S+ to.*', | 172 br'(?m)^pushing subrepo \S+\\\S+ to.*', |
177 | |
178 # moving d1\d11\a1 to d3/d11/a1 | 173 # moving d1\d11\a1 to d3/d11/a1 |
179 br'(?m)^moving \S+\\.*', | 174 br'(?m)^moving \S+\\.*', |
180 | |
181 # d1\a: not recording move - dummy does not exist | 175 # d1\a: not recording move - dummy does not exist |
182 br'\S+\\\S+: not recording move .+', | 176 br'\S+\\\S+: not recording move .+', |
183 | |
184 # reverting s\a | 177 # reverting s\a |
185 br'(?m)^reverting (?!subrepo ).*\\.*', | 178 br'(?m)^reverting (?!subrepo ).*\\.*', |
186 | |
187 # saved backup bundle to | 179 # saved backup bundle to |
188 # $TESTTMP\test\.hg\strip-backup/443431ffac4f-2fc5398a-backup.hg | 180 # $TESTTMP\test\.hg\strip-backup/443431ffac4f-2fc5398a-backup.hg |
189 br'(?m)^saved backup bundle to \$TESTTMP.*\.hg', | 181 br'(?m)^saved backup bundle to \$TESTTMP.*\.hg', |
190 | |
191 # no changes made to subrepo s\ss since last push to ../tcc/s/ss | 182 # no changes made to subrepo s\ss since last push to ../tcc/s/ss |
192 br'(?m)^no changes made to subrepo \S+\\\S+ since.*', | 183 br'(?m)^no changes made to subrepo \S+\\\S+ since.*', |
193 | |
194 # changeset 5:9cc5aa7204f0: stuff/maybelarge.dat references missing | 184 # changeset 5:9cc5aa7204f0: stuff/maybelarge.dat references missing |
195 # $TESTTMP\largefiles-repo-hg\.hg\largefiles\76..38 | 185 # $TESTTMP\largefiles-repo-hg\.hg\largefiles\76..38 |
196 br'(?m)^changeset .* references (corrupted|missing) \$TESTTMP\\.*', | 186 br'(?m)^changeset .* references (corrupted|missing) \$TESTTMP\\.*', |
197 | |
198 # stuff/maybelarge.dat: largefile 76..38 not available from | 187 # stuff/maybelarge.dat: largefile 76..38 not available from |
199 # file:/*/$TESTTMP\largefiles-repo (glob) | 188 # file:/*/$TESTTMP\largefiles-repo (glob) |
200 br'.*: largefile \S+ not available from file:/\*/.+', | 189 br'.*: largefile \S+ not available from file:/\*/.+', |
201 ] | 190 ] |
202 | 191 |
203 if os.name == 'nt': | 192 if os.name == 'nt': |
204 substitutions.extend([(s, lambda match: match.group().replace(b'\\', b'/')) | 193 substitutions.extend( |
205 for s in _winpathfixes]) | 194 [ |
195 (s, lambda match: match.group().replace(b'\\', b'/')) | |
196 for s in _winpathfixes | |
197 ] | |
198 ) |