Mercurial > hg
changeset 45290:d70c972cec74
sparse: pass mergeresult obj in sparse.filterupdatesactions() (API)
Not able to see much which can be improved in this function by passing in
mergeresult object but for API consistency and no function directly touching
actions dict, it sounds like a good idea.
Differential Revision: https://phab.mercurial-scm.org/D8828
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 24 Jul 2020 19:19:47 +0530 |
parents | 1d1f112da75c |
children | 26fa2eebc291 |
files | mercurial/merge.py mercurial/sparse.py |
diffstat | 2 files changed, 6 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Fri Jul 24 19:13:20 2020 +0530 +++ b/mercurial/merge.py Fri Jul 24 19:19:47 2020 +0530 @@ -1130,10 +1130,7 @@ fractions = _forgetremoved(wctx, mctx, branchmerge) mresult.updateactions(fractions) - prunedactions = sparse.filterupdatesactions( - repo, wctx, mctx, branchmerge, mresult.actions - ) - mresult.setactions(prunedactions) + sparse.filterupdatesactions(repo, wctx, mctx, branchmerge, mresult) _resolvetrivial(repo, wctx, mctx, ancestors[0], mresult) return mresult
--- a/mercurial/sparse.py Fri Jul 24 19:13:20 2020 +0530 +++ b/mercurial/sparse.py Fri Jul 24 19:19:47 2020 +0530 @@ -366,16 +366,16 @@ return result -def filterupdatesactions(repo, wctx, mctx, branchmerge, actions): +def filterupdatesactions(repo, wctx, mctx, branchmerge, mresult): """Filter updates to only lay out files that match the sparse rules.""" if not enabled: - return actions + return oldrevs = [pctx.rev() for pctx in wctx.parents()] oldsparsematch = matcher(repo, oldrevs) if oldsparsematch.always(): - return actions + return files = set() prunedactions = {} @@ -390,7 +390,7 @@ sparsematch = matcher(repo, [mctx.rev()]) temporaryfiles = [] - for file, action in pycompat.iteritems(actions): + for file, action in pycompat.iteritems(mresult.actions): type, args, msg = action files.add(file) if sparsematch(file): @@ -457,7 +457,7 @@ elif old and not new: prunedactions[file] = (b'r', [], b'') - return prunedactions + mresult.setactions(prunedactions) def refreshwdir(repo, origstatus, origsparsematch, force=False):