upgrade: move optimisation to something more declarative
This is not great yet, but still better than the previous state. This get use
one step closer to having all the possible "actions" clearly declared and moved
in a dedicated module.
Differential Revision: https://phab.mercurial-scm.org/D9475
[tool.black]
line-length = 80
exclude = '''
build/
| wheelhouse/
| dist/
| packages/
| \.hg/
| \.mypy_cache/
| \.venv/
| mercurial/thirdparty/
'''
skip-string-normalization = true
quiet = true