Mercurial > hg-stable
changeset 45363:150900a17ec2
merge: rework iteration over mergeresult object in checkpathconflicts()
Instead of following pattern:
```
for f, (m, args, msg) in mresult.actions.items():
if m == mergestatemod.ACTION_*:
...
elif m == mergestatemod.ACTION_*:
...
....
```
We do:
```
for (f, args, msg) in mresult.getaction((mergestatemod.ACTION_*,)):
...
for (f, args, msg) in mresult.getaction((mergestatemod.ACTION_*,)):
...
....
```
This makes code bit easier to understand and prevent iterating over actions
which we don't need.
Differential Revision: https://phab.mercurial-scm.org/D8884
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 05 Aug 2020 13:50:49 +0530 |
parents | e335936cd4e1 |
children | e3826f1dab60 |
files | mercurial/merge.py |
diffstat | 1 files changed, 23 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Wed Aug 05 13:21:06 2020 +0530 +++ b/mercurial/merge.py Wed Aug 05 13:50:49 2020 +0530 @@ -414,30 +414,33 @@ # The set of files deleted by all the actions. deletedfiles = set() - for f, (m, args, msg) in mresult.actions.items(): - if m in ( + for (f, args, msg) in mresult.getactions( + ( mergestatemod.ACTION_CREATED, mergestatemod.ACTION_DELETED_CHANGED, mergestatemod.ACTION_MERGE, mergestatemod.ACTION_CREATED_MERGE, - ): - # This action may create a new local file. - createdfiledirs.update(pathutil.finddirs(f)) - if mf.hasdir(f): - # The file aliases a local directory. This might be ok if all - # the files in the local directory are being deleted. This - # will be checked once we know what all the deleted files are. - remoteconflicts.add(f) - # Track the names of all deleted files. - if m == mergestatemod.ACTION_REMOVE: - deletedfiles.add(f) - if m == mergestatemod.ACTION_MERGE: - f1, f2, fa, move, anc = args - if move: - deletedfiles.add(f1) - if m == mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL: - f2, flags = args - deletedfiles.add(f2) + ) + ): + # This action may create a new local file. + createdfiledirs.update(pathutil.finddirs(f)) + if mf.hasdir(f): + # The file aliases a local directory. This might be ok if all + # the files in the local directory are being deleted. This + # will be checked once we know what all the deleted files are. + remoteconflicts.add(f) + # Track the names of all deleted files. + for (f, args, msg) in mresult.getactions((mergestatemod.ACTION_REMOVE,)): + deletedfiles.add(f) + for (f, args, msg) in mresult.getactions((mergestatemod.ACTION_MERGE,)): + f1, f2, fa, move, anc = args + if move: + deletedfiles.add(f1) + for (f, args, msg) in mresult.getactions( + (mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL,) + ): + f2, flags = args + deletedfiles.add(f2) # Check all directories that contain created files for path conflicts. for p in createdfiledirs: