# HG changeset patch # User Pierre-Yves David # Date 2020-09-14 21:47:42 # Node ID 751d9436141b2d6920b10ba73ab4e42cfd19d081 # Parent bb61352e59f5c26761a8cb465540858b56ac62b1 salvaged: record salvaged in ChangingFiles at commit time The new code is a simple but effective way to detect this information. We might be able to move it inside the various conditionnal above, but I want to focus on simplicity until we have a full working stack. It is worth noting that if we record the information in the ChangingFiles object, it is not persisted yet. This will comes with later changesets. Differential Revision: https://phab.mercurial-scm.org/D9120 diff --git a/mercurial/commit.py b/mercurial/commit.py --- a/mercurial/commit.py +++ b/mercurial/commit.py @@ -140,6 +140,19 @@ def _prepare_files(tr, ctx, error=False, files.update_copies_from_p1(ctx.p1copies()) files.update_copies_from_p2(ctx.p2copies()) + copy_sd = ctx.repo().filecopiesmode == b'changeset-sidedata' + if copy_sd and len(ctx.parents()) > 1: + # XXX this `mergestate.read` could be duplicated with a the merge state + # reading in _process_files So we could refactor further to reuse it in + # some cases. + ms = mergestate.mergestate.read(repo) + if ms.active(): + for fname in sorted(ms._stateextras.keys()): + might_removed = ms.extras(fname).get(b'merge-removal-candidate') + if might_removed == b'yes': + if fname in ctx: + files.mark_salvaged(fname) + return mn, files