mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-28 15:34:22 +00:00
987aecc749
I have been trying to figure out how to generalize diffs and merges for arbitrary number of inputs. For example, I want to have an internal representation of an octopus merge adding 5 inputs (file states/contents) and removing 4 inputs. I also want to be to represent a diff from a regular 3-way-conflict state to a resolved state. Such a diff would be from a state adding two inputs and removing one, to a state adding just one input. I finally realized last week that the problem is simple if you don't care about adds vs removes. Instead, you line up the matching and differing parts of all the inputs. It's then up to the caller to use it in an appropriate way for its use case. For example, a regular diff would pass in two inputs and would get back a list of matching and dffering hunks. It might then present the first element of differing hunks in red and the second element in green. Similarly, a 3-way merge would pass in three inputs with the base first. It would then compare the sides and decide on a resolution (or leave it unresolved if all three sides are different). This change adds a type representing this kind of multi-way diff. Coming changes will update existing code to use it. In addition to making the existing code simpler and more consistent, having this in place should also: * Make it much easier to present merge conflicts involving more than 3 parts. * Experiment with different ways of displaying diffs from/to conflict states. * Experiment with sub-line-level merging. |
||
---|---|---|
.. | ||
benches | ||
protos | ||
src | ||
tests | ||
build.rs | ||
Cargo.toml |