Probably could cache the first result, and make it a bit smarter too (e.g. can we instantiate only scm apps?)
It turns out that guess_repo is already cached in the two places it's called, and I didn't want to hard-code tool-names to identify SCM apps (we probably need some way to identify "types" of tools).
However, guess_repo shouldn't have been being called at all, so I fixed that (missing call to set_context) so it should be much faster now.
To test, view any SCM tree with stats logging enabled (1) and see that guess_repo no longer shows up in the stats.
Couldn't duplicate guess_repo being called on a tree view, but it is called a lot on a log view.
Fix for History view and logging any other calls pushed.