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 
This will leak the `packname` if there is a failure. I don't know what our policy is here anymore - are we worried about mutex and allocation errors or are they so exceedingly unlikely that not setting an error message or cleaning up an allocation isn't important? With the coverity scans, I thought we were trying to clean up these things more, but I don't intend to ask you to do something here that we don't bother to do elsewhere...