replay: Check relative / recursive externals only when closing root dir
These operations need only to be performed once at the end of a revision replay when closing the root directory.
Previously it was performed each time a sub-directory was closed which was significantly slowing down the loading process.
Related to #611
Migrated from D7107 (view on Phabricator)