changeset 45347:1aef38d973e8

merge: pass mergeresult obj in _forgetremoved() (API) Instead of returning a dict of actions and then updating it, let's pass the object directly and update it there. This makes `updateactions()` on mergeresult unused and this patch removes that. After this patch, we have couple of methods left on mergeresult class which still exposes the internal dict based action storage. Differential Revision: https://phab.mercurial-scm.org/D8889
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 05 Aug 2020 16:52:51 +0530
parents 3c783ff08d40
children 490607efc992
files mercurial/merge.py
diffstat 1 files changed, 5 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Wed Aug 05 16:00:25 2020 +0530
+++ b/mercurial/merge.py	Wed Aug 05 16:52:51 2020 +0530
@@ -255,7 +255,7 @@
         mresult.addfile(f, mergestatemod.ACTION_GET, (flags, backup), msg)
 
 
-def _forgetremoved(wctx, mctx, branchmerge):
+def _forgetremoved(wctx, mctx, branchmerge, mresult):
     """
     Forget removed files
 
@@ -270,25 +270,20 @@
     as removed.
     """
 
-    actions = {}
     m = mergestatemod.ACTION_FORGET
     if branchmerge:
         m = mergestatemod.ACTION_REMOVE
     for f in wctx.deleted():
         if f not in mctx:
-            actions[f] = m, None, b"forget deleted"
+            mresult.addfile(f, m, None, b"forget deleted")
 
     if not branchmerge:
         for f in wctx.removed():
             if f not in mctx:
-                actions[f] = (
-                    mergestatemod.ACTION_FORGET,
-                    None,
-                    b"forget removed",
+                mresult.addfile(
+                    f, mergestatemod.ACTION_FORGET, None, b"forget removed",
                 )
 
-    return actions
-
 
 def _checkcollision(repo, wmf, mresult):
     """
@@ -704,10 +699,6 @@
         for f, (act, data, msg) in pycompat.iteritems(self._filemapping):
             self._actionmapping[act][f] = data, msg
 
-    def updateactions(self, updates):
-        for f, (a, data, msg) in pycompat.iteritems(updates):
-            self.addfile(f, a, data, msg)
-
     def hasconflicts(self):
         """ tells whether this merge resulted in some actions which can
         result in conflicts or not """
@@ -1196,8 +1187,7 @@
         mresult.updatevalues(diverge, renamedelete, {})
 
     if wctx.rev() is None:
-        fractions = _forgetremoved(wctx, mctx, branchmerge)
-        mresult.updateactions(fractions)
+        _forgetremoved(wctx, mctx, branchmerge, mresult)
 
     sparse.filterupdatesactions(repo, wctx, mctx, branchmerge, mresult)
     _resolvetrivial(repo, wctx, mctx, ancestors[0], mresult)