Expand Merge API.

This includes refactoring of the merge logic to support different merge workflows, including pull.

Also adds a simple repository to perform merges in, simplying test logic.