From patchwork Mon Aug 10 11:19:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D8923: mergestate: replace `addmergedother()` with generic `addcommitinfo()` (API) From: phabricator X-Patchwork-Id: 47023 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 10 Aug 2020 11:19:04 +0000 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 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 = []