##// END OF EJS Templates
tests: port test-parseindex2.py to Python 3...
Augie Fackler -
r37911:2f00c6e8 default
parent child Browse files
Show More
@@ -1,466 +1,467
1 1 test-abort-checkin.t
2 2 test-add.t
3 3 test-addremove-similar.t
4 4 test-addremove.t
5 5 test-amend-subrepo.t
6 6 test-amend.t
7 7 test-ancestor.py
8 8 test-annotate.py
9 9 test-annotate.t
10 10 test-archive-symlinks.t
11 11 test-atomictempfile.py
12 12 test-audit-path.t
13 13 test-audit-subrepo.t
14 14 test-automv.t
15 15 test-backout.t
16 16 test-backwards-remove.t
17 17 test-basic.t
18 18 test-bheads.t
19 19 test-bisect.t
20 20 test-bisect2.t
21 21 test-bisect3.t
22 22 test-blackbox.t
23 23 test-bookmarks-current.t
24 24 test-bookmarks-merge.t
25 25 test-bookmarks-rebase.t
26 26 test-bookmarks-strip.t
27 27 test-bookmarks.t
28 28 test-branch-change.t
29 29 test-branch-option.t
30 30 test-branch-tag-confict.t
31 31 test-branches.t
32 32 test-bundle-phases.t
33 33 test-bundle-type.t
34 34 test-bundle-vs-outgoing.t
35 35 test-bundle2-multiple-changegroups.t
36 36 test-cappedreader.py
37 37 test-casecollision.t
38 38 test-cat.t
39 39 test-censor.t
40 40 test-changelog-exec.t
41 41 test-check-commit.t
42 42 test-check-execute.t
43 43 test-check-interfaces.py
44 44 test-check-module-imports.t
45 45 test-check-pyflakes.t
46 46 test-check-pylint.t
47 47 test-check-shbang.t
48 48 test-children.t
49 49 test-clone-cgi.t
50 50 test-clone-pull-corruption.t
51 51 test-clone-r.t
52 52 test-clone-update-order.t
53 53 test-command-template.t
54 54 test-commit-amend.t
55 55 test-commit-interactive.t
56 56 test-commit-multiple.t
57 57 test-commit-unresolved.t
58 58 test-commit.t
59 59 test-committer.t
60 60 test-completion.t
61 61 test-config-env.py
62 62 test-config.t
63 63 test-conflict.t
64 64 test-confused-revert.t
65 65 test-contrib-check-code.t
66 66 test-contrib-check-commit.t
67 67 test-convert-authormap.t
68 68 test-convert-clonebranches.t
69 69 test-convert-datesort.t
70 70 test-convert-filemap.t
71 71 test-convert-hg-sink.t
72 72 test-convert-hg-source.t
73 73 test-convert-hg-startrev.t
74 74 test-convert-splicemap.t
75 75 test-convert-tagsbranch-topology.t
76 76 test-copy-move-merge.t
77 77 test-copy.t
78 78 test-copytrace-heuristics.t
79 79 test-debugbuilddag.t
80 80 test-debugbundle.t
81 81 test-debugextensions.t
82 82 test-debugindexdot.t
83 83 test-debugrename.t
84 84 test-default-push.t
85 85 test-diff-binary-file.t
86 86 test-diff-change.t
87 87 test-diff-copy-depth.t
88 88 test-diff-hashes.t
89 89 test-diff-ignore-whitespace.t
90 90 test-diff-indent-heuristic.t
91 91 test-diff-issue2761.t
92 92 test-diff-newlines.t
93 93 test-diff-reverse.t
94 94 test-diff-subdir.t
95 95 test-diff-unified.t
96 96 test-diff-upgrade.t
97 97 test-diffdir.t
98 98 test-diffstat.t
99 99 test-directaccess.t
100 100 test-dirstate-backup.t
101 101 test-dirstate-nonnormalset.t
102 102 test-dirstate.t
103 103 test-doctest.py
104 104 test-double-merge.t
105 105 test-drawdag.t
106 106 test-duplicateoptions.py
107 107 test-editor-filename.t
108 108 test-empty-dir.t
109 109 test-empty-file.t
110 110 test-empty-group.t
111 111 test-empty.t
112 112 test-encode.t
113 113 test-encoding-func.py
114 114 test-encoding.t
115 115 test-eol-add.t
116 116 test-eol-clone.t
117 117 test-eol-hook.t
118 118 test-eol-tag.t
119 119 test-eol-update.t
120 120 test-excessive-merge.t
121 121 test-exchange-obsmarkers-case-A1.t
122 122 test-exchange-obsmarkers-case-A2.t
123 123 test-exchange-obsmarkers-case-A3.t
124 124 test-exchange-obsmarkers-case-A4.t
125 125 test-exchange-obsmarkers-case-A5.t
126 126 test-exchange-obsmarkers-case-A6.t
127 127 test-exchange-obsmarkers-case-A7.t
128 128 test-exchange-obsmarkers-case-B1.t
129 129 test-exchange-obsmarkers-case-B2.t
130 130 test-exchange-obsmarkers-case-B3.t
131 131 test-exchange-obsmarkers-case-B4.t
132 132 test-exchange-obsmarkers-case-B5.t
133 133 test-exchange-obsmarkers-case-B6.t
134 134 test-exchange-obsmarkers-case-B7.t
135 135 test-exchange-obsmarkers-case-C1.t
136 136 test-exchange-obsmarkers-case-C2.t
137 137 test-exchange-obsmarkers-case-C3.t
138 138 test-exchange-obsmarkers-case-C4.t
139 139 test-exchange-obsmarkers-case-D1.t
140 140 test-exchange-obsmarkers-case-D2.t
141 141 test-exchange-obsmarkers-case-D3.t
142 142 test-exchange-obsmarkers-case-D4.t
143 143 test-execute-bit.t
144 144 test-export.t
145 145 test-extdata.t
146 146 test-extdiff.t
147 147 test-extra-filelog-entry.t
148 148 test-filebranch.t
149 149 test-fileset-generated.t
150 150 test-fix-topology.t
151 151 test-flags.t
152 152 test-generaldelta.t
153 153 test-getbundle.t
154 154 test-git-export.t
155 155 test-glog-topological.t
156 156 test-gpg.t
157 157 test-graft.t
158 158 test-hg-parseurl.py
159 159 test-hghave.t
160 160 test-hgignore.t
161 161 test-hgk.t
162 162 test-hgweb-bundle.t
163 163 test-hgweb-descend-empties.t
164 164 test-hgweb-empty.t
165 165 test-hgweb-removed.t
166 166 test-hgwebdir-paths.py
167 167 test-hgwebdirsym.t
168 168 test-histedit-arguments.t
169 169 test-histedit-base.t
170 170 test-histedit-bookmark-motion.t
171 171 test-histedit-commute.t
172 172 test-histedit-drop.t
173 173 test-histedit-edit.t
174 174 test-histedit-fold-non-commute.t
175 175 test-histedit-fold.t
176 176 test-histedit-no-change.t
177 177 test-histedit-non-commute-abort.t
178 178 test-histedit-non-commute.t
179 179 test-histedit-obsolete.t
180 180 test-histedit-outgoing.t
181 181 test-histedit-templates.t
182 182 test-http-branchmap.t
183 183 test-http-bundle1.t
184 184 test-http-clone-r.t
185 185 test-http.t
186 186 test-hybridencode.py
187 187 test-identify.t
188 188 test-import-unknown.t
189 189 test-import.t
190 190 test-imports-checker.t
191 191 test-incoming-outgoing.t
192 192 test-inherit-mode.t
193 193 test-issue1089.t
194 194 test-issue1102.t
195 195 test-issue1175.t
196 196 test-issue1306.t
197 197 test-issue1438.t
198 198 test-issue1502.t
199 199 test-issue1802.t
200 200 test-issue1877.t
201 201 test-issue1993.t
202 202 test-issue2137.t
203 203 test-issue3084.t
204 204 test-issue4074.t
205 205 test-issue522.t
206 206 test-issue586.t
207 207 test-issue612.t
208 208 test-issue619.t
209 209 test-issue660.t
210 210 test-issue672.t
211 211 test-issue842.t
212 212 test-journal-exists.t
213 213 test-journal-share.t
214 214 test-journal.t
215 215 test-largefiles-cache.t
216 216 test-largefiles-misc.t
217 217 test-largefiles-small-disk.t
218 218 test-largefiles-update.t
219 219 test-largefiles.t
220 220 test-lfs-largefiles.t
221 221 test-linerange.py
222 222 test-locate.t
223 223 test-lock-badness.t
224 224 test-log-linerange.t
225 225 test-log.t
226 226 test-logexchange.t
227 227 test-lrucachedict.py
228 228 test-mactext.t
229 229 test-mailmap.t
230 230 test-manifest-merging.t
231 231 test-manifest.py
232 232 test-manifest.t
233 233 test-match.py
234 234 test-mdiff.py
235 235 test-merge-changedelete.t
236 236 test-merge-closedheads.t
237 237 test-merge-commit.t
238 238 test-merge-criss-cross.t
239 239 test-merge-default.t
240 240 test-merge-force.t
241 241 test-merge-halt.t
242 242 test-merge-internal-tools-pattern.t
243 243 test-merge-local.t
244 244 test-merge-remove.t
245 245 test-merge-revert.t
246 246 test-merge-revert2.t
247 247 test-merge-subrepos.t
248 248 test-merge-symlinks.t
249 249 test-merge-tools.t
250 250 test-merge-types.t
251 251 test-merge1.t
252 252 test-merge10.t
253 253 test-merge2.t
254 254 test-merge4.t
255 255 test-merge5.t
256 256 test-merge6.t
257 257 test-merge7.t
258 258 test-merge8.t
259 259 test-merge9.t
260 260 test-minifileset.py
261 261 test-minirst.py
262 262 test-mq-git.t
263 263 test-mq-header-date.t
264 264 test-mq-header-from.t
265 265 test-mq-merge.t
266 266 test-mq-pull-from-bundle.t
267 267 test-mq-qclone-http.t
268 268 test-mq-qdelete.t
269 269 test-mq-qdiff.t
270 270 test-mq-qfold.t
271 271 test-mq-qgoto.t
272 272 test-mq-qimport-fail-cleanup.t
273 273 test-mq-qnew.t
274 274 test-mq-qpush-exact.t
275 275 test-mq-qqueue.t
276 276 test-mq-qrefresh-interactive.t
277 277 test-mq-qrefresh-replace-log-message.t
278 278 test-mq-qrefresh.t
279 279 test-mq-qrename.t
280 280 test-mq-qsave.t
281 281 test-mq-safety.t
282 282 test-mq-subrepo.t
283 283 test-mq-symlinks.t
284 284 test-mv-cp-st-diff.t
285 285 test-narrow-archive.t
286 286 test-narrow-clone-no-ellipsis.t
287 287 test-narrow-clone-non-narrow-server.t
288 288 test-narrow-clone-nonlinear.t
289 289 test-narrow-clone.t
290 290 test-narrow-commit.t
291 291 test-narrow-copies.t
292 292 test-narrow-debugcommands.t
293 293 test-narrow-debugrebuilddirstate.t
294 294 test-narrow-exchange-merges.t
295 295 test-narrow-exchange.t
296 296 test-narrow-expanddirstate.t
297 297 test-narrow-merge.t
298 298 test-narrow-patch.t
299 299 test-narrow-patterns.t
300 300 test-narrow-pull.t
301 301 test-narrow-rebase.t
302 302 test-narrow-shallow-merges.t
303 303 test-narrow-shallow.t
304 304 test-narrow-strip.t
305 305 test-narrow-update.t
306 306 test-nested-repo.t
307 307 test-newbranch.t
308 308 test-obshistory.t
309 309 test-obsmarker-template.t
310 310 test-obsmarkers-effectflag.t
311 311 test-obsolete-bundle-strip.t
312 312 test-obsolete-changeset-exchange.t
313 313 test-obsolete-checkheads.t
314 314 test-obsolete-distributed.t
315 315 test-obsolete-tag-cache.t
316 316 test-parents.t
317 test-parseindex2.py
317 318 test-pathconflicts-merge.t
318 319 test-pathconflicts-update.t
319 320 test-pathencode.py
320 321 test-pending.t
321 322 test-permissions.t
322 323 test-phases.t
323 324 test-pull-branch.t
324 325 test-pull-http.t
325 326 test-pull-permission.t
326 327 test-pull-pull-corruption.t
327 328 test-pull-r.t
328 329 test-pull-update.t
329 330 test-purge.t
330 331 test-push-checkheads-partial-C1.t
331 332 test-push-checkheads-partial-C2.t
332 333 test-push-checkheads-partial-C3.t
333 334 test-push-checkheads-partial-C4.t
334 335 test-push-checkheads-pruned-B1.t
335 336 test-push-checkheads-pruned-B2.t
336 337 test-push-checkheads-pruned-B3.t
337 338 test-push-checkheads-pruned-B4.t
338 339 test-push-checkheads-pruned-B5.t
339 340 test-push-checkheads-pruned-B6.t
340 341 test-push-checkheads-pruned-B7.t
341 342 test-push-checkheads-pruned-B8.t
342 343 test-push-checkheads-superceed-A1.t
343 344 test-push-checkheads-superceed-A2.t
344 345 test-push-checkheads-superceed-A3.t
345 346 test-push-checkheads-superceed-A4.t
346 347 test-push-checkheads-superceed-A5.t
347 348 test-push-checkheads-superceed-A6.t
348 349 test-push-checkheads-superceed-A7.t
349 350 test-push-checkheads-superceed-A8.t
350 351 test-push-checkheads-unpushed-D1.t
351 352 test-push-checkheads-unpushed-D2.t
352 353 test-push-checkheads-unpushed-D3.t
353 354 test-push-checkheads-unpushed-D4.t
354 355 test-push-checkheads-unpushed-D5.t
355 356 test-push-checkheads-unpushed-D6.t
356 357 test-push-checkheads-unpushed-D7.t
357 358 test-push-http.t
358 359 test-push-warn.t
359 360 test-pushvars.t
360 361 test-rebase-abort.t
361 362 test-rebase-base-flag.t
362 363 test-rebase-bookmarks.t
363 364 test-rebase-brute-force.t
364 365 test-rebase-cache.t
365 366 test-rebase-check-restore.t
366 367 test-rebase-collapse.t
367 368 test-rebase-conflicts.t
368 369 test-rebase-dest.t
369 370 test-rebase-detach.t
370 371 test-rebase-emptycommit.t
371 372 test-rebase-inmemory.t
372 373 test-rebase-interruptions.t
373 374 test-rebase-issue-noparam-single-rev.t
374 375 test-rebase-legacy.t
375 376 test-rebase-mq-skip.t
376 377 test-rebase-mq.t
377 378 test-rebase-named-branches.t
378 379 test-rebase-newancestor.t
379 380 test-rebase-obsolete.t
380 381 test-rebase-parameters.t
381 382 test-rebase-partial.t
382 383 test-rebase-pull.t
383 384 test-rebase-rename.t
384 385 test-rebase-scenario-global.t
385 386 test-rebase-templates.t
386 387 test-rebase-transaction.t
387 388 test-record.t
388 389 test-relink.t
389 390 test-remove.t
390 391 test-rename-after-merge.t
391 392 test-rename-dir-merge.t
392 393 test-rename-merge1.t
393 394 test-rename.t
394 395 test-repair-strip.t
395 396 test-repo-compengines.t
396 397 test-resolve.t
397 398 test-revert-flags.t
398 399 test-revert-unknown.t
399 400 test-revlog-ancestry.py
400 401 test-revlog-group-emptyiter.t
401 402 test-revlog-mmapindex.t
402 403 test-revlog-packentry.t
403 404 test-revset-dirstate-parents.t
404 405 test-revset-legacy-lookup.t
405 406 test-revset-outgoing.t
406 407 test-rollback.t
407 408 test-run-tests.py
408 409 test-run-tests.t
409 410 test-schemes.t
410 411 test-serve.t
411 412 test-setdiscovery.t
412 413 test-share.t
413 414 test-shelve.t
414 415 test-show-stack.t
415 416 test-show-work.t
416 417 test-show.t
417 418 test-simple-update.t
418 419 test-simplemerge.py
419 420 test-single-head.t
420 421 test-sparse-clear.t
421 422 test-sparse-import.t
422 423 test-sparse-merges.t
423 424 test-sparse-profiles.t
424 425 test-sparse-requirement.t
425 426 test-sparse-verbose-json.t
426 427 test-ssh-clone-r.t
427 428 test-ssh-proto.t
428 429 test-sshserver.py
429 430 test-stack.t
430 431 test-status-rev.t
431 432 test-status-terse.t
432 433 test-strip-cross.t
433 434 test-strip.t
434 435 test-subrepo-deep-nested-change.t
435 436 test-subrepo-missing.t
436 437 test-subrepo-recursion.t
437 438 test-subrepo-relative-path.t
438 439 test-subrepo.t
439 440 test-symlinks.t
440 441 test-tag.t
441 442 test-tags.t
442 443 test-template-engine.t
443 444 test-treemanifest.t
444 445 test-unamend.t
445 446 test-uncommit.t
446 447 test-unified-test.t
447 448 test-unrelated-pull.t
448 449 test-up-local-change.t
449 450 test-update-branches.t
450 451 test-update-dest.t
451 452 test-update-issue1456.t
452 453 test-update-names.t
453 454 test-update-reverse.t
454 455 test-upgrade-repo.t
455 456 test-url-download.t
456 457 test-url-rev.t
457 458 test-url.py
458 459 test-username-newline.t
459 460 test-verify.t
460 461 test-walkrepo.py
461 462 test-websub.t
462 463 test-win32text.t
463 464 test-wireproto-clientreactor.py
464 465 test-wireproto-framing.py
465 466 test-wireproto-serverreactor.py
466 467 test-xdg.t
@@ -1,218 +1,218
1 1 """This unit test primarily tests parsers.parse_index2().
2 2
3 3 It also checks certain aspects of the parsers module as a whole.
4 4 """
5 5
6 6 from __future__ import absolute_import, print_function
7 7
8 8 import struct
9 9 import subprocess
10 10 import sys
11 11
12 12 from mercurial.node import (
13 13 nullid,
14 14 nullrev,
15 15 )
16 16 from mercurial import (
17 17 policy,
18 18 )
19 19
20 20 parsers = policy.importmod(r'parsers')
21 21
22 22 # original python implementation
23 23 def gettype(q):
24 24 return int(q & 0xFFFF)
25 25
26 26 def offset_type(offset, type):
27 return long(long(offset) << 16 | type)
27 return int(int(offset) << 16 | type)
28 28
29 29 indexformatng = ">Qiiiiii20s12x"
30 30
31 31 def py_parseindex(data, inline) :
32 32 s = 64
33 33 cache = None
34 34 index = []
35 35 nodemap = {nullid: nullrev}
36 36 n = off = 0
37 37
38 38 l = len(data) - s
39 39 append = index.append
40 40 if inline:
41 41 cache = (0, data)
42 42 while off <= l:
43 43 e = struct.unpack(indexformatng, data[off:off + s])
44 44 nodemap[e[7]] = n
45 45 append(e)
46 46 n += 1
47 47 if e[1] < 0:
48 48 break
49 49 off += e[1] + s
50 50 else:
51 51 while off <= l:
52 52 e = struct.unpack(indexformatng, data[off:off + s])
53 53 nodemap[e[7]] = n
54 54 append(e)
55 55 n += 1
56 56 off += s
57 57
58 58 e = list(index[0])
59 59 type = gettype(e[0])
60 60 e[0] = offset_type(0, type)
61 61 index[0] = tuple(e)
62 62
63 63 # add the magic null revision at -1
64 64 index.append((0, 0, 0, -1, -1, -1, -1, nullid))
65 65
66 66 return index, cache
67 67
68 68 data_inlined = (
69 '\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x01\x8c'
70 '\x00\x00\x04\x07\x00\x00\x00\x00\x00\x00\x15\x15\xff\xff\xff'
71 '\xff\xff\xff\xff\xff\xebG\x97\xb7\x1fB\x04\xcf\x13V\x81\tw\x1b'
72 'w\xdduR\xda\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
73 'x\x9c\x9d\x93?O\xc30\x10\xc5\xf7|\x8a\xdb\x9a\xa8m\x06\xd8*\x95'
74 '\x81B\xa1\xa2\xa2R\xcb\x86Pd\x9a\x0b5$vd_\x04\xfd\xf6\x9c\xff@'
75 '\x11!\x0b\xd9\xec\xf7\xbbw\xe7gG6\xad6\x04\xdaN\xc0\x92\xa0$)'
76 '\xb1\x82\xa2\xd1%\x16\xa4\x8b7\xa9\xca\xd4-\xb2Y\x02\xfc\xc9'
77 '\xcaS\xf9\xaeX\xed\xb6\xd77Q\x02\x83\xd4\x19\xf5--Y\xea\xe1W'
78 '\xab\xed\x10\xceR\x0f_\xdf\xdf\r\xe1,\xf5\xf0\xcb\xf5 \xceR\x0f'
79 '_\xdc\x0e\x0e\xc3R\x0f_\xae\x96\x9b!\x9e\xa5\x1e\xbf\xdb,\x06'
80 '\xc7q\x9a/\x88\x82\xc3B\xea\xb5\xb4TJ\x93\xb6\x82\x0e\xe16\xe6'
81 'KQ\xdb\xaf\xecG\xa3\xd1 \x01\xd3\x0b_^\xe8\xaa\xa0\xae\xad\xd1'
82 '&\xbef\x1bz\x08\xb0|\xc9Xz\x06\xf6Z\x91\x90J\xaa\x17\x90\xaa'
83 '\xd2\xa6\x11$5C\xcf\xba#\xa0\x03\x02*2\x92-\xfc\xb1\x94\xdf\xe2'
84 '\xae\xb8\'m\x8ey0^\x85\xd3\x82\xb4\xf0`:\x9c\x00\x8a\xfd\x01'
85 '\xb0\xc6\x86\x8b\xdd\xae\x80\xf3\xa9\x9fd\x16\n\x00R%\x1a\x06'
86 '\xe9\xd8b\x98\x1d\xf4\xf3+\x9bf\x01\xd8p\x1b\xf3.\xed\x9f^g\xc3'
87 '^\xd9W81T\xdb\xd5\x04sx|\xf2\xeb\xd6`%?x\xed"\x831\xbf\xf3\xdc'
88 'b\xeb%gaY\xe1\xad\x9f\xb9f\'1w\xa9\xa5a\x83s\x82J\xb98\xbc4\x8b'
89 '\x83\x00\x9f$z\xb8#\xa5\xb1\xdf\x98\xd9\xec\x1b\x89O\xe3Ts\x9a4'
90 '\x17m\x8b\xfc\x8f\xa5\x95\x9a\xfc\xfa\xed,\xe5|\xa1\xfe\x15\xb9'
91 '\xbc\xb2\x93\x1f\xf2\x95\xff\xdf,\x1a\xc5\xe7\x17*\x93Oz:>\x0e'
69 b'\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x01\x8c'
70 b'\x00\x00\x04\x07\x00\x00\x00\x00\x00\x00\x15\x15\xff\xff\xff'
71 b'\xff\xff\xff\xff\xff\xebG\x97\xb7\x1fB\x04\xcf\x13V\x81\tw\x1b'
72 b'w\xdduR\xda\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
73 b'x\x9c\x9d\x93?O\xc30\x10\xc5\xf7|\x8a\xdb\x9a\xa8m\x06\xd8*\x95'
74 b'\x81B\xa1\xa2\xa2R\xcb\x86Pd\x9a\x0b5$vd_\x04\xfd\xf6\x9c\xff@'
75 b'\x11!\x0b\xd9\xec\xf7\xbbw\xe7gG6\xad6\x04\xdaN\xc0\x92\xa0$)'
76 b'\xb1\x82\xa2\xd1%\x16\xa4\x8b7\xa9\xca\xd4-\xb2Y\x02\xfc\xc9'
77 b'\xcaS\xf9\xaeX\xed\xb6\xd77Q\x02\x83\xd4\x19\xf5--Y\xea\xe1W'
78 b'\xab\xed\x10\xceR\x0f_\xdf\xdf\r\xe1,\xf5\xf0\xcb\xf5 \xceR\x0f'
79 b'_\xdc\x0e\x0e\xc3R\x0f_\xae\x96\x9b!\x9e\xa5\x1e\xbf\xdb,\x06'
80 b'\xc7q\x9a/\x88\x82\xc3B\xea\xb5\xb4TJ\x93\xb6\x82\x0e\xe16\xe6'
81 b'KQ\xdb\xaf\xecG\xa3\xd1 \x01\xd3\x0b_^\xe8\xaa\xa0\xae\xad\xd1'
82 b'&\xbef\x1bz\x08\xb0|\xc9Xz\x06\xf6Z\x91\x90J\xaa\x17\x90\xaa'
83 b'\xd2\xa6\x11$5C\xcf\xba#\xa0\x03\x02*2\x92-\xfc\xb1\x94\xdf\xe2'
84 b'\xae\xb8\'m\x8ey0^\x85\xd3\x82\xb4\xf0`:\x9c\x00\x8a\xfd\x01'
85 b'\xb0\xc6\x86\x8b\xdd\xae\x80\xf3\xa9\x9fd\x16\n\x00R%\x1a\x06'
86 b'\xe9\xd8b\x98\x1d\xf4\xf3+\x9bf\x01\xd8p\x1b\xf3.\xed\x9f^g\xc3'
87 b'^\xd9W81T\xdb\xd5\x04sx|\xf2\xeb\xd6`%?x\xed"\x831\xbf\xf3\xdc'
88 b'b\xeb%gaY\xe1\xad\x9f\xb9f\'1w\xa9\xa5a\x83s\x82J\xb98\xbc4\x8b'
89 b'\x83\x00\x9f$z\xb8#\xa5\xb1\xdf\x98\xd9\xec\x1b\x89O\xe3Ts\x9a4'
90 b'\x17m\x8b\xfc\x8f\xa5\x95\x9a\xfc\xfa\xed,\xe5|\xa1\xfe\x15\xb9'
91 b'\xbc\xb2\x93\x1f\xf2\x95\xff\xdf,\x1a\xc5\xe7\x17*\x93Oz:>\x0e'
92 92 )
93 93
94 94 data_non_inlined = (
95 '\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01D\x19'
96 '\x00\x07e\x12\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff'
97 '\xff\xff\xff\xff\xd1\xf4\xbb\xb0\xbe\xfc\x13\xbd\x8c\xd3\x9d'
98 '\x0f\xcd\xd9;\x8c\x07\x8cJ/\x00\x00\x00\x00\x00\x00\x00\x00\x00'
99 '\x00\x00\x00\x00\x00\x00\x01D\x19\x00\x00\x00\x00\x00\xdf\x00'
100 '\x00\x01q\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\xff'
101 '\xff\xff\xff\xc1\x12\xb9\x04\x96\xa4Z1t\x91\xdfsJ\x90\xf0\x9bh'
102 '\x07l&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
103 '\x00\x01D\xf8\x00\x00\x00\x00\x01\x1b\x00\x00\x01\xb8\x00\x00'
104 '\x00\x01\x00\x00\x00\x02\x00\x00\x00\x01\xff\xff\xff\xff\x02\n'
105 '\x0e\xc6&\xa1\x92\xae6\x0b\x02i\xfe-\xe5\xbao\x05\xd1\xe7\x00'
106 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01F'
107 '\x13\x00\x00\x00\x00\x01\xec\x00\x00\x03\x06\x00\x00\x00\x01'
108 '\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1'
109 '\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00'
110 '\x00\x00\x00\x00\x00\x00\x00\x00\x00'
95 b'\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01D\x19'
96 b'\x00\x07e\x12\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff'
97 b'\xff\xff\xff\xff\xd1\xf4\xbb\xb0\xbe\xfc\x13\xbd\x8c\xd3\x9d'
98 b'\x0f\xcd\xd9;\x8c\x07\x8cJ/\x00\x00\x00\x00\x00\x00\x00\x00\x00'
99 b'\x00\x00\x00\x00\x00\x00\x01D\x19\x00\x00\x00\x00\x00\xdf\x00'
100 b'\x00\x01q\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\xff'
101 b'\xff\xff\xff\xc1\x12\xb9\x04\x96\xa4Z1t\x91\xdfsJ\x90\xf0\x9bh'
102 b'\x07l&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
103 b'\x00\x01D\xf8\x00\x00\x00\x00\x01\x1b\x00\x00\x01\xb8\x00\x00'
104 b'\x00\x01\x00\x00\x00\x02\x00\x00\x00\x01\xff\xff\xff\xff\x02\n'
105 b'\x0e\xc6&\xa1\x92\xae6\x0b\x02i\xfe-\xe5\xbao\x05\xd1\xe7\x00'
106 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01F'
107 b'\x13\x00\x00\x00\x00\x01\xec\x00\x00\x03\x06\x00\x00\x00\x01'
108 b'\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1'
109 b'\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00'
110 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00'
111 111 )
112 112
113 113 def parse_index2(data, inline):
114 114 index, chunkcache = parsers.parse_index2(data, inline)
115 115 return list(index), chunkcache
116 116
117 117 def importparsers(hexversion):
118 118 """Import mercurial.parsers with the given sys.hexversion."""
119 119 # The file parsers.c inspects sys.hexversion to determine the version
120 120 # of the currently-running Python interpreter, so we monkey-patch
121 121 # sys.hexversion to simulate using different versions.
122 122 code = ("import sys; sys.hexversion=%s; "
123 123 "import mercurial.cext.parsers" % hexversion)
124 124 cmd = "python -c \"%s\"" % code
125 125 # We need to do these tests inside a subprocess because parser.c's
126 126 # version-checking code happens inside the module init function, and
127 127 # when using reload() to reimport an extension module, "The init function
128 128 # of extension modules is not called a second time"
129 129 # (from http://docs.python.org/2/library/functions.html?#reload).
130 130 p = subprocess.Popen(cmd, shell=True,
131 131 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
132 132 return p.communicate() # returns stdout, stderr
133 133
134 134 def printhexfail(testnumber, hexversion, stdout, expected):
135 135 try:
136 136 hexstring = hex(hexversion)
137 137 except TypeError:
138 138 hexstring = None
139 139 print("FAILED: version test #%s with Python %s and patched "
140 140 "sys.hexversion %r (%r):\n Expected %s but got:\n-->'%s'\n" %
141 141 (testnumber, sys.version_info, hexversion, hexstring, expected,
142 142 stdout))
143 143
144 144 def testversionokay(testnumber, hexversion):
145 145 stdout, stderr = importparsers(hexversion)
146 146 if stdout:
147 147 printhexfail(testnumber, hexversion, stdout, expected="no stdout")
148 148
149 149 def testversionfail(testnumber, hexversion):
150 150 stdout, stderr = importparsers(hexversion)
151 151 # We include versionerrortext to distinguish from other ImportErrors.
152 152 errtext = "ImportError: %s" % parsers.versionerrortext
153 153 if errtext not in stdout:
154 154 printhexfail(testnumber, hexversion, stdout,
155 155 expected="stdout to contain %r" % errtext)
156 156
157 157 def makehex(major, minor, micro):
158 158 return int("%x%02x%02x00" % (major, minor, micro), 16)
159 159
160 160 def runversiontests():
161 161 """Check the version-detection logic when importing parsers."""
162 162 info = sys.version_info
163 163 major, minor, micro = info[0], info[1], info[2]
164 164 # Test same major-minor versions.
165 165 testversionokay(1, makehex(major, minor, micro))
166 166 testversionokay(2, makehex(major, minor, micro + 1))
167 167 # Test different major-minor versions.
168 168 testversionfail(3, makehex(major + 1, minor, micro))
169 169 testversionfail(4, makehex(major, minor + 1, micro))
170 170 testversionfail(5, "'foo'")
171 171
172 172 def runtest() :
173 173 # Only test the version-detection logic if it is present.
174 174 try:
175 175 parsers.versionerrortext
176 176 except AttributeError:
177 177 pass
178 178 else:
179 179 runversiontests()
180 180
181 181 # Check that parse_index2() raises TypeError on bad arguments.
182 182 try:
183 183 parse_index2(0, True)
184 184 except TypeError:
185 185 pass
186 186 else:
187 187 print("Expected to get TypeError.")
188 188
189 189 # Check parsers.parse_index2() on an index file against the original
190 190 # Python implementation of parseindex, both with and without inlined data.
191 191
192 192 py_res_1 = py_parseindex(data_inlined, True)
193 193 c_res_1 = parse_index2(data_inlined, True)
194 194
195 195 py_res_2 = py_parseindex(data_non_inlined, False)
196 196 c_res_2 = parse_index2(data_non_inlined, False)
197 197
198 198 if py_res_1 != c_res_1:
199 199 print("Parse index result (with inlined data) differs!")
200 200
201 201 if py_res_2 != c_res_2:
202 202 print("Parse index result (no inlined data) differs!")
203 203
204 204 ix = parsers.parse_index2(data_inlined, True)[0]
205 205 for i, r in enumerate(ix):
206 206 if r[7] == nullid:
207 207 i = -1
208 208 try:
209 209 if ix[r[7]] != i:
210 210 print('Reverse lookup inconsistent for %r'
211 211 % r[7].encode('hex'))
212 212 except TypeError:
213 213 # pure version doesn't support this
214 214 break
215 215
216 216 print("done")
217 217
218 218 runtest()
General Comments 0
You need to be logged in to leave comments. Login now