changeset 45403:f970cca30989

merge: use collections.defaultdict() for mergeresult.commitinfo We will be storing info from mergeresult.commitinfo to mergestate._stateextras in upcoming patches, let's make them use same structure so that we don't have to make much efforts in transferring info from one to other. Differential Revision: https://phab.mercurial-scm.org/D8921
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 10 Aug 2020 15:34:27 +0530
parents 0652a533fe3c
children 72e503a24715
files mercurial/merge.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Mon Aug 10 15:29:02 2020 +0530
+++ b/mercurial/merge.py	Mon Aug 10 15:34:27 2020 +0530
@@ -579,7 +579,7 @@
         self._filemapping = {}
         self._diverge = {}
         self._renamedelete = {}
-        self._commitinfo = {}
+        self._commitinfo = collections.defaultdict(dict)
         self._actionmapping = collections.defaultdict(dict)
 
     def updatevalues(self, diverge, renamedelete, commitinfo):
@@ -756,7 +756,7 @@
     # 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 = {}
+    commitinfo = collections.defaultdict(dict)
     if followcopies:
         branch_copies1, branch_copies2, diverge = copies.mergecopies(
             repo, wctx, p2, pa
@@ -844,7 +844,7 @@
                             b'remote is newer',
                         )
                         if branchmerge:
-                            commitinfo[f] = b'other'
+                            commitinfo[f][b'filenode-source'] = b'other'
                 elif nol and n2 == a:  # remote only changed 'x'
                     mresult.addfile(
                         f,
@@ -860,7 +860,7 @@
                         b'remote is newer',
                     )
                     if branchmerge:
-                        commitinfo[f] = b'other'
+                        commitinfo[f][b'filenode-source'] = b'other'
                 else:  # both changed something
                     mresult.addfile(
                         f,
@@ -1363,7 +1363,7 @@
     for f, op in pycompat.iteritems(mresult.commitinfo):
         # the other side of filenode was choosen while merging, store this in
         # mergestate so that it can be reused on commit
-        if op == b'other':
+        if op[b'filenode-source'] == b'other':
             ms.addmergedother(f)
 
     moves = []