# HG changeset patch # User Martin von Zweigbergk # Date 2019-07-17 04:15:39 # Node ID 57ea0a81a65ce343200b05a62720d8eecd755e9f # Parent 6f0273558c4bfcf21e0a4766212956e081d5429c copies: remove existing copy info from the changeset on amend (BC) When amending a changeset with copy information in the changeset and the new changeset doesn't have any copy information (or similar for "filesadded" and "filesremoved"), we shouldn't keep it. A drawback of this is that we now unconditionally remove these four entries from the extras, breaking any extensions that happened to write entries with the same names (which seems very unlikely). I think I'd heard that there was list of blacklisted keys that would be removed from the extras when a commit is rewritten, but I couldn't find that. It would make sense to add the keys mentioned above there instead of the custom filtering I've added in this patch. Differential Revision: https://phab.mercurial-scm.org/D6752 diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -637,6 +637,9 @@ class changelog(revlog.revlog): if extra is None and any(x is not None for x in extrasentries): extra = {} sortedfiles = sorted(files) + if extra is not None: + for name in ('p1copies', 'p2copies', 'filesadded', 'filesremoved'): + extra.pop(name, None) if p1copies is not None: extra['p1copies'] = encodecopies(sortedfiles, p1copies) if p2copies is not None: diff --git a/tests/test-copies-in-changeset.t b/tests/test-copies-in-changeset.t --- a/tests/test-copies-in-changeset.t +++ b/tests/test-copies-in-changeset.t @@ -140,11 +140,7 @@ copy information on to the filelog saved backup bundle to $TESTTMP/repo/.hg/strip-backup/dd7bb9581359-a6e6b6d2-amend.hg $ hg changesetcopies files: j - filesadded: 0 - filesremoved: - p1copies: 0\x00a (esc) - p2copies: $ hg showcopies --config experimental.copies.read-from=filelog-only a -> j The entries should be written to extras even if they're empty (so the client