More refactoring, updated support for synchronizing with shallow clones.

You can now push and pull from a remote shallow clone as long as it has
enough history to perform the operation.