topic: don't lose any file changes when changing topic of a merge commit

This file-related logic is taken directly from cmdutil.amend().

--HG--
branch : stable
8 jobs for topic/stable/retopic-merge in 4 minutes and 34 seconds (queued for 1 second)
Status Job ID Name Coverage
  Test
passed #195168
checks-py2

00:02:19

passed #195169
checks-py3

00:01:31

passed #195174
doc

00:02:18

manual #195167
allowed to fail manual
pytype
passed #195170
tests-py2-cext

00:04:34

passed #195171
tests-py2-pure

00:04:22

passed #195172
tests-py3-cext

00:04:27

passed #195173
tests-py3-pure

00:04:15