Patchwork D8923: mergestate: replace `addmergedother()` with generic `addcommitinfo()` (API)

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

Comments

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

REVISION SUMMARY
  Storing that a file is resolved for the other parent while merging is just one
  case of things we will like to store in the mergestate. There are more which we
  will like to store.
  
  This patch replaces `addmergedother()` with a much more generic
  `addcommitinfo()`. Doing this, we also blinding stores the same key value pair
  generated by the merge code instead of touching them.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py
  mercurial/mergestate.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -592,8 +592,10 @@ 
         self._state[path] = [MERGE_RECORD_UNRESOLVED_PATH, frename, forigin]
         self._dirty = True
 
-    def addmergedother(self, path):
-        self._stateextras[path] = {b'filenode': b'other'}
+    def addcommitinfo(self, path, data):
+        """ stores information which is required at commit
+        into _stateextras """
+        self._stateextras[path].update(data)
         self._dirty = True
 
     def __contains__(self, dfile):
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1365,8 +1365,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'filenode'] == b'other':
-            ms.addmergedother(f)
+        ms.addcommitinfo(f, op)
 
     moves = []