[Request] [+- ] D8889: merge: pass mergeresult obj in _forgetremoved() (API)

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Aug 5 12:12:28 UTC 2020


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

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)



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200805/8fae16e8/attachment-0001.html>


More information about the Mercurial-patches mailing list