| 1 |
# common patterns in test at can safely be replaced |
| 2 |
|
| 3 |
import os |
| 4 |
|
| 5 |
substitutions = [ |
| 6 |
# list of possible compressions |
| 7 |
(br'(zstd,)?zlib,none,bzip2', br'$USUAL_COMPRESSIONS$'), |
| 8 |
(br'=(zstd,)?zlib', br'=$BUNDLE2_COMPRESSIONS$'), |
| 9 |
# capabilities sent through http |
| 10 |
( |
| 11 |
br'bundlecaps=HG20%2Cbundle2%3DHG20%250A' |
| 12 |
br'bookmarks%250A' |
| 13 |
br'changegroup%253D01%252C02%252C03%250A' |
| 14 |
br'checkheads%253Drelated%250A' |
| 15 |
br'delta-compression%253Dnone%252Czlib(%252Czstd)?%250A' |
| 16 |
br'digests%253Dmd5%252Csha1%252Csha512%250A' |
| 17 |
br'error%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250A' |
| 18 |
br'hgtagsfnodes%250A' |
| 19 |
br'listkeys%250A' |
| 20 |
br'phases%253Dheads%250A' |
| 21 |
br'pushkey%250A' |
| 22 |
br'remote-changegroup%253Dhttp%252Chttps%250A' |
| 23 |
br'stream%253Dv2', |
| 24 |
# (the replacement patterns) |
| 25 |
br'$USUAL_BUNDLE_CAPS$', |
| 26 |
), |
| 27 |
( |
| 28 |
br'bundlecaps=HG20%2Cbundle2%3DHG20%250A' |
| 29 |
br'bookmarks%250A' |
| 30 |
br'changegroup%253D01%252C02%252C03%250A' |
| 31 |
br'checkheads%3Drelated%0A' |
| 32 |
br'delta-compression%253Dnone%252Czlib(%252Czstd)?%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 |
| 44 |
( |
| 45 |
br'bundle2=HG20%0A' |
| 46 |
br'bookmarks%0A' |
| 47 |
br'changegroup%3D01%2C02%2C03%0A' |
| 48 |
br'checkheads%3Drelated%0A' |
| 49 |
br'delta-compression%3Dnone%2Czlib(%2Czstd)?%0A' |
| 50 |
br'digests%3Dmd5%2Csha1%2Csha512%0A' |
| 51 |
br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' |
| 52 |
br'hgtagsfnodes%0A' |
| 53 |
br'listkeys%0A' |
| 54 |
br'phases%3Dheads%0A' |
| 55 |
br'pushkey%0A' |
| 56 |
br'remote-changegroup%3Dhttp%2Chttps%0A' |
| 57 |
br'stream%3Dv2', |
| 58 |
# (replacement patterns) |
| 59 |
br'$USUAL_BUNDLE2_CAPS$', |
| 60 |
), |
| 61 |
# bundle2 capabilities advertised by the server |
| 62 |
( |
| 63 |
br'bundle2=HG20%0A' |
| 64 |
br'bookmarks%0A' |
| 65 |
br'changegroup%3D01%2C02%2C03%0A' |
| 66 |
br'checkheads%3Drelated%0A' |
| 67 |
br'delta-compression%3Dnone%2Czlib(%2Czstd)?%0A' |
| 68 |
br'digests%3Dmd5%2Csha1%2Csha512%0A' |
| 69 |
br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' |
| 70 |
br'hgtagsfnodes%0A' |
| 71 |
br'listkeys%0A' |
| 72 |
br'phases%3Dheads%0A' |
| 73 |
br'pushkey%0A' |
| 74 |
br'remote-changegroup%3Dhttp%2Chttps', |
| 75 |
# (replacement patterns) |
| 76 |
br'$USUAL_BUNDLE2_CAPS_SERVER$', |
| 77 |
), |
| 78 |
( |
| 79 |
br'bundle2=HG20%0A' |
| 80 |
br'bookmarks%0A' |
| 81 |
br'changegroup%3D01%2C02%2C03%0A' |
| 82 |
br'delta-compression%3Dnone%2Czlib(%2Czstd)?%0A' |
| 83 |
br'digests%3Dmd5%2Csha1%2Csha512%0A' |
| 84 |
br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' |
| 85 |
br'hgtagsfnodes%0A' |
| 86 |
br'listkeys%0A' |
| 87 |
br'pushkey%0A' |
| 88 |
br'remote-changegroup%3Dhttp%2Chttps%0A' |
| 89 |
br'stream%3Dv2', |
| 90 |
# (replacement patterns) |
| 91 |
br'$USUAL_BUNDLE2_CAPS_NO_PHASES$', |
| 92 |
), |
| 93 |
# HTTP access log dates |
| 94 |
( |
| 95 |
br' - - \[\d\d/.../2\d\d\d \d\d:\d\d:\d\d] "(GET|PUT|POST)', |
| 96 |
lambda m: br' - - [$LOGDATE$] "' + m.group(1), |
| 97 |
), |
| 98 |
# HTTP error log dates |
| 99 |
( |
| 100 |
br' - - \[\d\d/.../2\d\d\d \d\d:\d\d:\d\d] (HG error:|Exception)', |
| 101 |
lambda m: br' - - [$ERRDATE$] ' + m.group(1), |
| 102 |
), |
| 103 |
# HTTP header dates- RFC 1123 |
| 104 |
( |
| 105 |
br'([Dd]ate): [A-Za-z]{3}, \d\d [A-Za-z]{3} \d{4} \d\d:\d\d:\d\d GMT', |
| 106 |
lambda m: br'%s: $HTTP_DATE$' % m.group(1), |
| 107 |
), |
| 108 |
# LFS expiration value |
| 109 |
( |
| 110 |
br'"expires_at": "\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ"', |
| 111 |
br'"expires_at": "$ISO_8601_DATE_TIME$"', |
| 112 |
), |
| 113 |
# Windows has an extra '/' in the following lines that get globbed away: |
| 114 |
# pushing to file:/*/$TESTTMP/r2 (glob) |
| 115 |
# comparing with file:/*/$TESTTMP/r2 (glob) |
| 116 |
# sub/maybelarge.dat: largefile 34..9c not available from |
| 117 |
# file:/*/$TESTTMP/largefiles-repo (glob) |
| 118 |
( |
| 119 |
br'(.*file:/)/?(/\$TESTTMP.*)', |
| 120 |
lambda m: m.group(1) + b'*' + m.group(2) + b' (glob)', |
| 121 |
), |
| 122 |
# `discovery debug output |
| 123 |
( |
| 124 |
br'\b(\d+) total queries in \d.\d\d\d\ds\b', |
| 125 |
lambda m: (br'%s total queries in *.????s (glob)' % m.group(1)), |
| 126 |
), |
| 127 |
( |
| 128 |
br'\belapsed time: \d+.\d{6} seconds\b', |
| 129 |
br'elapsed time: *.?????? seconds (glob)', |
| 130 |
), |
| 131 |
# delta find debug time |
| 132 |
( |
| 133 |
br'(DBG-DELTAS: .* - )duration=\d+\.\d{6}\b', |
| 134 |
lambda m: br'%sduration=*.?????? (glob)' % m.group(1), |
| 135 |
), |
| 136 |
( |
| 137 |
br'DBG-DELTAS-SEARCH: delta-search-time=\d+.\d{6}', |
| 138 |
br'DBG-DELTAS-SEARCH: delta-search-time=* (glob)', |
| 139 |
), |
| 140 |
# debugupgrarepo output |
| 141 |
( |
| 142 |
br' elapsed-time: [0-9 ]{9} seconds\b', |
| 143 |
br' elapsed-time: [0-9 ]{9} seconds (re)', |
| 144 |
), |
| 145 |
] |
| 146 |
|
| 147 |
# Various platform error strings, keyed on a common replacement string |
| 148 |
_errors = { |
| 149 |
br'$ENOENT$': ( |
| 150 |
# IOError in Python does not have the same error message |
| 151 |
# than in Rust, and automatic conversion is not possible |
| 152 |
# because of module member privacy. |
| 153 |
br'No such file or directory \(os error 2\)', |
| 154 |
# strerror() |
| 155 |
br'No such file or directory', |
| 156 |
# FormatMessage(ERROR_FILE_NOT_FOUND) |
| 157 |
br'The system cannot find the file specified', |
| 158 |
), |
| 159 |
br'$EACCES$': ( |
| 160 |
br'Permission denied \(os error 13\)', |
| 161 |
# strerror |
| 162 |
br'Permission denied', |
| 163 |
), |
| 164 |
br'$ENOTDIR$': ( |
| 165 |
# strerror() |
| 166 |
br'Not a directory', |
| 167 |
# FormatMessage(ERROR_PATH_NOT_FOUND) |
| 168 |
br'The system cannot find the path specified', |
| 169 |
), |
| 170 |
br'$ECONNRESET$': ( |
| 171 |
# strerror() |
| 172 |
br'Connection reset by peer', |
| 173 |
# FormatMessage(WSAECONNRESET) |
| 174 |
br'An existing connection was forcibly closed by the remote host', |
| 175 |
), |
| 176 |
br'$EADDRINUSE$': ( |
| 177 |
# strerror() |
| 178 |
br'Address already in use', |
| 179 |
br'Address in use', |
| 180 |
# FormatMessage(WSAEADDRINUSE) |
| 181 |
br'Only one usage of each socket address' |
| 182 |
br' \(protocol/network address/port\) is normally permitted', |
| 183 |
), |
| 184 |
br'$EADDRNOTAVAIL$': ( |
| 185 |
# strerror() |
| 186 |
br'Cannot assign requested address', |
| 187 |
br'Can\'t assign requested address', |
| 188 |
# FormatMessage(WSAEADDRNOTAVAIL) |
| 189 |
br'The requested address is not valid in its context', |
| 190 |
), |
| 191 |
br'$ECONNREFUSED$': ( |
| 192 |
# strerror() |
| 193 |
br'Connection refused', |
| 194 |
# FormatMessage(WSAECONNREFUSED) |
| 195 |
br'No connection could be made because the target machine actively refused it', |
| 196 |
), |
| 197 |
br'$EINVAL$': ( |
| 198 |
# strerror() |
| 199 |
br'Invalid argument', |
| 200 |
), |
| 201 |
} |
| 202 |
|
| 203 |
for replace, msgs in _errors.items(): |
| 204 |
substitutions.extend((m, replace) for m in msgs) |
| 205 |
|
| 206 |
# Output lines on Windows that can be autocorrected for '\' vs '/' path |
| 207 |
# differences. |
| 208 |
_winpathfixes = [ |
| 209 |
# cloning subrepo s\ss from $TESTTMP/t/s/ss |
| 210 |
# cloning subrepo foo\bar from http://localhost:$HGPORT/foo/bar |
| 211 |
br'(?m)^cloning subrepo \S+\\.*', |
| 212 |
# pulling from $TESTTMP\issue1852a |
| 213 |
br'(?m)^pulling from \$TESTTMP\\.*', |
| 214 |
# pushing to $TESTTMP\a |
| 215 |
br'(?m)^pushing to \$TESTTMP\\.*', |
| 216 |
# pushing subrepo s\ss to $TESTTMP/t/s/ss |
| 217 |
br'(?m)^pushing subrepo \S+\\\S+ to.*', |
| 218 |
# moving d1\d11\a1 to d3/d11/a1 |
| 219 |
br'(?m)^moving \S+\\.*', |
| 220 |
# d1\a: not recording move - dummy does not exist |
| 221 |
br'\S+\\\S+: not recording move .+', |
| 222 |
# reverting s\a |
| 223 |
br'(?m)^reverting (?!subrepo ).*\\.*', |
| 224 |
# saved backup bundle to |
| 225 |
# $TESTTMP\test\.hg\strip-backup/443431ffac4f-2fc5398a-backup.hg |
| 226 |
br'(?m)^saved backup bundle to \$TESTTMP.*\.hg', |
| 227 |
# no changes made to subrepo s\ss since last push to ../tcc/s/ss |
| 228 |
br'(?m)^no changes made to subrepo \S+\\\S+ since.*', |
| 229 |
# changeset 5:9cc5aa7204f0: stuff/maybelarge.dat references missing |
| 230 |
# $TESTTMP\largefiles-repo-hg\.hg\largefiles\76..38 |
| 231 |
br'(?m)^changeset .* references (corrupted|missing) \$TESTTMP\\.*', |
| 232 |
# stuff/maybelarge.dat: largefile 76..38 not available from |
| 233 |
# file:/*/$TESTTMP\largefiles-repo (glob) |
| 234 |
br'.*: largefile \S+ not available from file:/\*/.+', |
| 235 |
] |
| 236 |
|
| 237 |
if os.name == 'nt': |
| 238 |
substitutions.extend( |
| 239 |
[ |
| 240 |
(s, lambda match: match.group().replace(b'\\', b'/')) |
| 241 |
for s in _winpathfixes |
| 242 |
] |
| 243 |
) |