Mercurial > hg
diff mercurial/merge.py @ 45334:b9b055f15035
merge: pass mergeresult obj instead of actions in applyupdates() (API)
This is similar to past 20 patches or so where we are replacing use of a bare
actions dict with a dedicated mergeresult object. The goal is to have a
dedicated powerful object instead of a dict while making the code more easier to
understand.
In past few patches, we have already simplified the code at some places using
the newly introduced object.
This patch does not updates applyupdates() to use the mergeresult object
directly. That will be done in next patch to make things easier to review.
Differential Revision: https://phab.mercurial-scm.org/D8876
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 03 Aug 2020 14:12:13 +0530 |
parents | f569ca3eb430 |
children | 2c96fd8e05f6 |
line wrap: on
line diff
--- a/mercurial/merge.py Mon Aug 03 13:30:14 2020 +0530 +++ b/mercurial/merge.py Mon Aug 03 14:12:13 2020 +0530 @@ -1328,7 +1328,7 @@ def applyupdates( repo, - actions, + mresult, wctx, mctx, overwrite, @@ -1338,6 +1338,7 @@ ): """apply the merge action list to the working directory + mresult is a mergeresult object representing result of the merge wctx is the working copy context mctx is the context to be merged into the working copy commitinfo is a mapping of information which needs to be stored somewhere @@ -1349,6 +1350,7 @@ batchget. """ + actions = mresult.actionsdict _prefetchfiles(repo, mctx, actions) updated, merged, removed = 0, 0, 0 @@ -1613,6 +1615,8 @@ mfiles = {a[0] for a in actions[mergestatemod.ACTION_MERGE]} for k, acts in pycompat.iteritems(extraactions): actions[k].extend(acts) + for a in acts: + mresult.addfile(a[0], k, *a[1:]) if k == mergestatemod.ACTION_GET and wantfiledata: # no filedata until mergestate is updated to provide it for a in acts: @@ -1638,6 +1642,9 @@ actions[mergestatemod.ACTION_MERGE] = [ a for a in actions[mergestatemod.ACTION_MERGE] if a[0] in mfiles ] + for a in mresult.getactions([mergestatemod.ACTION_MERGE]): + if a[0] not in mfiles: + mresult.removefile(a[0]) progress.complete() assert len(getfiledata) == ( @@ -2016,7 +2023,7 @@ wantfiledata = updatedirstate and not branchmerge stats, getfiledata = applyupdates( repo, - actions, + mresult, wc, p2, overwrite, @@ -2029,7 +2036,7 @@ with repo.dirstate.parentchange(): repo.setparents(fp1, fp2) mergestatemod.recordupdates( - repo, actions, branchmerge, getfiledata + repo, mresult.actionsdict, branchmerge, getfiledata ) # update completed, clear state util.unlink(repo.vfs.join(b'updatestate'))