phases: move the binary decoding function in the phases module
We move the decoding function near the encoding one in a place where they can
be reused in other place (current target, 'exchange.py').
## Avoid interference from actual test env:unset HGTEST_JOBSunset HGTEST_TIMEOUTunset HGTEST_PORTunset HGTEST_SHELL