branchcache: move loading of branch names and nodes into it's own function

Authored by pulkit.

Description

branchcache: move loading of branch names and nodes into it's own function

This will help me in implementing lazy loading of the branchcache in upcoming
patches.

Differential Revision: https://phab.mercurial-scm.org/D6023