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 59 seconds (queued for 2 seconds)
Status Name Job ID Coverage
  Test
passed checks-py2 #198129

00:00:59

passed checks-py3 #198130

00:01:17

passed doc #198135

00:00:19

manual pytype #198128
allowed to fail manual
passed tests-py2-cext #198131

00:04:59

passed tests-py2-pure #198132

00:04:28

passed tests-py3-cext #198133

00:03:32

passed tests-py3-pure #198134

00:04:27