Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 45342: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 |
comparison
equal
deleted
inserted
replaced
45341:e335936cd4e1 | 45342:150900a17ec2 |
---|---|
412 createdfiledirs = set() | 412 createdfiledirs = set() |
413 | 413 |
414 # The set of files deleted by all the actions. | 414 # The set of files deleted by all the actions. |
415 deletedfiles = set() | 415 deletedfiles = set() |
416 | 416 |
417 for f, (m, args, msg) in mresult.actions.items(): | 417 for (f, args, msg) in mresult.getactions( |
418 if m in ( | 418 ( |
419 mergestatemod.ACTION_CREATED, | 419 mergestatemod.ACTION_CREATED, |
420 mergestatemod.ACTION_DELETED_CHANGED, | 420 mergestatemod.ACTION_DELETED_CHANGED, |
421 mergestatemod.ACTION_MERGE, | 421 mergestatemod.ACTION_MERGE, |
422 mergestatemod.ACTION_CREATED_MERGE, | 422 mergestatemod.ACTION_CREATED_MERGE, |
423 ): | 423 ) |
424 # This action may create a new local file. | 424 ): |
425 createdfiledirs.update(pathutil.finddirs(f)) | 425 # This action may create a new local file. |
426 if mf.hasdir(f): | 426 createdfiledirs.update(pathutil.finddirs(f)) |
427 # The file aliases a local directory. This might be ok if all | 427 if mf.hasdir(f): |
428 # the files in the local directory are being deleted. This | 428 # The file aliases a local directory. This might be ok if all |
429 # will be checked once we know what all the deleted files are. | 429 # the files in the local directory are being deleted. This |
430 remoteconflicts.add(f) | 430 # will be checked once we know what all the deleted files are. |
431 # Track the names of all deleted files. | 431 remoteconflicts.add(f) |
432 if m == mergestatemod.ACTION_REMOVE: | 432 # Track the names of all deleted files. |
433 deletedfiles.add(f) | 433 for (f, args, msg) in mresult.getactions((mergestatemod.ACTION_REMOVE,)): |
434 if m == mergestatemod.ACTION_MERGE: | 434 deletedfiles.add(f) |
435 f1, f2, fa, move, anc = args | 435 for (f, args, msg) in mresult.getactions((mergestatemod.ACTION_MERGE,)): |
436 if move: | 436 f1, f2, fa, move, anc = args |
437 deletedfiles.add(f1) | 437 if move: |
438 if m == mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL: | 438 deletedfiles.add(f1) |
439 f2, flags = args | 439 for (f, args, msg) in mresult.getactions( |
440 deletedfiles.add(f2) | 440 (mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL,) |
441 ): | |
442 f2, flags = args | |
443 deletedfiles.add(f2) | |
441 | 444 |
442 # Check all directories that contain created files for path conflicts. | 445 # Check all directories that contain created files for path conflicts. |
443 for p in createdfiledirs: | 446 for p in createdfiledirs: |
444 if p in mf: | 447 if p in mf: |
445 if p in mctx: | 448 if p in mctx: |