Commit graph

4 commits

Author SHA1 Message Date
Martin von Zweigbergk
3f95dafd67 conflicts: resolve trivial merge of A+A-B+C-C to A
This changes the behavior in one of the cases ilyagr@
[mentioned](https://github.com/martinvonz/jj/pull/1610#discussion_r1199823932)
to match his suggestion. After some more thinking while working on
tree-level conflicts, I now think it's clear that the added `+C-C`
terms should have no effect on the result. A very similar argument is
that `Conflict::simplify()` should not change the result of
`trivial_merge()`. I'll add tests for that next.
2023-06-19 08:30:09 +02:00
Martin von Zweigbergk
a5883eba15 merge: make trivial_merge() return a reference
I don't know why I made it return an owned value. It seems like an
unnecessary restriction that the value implements `Clone`, so let's
return a reference instead.
2023-05-31 06:28:01 -07:00
Martin von Zweigbergk
ef7b831411 merge: optimize 3-way merge case
I haven't done any profiling to see if this is actually useful, but
it's also pretty simple to do.
2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
aa2792c5e5 merge: add a generic function for resolving trivial N-way merges
We already resolve merge conflicts between hunks, trees, and refs, and
maybe more. They each have their own code for the handling trivial
merges (where the output is equal to one of the inputs). They look
surprisingly different. This commit adds a generic function for doing
that. Curiously, this new implementation uses implements it in yet
another way (basically using a multi-set).
2023-05-24 22:00:38 -07:00