Mercurial > hg
changeset 45346:3c783ff08d40
mergeresult: introduce filemap() which yields filename based mapping
We wanted to remove `actions` as this was leaking how we store things internally
and was direct access to one of the member. This introduces filemap() which
yields a map of `filename` -> `action, args, msg`.
`mergeresult.actions` has been deleted as it's no longer required.
Differential Revision: https://phab.mercurial-scm.org/D8888
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 05 Aug 2020 16:00:25 +0530 |
parents | e5b4061f32be |
children | 1aef38d973e8 |
files | hgext/convert/hg.py hgext/remotefilelog/__init__.py mercurial/merge.py mercurial/sparse.py |
diffstat | 4 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/hg.py Wed Aug 05 15:41:23 2020 +0530 +++ b/hgext/convert/hg.py Wed Aug 05 16:00:25 2020 +0530 @@ -229,7 +229,7 @@ followcopies=False, ) - for file, (action, info, msg) in pycompat.iteritems(mresult.actions): + for file, (action, info, msg) in mresult.filemap(): if source.targetfilebelongstosource(file): # If the file belongs to the source repo, ignore the p2 # since it will be covered by the existing fileset.
--- a/hgext/remotefilelog/__init__.py Wed Aug 05 15:41:23 2020 +0530 +++ b/hgext/remotefilelog/__init__.py Wed Aug 05 16:00:25 2020 +0530 @@ -497,7 +497,7 @@ if isenabled(repo): files = [] sparsematch = repo.maybesparsematch(mctx.rev()) - for f, (m, actionargs, msg) in pycompat.iteritems(mresult.actions): + for f, (m, actionargs, msg) in mresult.filemap(): if sparsematch and not sparsematch(f): continue if m in (
--- a/mercurial/merge.py Wed Aug 05 15:41:23 2020 +0530 +++ b/mercurial/merge.py Wed Aug 05 16:00:25 2020 +0530 @@ -541,7 +541,7 @@ } # We mutate the items in the dict during iteration, so iterate # over a copy. - for f, action in list(mresult.actions.items()): + for f, action in mresult.filemap(): if narrowmatch(f): pass elif not branchmerge: @@ -668,9 +668,13 @@ return sum(len(self._actionmapping[a]) for a in actions) - @property - def actions(self): - return self._filemapping + def filemap(self, sort=False): + if sorted: + for key, val in sorted(pycompat.iteritems(self._filemapping)): + yield key, val + else: + for key, val in pycompat.iteritems(self._filemapping): + yield key, val @property def diverge(self): @@ -1137,7 +1141,7 @@ ): renamedelete = mresult1.renamedelete - for f, a in sorted(pycompat.iteritems(mresult1.actions)): + for f, a in mresult1.filemap(sort=True): m, args, msg = a repo.ui.debug(b' %s: %s -> %s\n' % (f, msg, m)) if f in fbids:
--- a/mercurial/sparse.py Wed Aug 05 15:41:23 2020 +0530 +++ b/mercurial/sparse.py Wed Aug 05 16:00:25 2020 +0530 @@ -388,7 +388,7 @@ sparsematch = matcher(repo, [mctx.rev()]) temporaryfiles = [] - for file, action in pycompat.iteritems(mresult.actions): + for file, action in mresult.filemap(): type, args, msg = action files.add(file) if sparsematch(file):