Share packs across repository instances

Opening the same repository multiple times will currently open the same
file multiple times, as well as map the same region of the file multiple
times. This is not necessary, as the packfile data is immutable.

Instead of opening and closing packfiles directly, introduce an
indirection and allocate packfiles globally. This does mean locking on
each packfile open, but we already use this lock for the global mwindow
list so it doesn't introduce a new contention point.

--- 

We probably want to add a test to actually make sure we're allocating the right number of packs, but I wanted to get some early feedback.

One thing that this means is that once you have the pack open, we won't check for permissions anymore, so if you open a repo as root and then drop to a normal user, we would still have it open as root, not that anybody should be doing anything of the sort.

/cc @vmg 
The pthreads docs seem to indicate that the errors would come from errors we do in dealing with the locks, so setting an error message would be good so we know where this happened, but I'm not sure that we would want to think too hard about freeing the resources. In this case it's just one free call, so it's not a big deal either way.