diff -r 7b474609f199 -r c7a04bfabd4d mercurial/merge.py --- a/mercurial/merge.py Wed Jan 04 19:30:47 2023 +0000 +++ b/mercurial/merge.py Thu Jan 12 13:14:00 2023 +0000 @@ -246,9 +246,7 @@ else: repo.ui.warn(_(b"%s: replacing untracked files in directory\n") % f) - for f, args, msg in list( - mresult.getactions([mergestatemod.ACTION_CREATED]) - ): + def transformargs(f, args): backup = ( f in fileconflicts or pathconflicts @@ -258,7 +256,11 @@ ) ) (flags,) = args - mresult.addfile(f, mergestatemod.ACTION_GET, (flags, backup), msg) + return (flags, backup) + + mresult.mapaction( + mergestatemod.ACTION_CREATED, mergestatemod.ACTION_GET, transformargs + ) def _forgetremoved(wctx, mctx, branchmerge, mresult): @@ -590,6 +592,18 @@ self._filemapping[filename] = (action, data, message) self._actionmapping[action][filename] = (data, message) + def mapaction(self, actionfrom, actionto, transform): + """changes all occurrences of action `actionfrom` into `actionto`, + transforming its args with the function `transform`. + """ + orig = self._actionmapping[actionfrom] + del self._actionmapping[actionfrom] + dest = self._actionmapping[actionto] + for f, (data, msg) in orig.items(): + data = transform(f, data) + self._filemapping[f] = (actionto, data, msg) + dest[f] = (data, msg) + def getfile(self, filename, default_return=None): """returns (action, args, msg) about this file