Patchwork D8922: merge: introduce `addcommitinfo()` on mergeresult object

login
register
mail settings
Submitter phabricator
Date Aug. 10, 2020, 11:18 a.m.
Message ID <differential-rev-PHID-DREV-is5giqijx3qacdgqxr5h-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47021/
State Superseded
Headers show

Comments

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

REVISION SUMMARY
  This makes code little bit nicer as we directly update information in the
  mergeresult object instead of building up a dict first and then setting it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -582,10 +582,9 @@ 
         self._commitinfo = collections.defaultdict(dict)
         self._actionmapping = collections.defaultdict(dict)
 
-    def updatevalues(self, diverge, renamedelete, commitinfo):
+    def updatevalues(self, diverge, renamedelete):
         self._diverge = diverge
         self._renamedelete = renamedelete
-        self._commitinfo = commitinfo
 
     def addfile(self, filename, action, data, message):
         """ adds a new file to the mergeresult object
@@ -671,6 +670,11 @@ 
             for key, val in pycompat.iteritems(self._filemapping):
                 yield key, val
 
+    def addcommitinfo(self, filename, key, value):
+        """ adds key-value information about filename which will be required
+        while committing this merge """
+        self._commitinfo[filename][key] = value
+
     @property
     def diverge(self):
         return self._diverge
@@ -756,7 +760,6 @@ 
     # information from merge which is needed at commit time
     # for example choosing filelog of which parent to commit
     # TODO: use specific constants in future for this mapping
-    commitinfo = collections.defaultdict(dict)
     if followcopies:
         branch_copies1, branch_copies2, diverge = copies.mergecopies(
             repo, wctx, p2, pa
@@ -844,7 +847,7 @@ 
                             b'remote is newer',
                         )
                         if branchmerge:
-                            commitinfo[f][b'filenode'] = b'other'
+                            mresult.addcommitinfo(f, b'filenode', b'other')
                 elif nol and n2 == a:  # remote only changed 'x'
                     mresult.addfile(
                         f,
@@ -860,7 +863,7 @@ 
                         b'remote is newer',
                     )
                     if branchmerge:
-                        commitinfo[f][b'filenode'] = b'other'
+                        mresult.addcommitinfo(f, b'filenode', b'other')
                 else:  # both changed something
                     mresult.addfile(
                         f,
@@ -1027,7 +1030,7 @@ 
     renamedelete = branch_copies1.renamedelete
     renamedelete.update(branch_copies2.renamedelete)
 
-    mresult.updatevalues(diverge, renamedelete, commitinfo)
+    mresult.updatevalues(diverge, renamedelete)
     return mresult
 
 
@@ -1183,8 +1186,7 @@ 
             mresult.addfile(f, *l[0])
             continue
         repo.ui.note(_(b'end of auction\n\n'))
-        # TODO: think about commitinfo when bid merge is used
-        mresult.updatevalues(diverge, renamedelete, {})
+        mresult.updatevalues(diverge, renamedelete)
 
     if wctx.rev() is None:
         _forgetremoved(wctx, mctx, branchmerge, mresult)