Mercurial > hg
annotate tests/readlink.py @ 33766:4c706037adef
wireproto: overhaul iterating batcher code (API)
The remote batching code is difficult to read. Let's improve it.
As part of the refactor, the future returned by method calls on
batchiter() instances is now populated. However, you still need to
consume the results() generator for the future to be set. But at
least now we can stuff the future somewhere and not have to worry
about aligning method call order with result order since you can
use a future to hold the result.
Also as part of the change, we now verify that @batchable generators
yield exactly 2 values. In other words, we enforce their API.
The non-iter batcher has been unused since b6e71f8af5b8. And to my
surprise we had no explicit unit test coverage of it! test-batching.py
has been overhauled to use the iterating batcher.
Since the iterating batcher doesn't allow non-batchable method
calls nor local calls, tests have been updated to reflect reality.
The iterating batcher has been used for multiple releases apparently
without major issue. So this shouldn't cause alarm.
.. api::
@peer.batchable functions must now yield exactly 2 values
Differential Revision: https://phab.mercurial-scm.org/D319
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 09 Aug 2017 23:29:30 -0700 |
parents | 6a98f9408a50 |
children | c102b704edb5 |
rev | line source |
---|---|
5683
396c7010b0cd
Use common readlink.py instead of own implementations per test script.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
396c7010b0cd
Use common readlink.py instead of own implementations per test script.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
2 |
29485
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29175
diff
changeset
|
3 from __future__ import absolute_import, print_function |
29175
7bcfb9090c86
readlink: use print_function
timeless <timeless@mozdev.org>
parents:
25660
diff
changeset
|
4 |
29485
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29175
diff
changeset
|
5 import errno |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29175
diff
changeset
|
6 import os |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29175
diff
changeset
|
7 import sys |
5683
396c7010b0cd
Use common readlink.py instead of own implementations per test script.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
8 |
396c7010b0cd
Use common readlink.py instead of own implementations per test script.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
9 for f in sys.argv[1:]: |
396c7010b0cd
Use common readlink.py instead of own implementations per test script.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
10 try: |
29175
7bcfb9090c86
readlink: use print_function
timeless <timeless@mozdev.org>
parents:
25660
diff
changeset
|
11 print(f, '->', os.readlink(f)) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
10282
diff
changeset
|
12 except OSError as err: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
5683
diff
changeset
|
13 if err.errno != errno.EINVAL: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
5683
diff
changeset
|
14 raise |
29175
7bcfb9090c86
readlink: use print_function
timeless <timeless@mozdev.org>
parents:
25660
diff
changeset
|
15 print(f, '->', f, 'not a symlink') |
5683
396c7010b0cd
Use common readlink.py instead of own implementations per test script.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
16 |
396c7010b0cd
Use common readlink.py instead of own implementations per test script.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
17 sys.exit(0) |