Patchwork D8819: merge: make mergeresult constructor initialize empty object

login
register
mail settings
Submitter phabricator
Date July 25, 2020, 10 a.m.
Message ID <differential-rev-PHID-DREV-loldexmj4v3pb26xlacq-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46890/
State Superseded
Headers show

Comments

phabricator - July 25, 2020, 10 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In future patches, we will be going to update mergeresult object
  instead of building an actions dict and then setting it in the object.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -546,7 +546,7 @@ 
     It has information about what actions need to be performed on dirstate
     mapping of divergent renames and other such cases. '''
 
-    def __init__(self, actions, diverge, renamedelete, commitinfo):
+    def __init__(self):
         """
         actions: dict of filename as keys and action related info as values
         diverge: mapping of source name -> list of dest name for
@@ -556,7 +556,12 @@ 
         commitinfo: dict containing data which should be used on commit
                     contains a filename -> info mapping
         """
+        self._actions = {}
+        self._diverge = {}
+        self._renamedelete = {}
+        self._commitinfo = {}
 
+    def updatevalues(self, actions, diverge, renamedelete, commitinfo):
         self._actions = actions
         self._diverge = diverge
         self._renamedelete = renamedelete
@@ -914,7 +919,9 @@ 
     renamedelete = branch_copies1.renamedelete
     renamedelete.update(branch_copies2.renamedelete)
 
-    return mergeresult(actions, diverge, renamedelete, commitinfo)
+    mresult = mergeresult()
+    mresult.updatevalues(actions, diverge, renamedelete, commitinfo)
+    return mresult
 
 
 def _resolvetrivial(repo, wctx, mctx, ancestor, actions):
@@ -965,6 +972,7 @@ 
     # Avoid cycle.
     from . import sparse
 
+    mresult = None
     if len(ancestors) == 1:  # default
         mresult = manifestmerge(
             repo,
@@ -1075,7 +1083,8 @@ 
             continue
         repo.ui.note(_(b'end of auction\n\n'))
         # TODO: think about commitinfo when bid merge is used
-        mresult = mergeresult(actions, diverge, renamedelete, {})
+        mresult = mergeresult()
+        mresult.updatevalues(actions, diverge, renamedelete, {})
 
     if wctx.rev() is None:
         fractions = _forgetremoved(wctx, mctx, branchmerge)