Page MenuHomePhabricator

copies: make mergecopies() distinguish between copies on each side

Authored by martinvonz on Jan 24 2020, 5:00 PM.



I find it confusing that most of the dicts returned from
mergecopies() have entries specific to one branch of the merge, but
they're still combined into dict. For example, you can't tell if `copy

{"bar": "foo"}` means that "foo" was copied to "bar" on the first

branch or the second.

It also feels like there are bugs lurking here because we may mistake
which side the copy happened on. However, for most of the dicts, it's
not possible that there is disagreement. For example, renamedelete
keeps track of renames that happened on one side of the merge where
the other side deleted the file. There can't be a disagreement there
(because we record that in the diverge dict instead). For regular
copies/renames, there can be a disagreement. Let's say file "foo" was
copied to "bar" on one branch and file "baz" was copied to "bar" on
the other. Beacause we only return one copy dict, we end up
replacing the {"bar": "foo"} entry by {"bar": "baz"}. The merge
code (manifestmerge()) will then decide that that means "both
renamed from 'baz'". We should probably treat it as a conflict

The next few patches will make mergecopies() return two instances of
most of the returned copies. That will lead to a bit more code (~40
lines), but I think it makes both copies.mergecopies() and
merge.manifestmerge() clearer.

Diff Detail

rHG Mercurial
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

martinvonz created this revision.Jan 24 2020, 5:00 PM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.