Patchwork D8889: merge: pass mergeresult obj in _forgetremoved() (API)

login
register
mail settings
Submitter phabricator
Date Aug. 5, 2020, 12:12 p.m.
Message ID <differential-rev-PHID-DREV-oz6nf5miyj3jagzkxhsc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46987/
State Superseded
Headers show

Comments

phabricator - Aug. 5, 2020, 12:12 p.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8889

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -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)