On Mon, Aug 28, 2017 at 9:05 PM, Julian Foad <julianf...@apache.org> wrote: > Branko Čibej wrote: >> On the topic of storing patches, I'd like to propose an alternative >> implementation. >> >> Instead of saving a set of patches, save two sets of (untranslated >> pristine) files: >> >> * All currently modified files >> * Their pristine, unmodified versions (these are of course already in >> the pristine store and would only need an extra reference in the WC >> DB so that 'svn cleanup' doesn't delete them). > >> The idea is that 'unshelve' could, instead of applying patches to the >> current working copy, invoke our built-in diff3 algorithm with whole >> (untranslated!) files. This is likely to produce much better results and >> saner conflict info than applying patches, which have limited context >> information. > > Thanks for the thoughts. > > Three-way merging should indeed produce better results than patching > when applying the results to a base other than the original base. We > know that patching is sufficient for many use cases, but we also know > there are cases that where a proper merge would be superior, and they > might turn out to be common in certain usage patterns. I would certainly > be happier if we could do that.
There is one big disadvantage of storing the complete modified files, and that's storage. If I'm making a small edit to a 100 MB file, instead of storing a patch of 500 bytes, I have to store 100 MB per shelved change. I'm not an expert, but do you really need the modified file itself, if you have the patch and a reference to the base file (pristine)? Why store both F (pristine) and F' (modified file), if I can reconstruct F' out of F + P (patch). So I suggest: * Store the patch * Keep the pristine on which the patch was based (keep a reference to it in the pristine store, like in Brane's suggestion) We can still perform the 3-way merge by first reconstructing F and F' out of F and P. And even if the pristine gets lost (either because the patch was transferred to another user; or because the user executed the not-yet-existing command 'svn cleanup --vacuum-shelve-pristines' to reclaim diskspace) the patch will still be usable, although without the 3-way merging. -- Johan