localrepo: refactor logic to calculate sharedvfs in separate fn
We will be reusing this in an upcoming patch, so better to refactor it into a
separate function. Also the underlying handling deserves a function of it's own.
Differential Revision: https://phab.mercurial-scm.org/D8909