revlog: refactor out the rev-oriented part of commonancestorheads
We plan to use this in a function taking revs as argument. Round trips to nodes
seem silly.
## Avoid interference from actual test env:unset HGTEST_JOBSunset HGTEST_TIMEOUTunset HGTEST_PORTunset HGTEST_SHELL