Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 45478:bb9888d32601
merge: add `ACTION_KEEP_ABSENT` to represent files we want to keep absent
There are files which were deleted/not present in working copy parent but were
present on other side of merge. On merge, we might decide to keep them deleted.
We want to track such cases more closely, rather all kind of cases which results
from some kind of merging logic.
We do have `ACTION_KEEP` but having a dedicated action for the absent case is
more cleaner.
Initially I named the action as `ACTION_KEEP_DELETED` but later realized that
file can be not-present because of other reasons than deletion like rename,
hence decided to use more generic name `ACTION_KEEP_ABSENT`.
Differential Revision: https://phab.mercurial-scm.org/D8974
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 01 Sep 2020 17:08:26 +0530 |
parents | 14b3dbfa4eeb |
children | 09edbff6ae8d |
comparison
equal
deleted
inserted
replaced
45477:14b3dbfa4eeb | 45478:bb9888d32601 |
---|---|
561 ''''An object representing result of merging manifests. | 561 ''''An object representing result of merging manifests. |
562 | 562 |
563 It has information about what actions need to be performed on dirstate | 563 It has information about what actions need to be performed on dirstate |
564 mapping of divergent renames and other such cases. ''' | 564 mapping of divergent renames and other such cases. ''' |
565 | 565 |
566 NO_OP_ACTIONS = (mergestatemod.ACTION_KEEP,) | 566 NO_OP_ACTIONS = ( |
567 mergestatemod.ACTION_KEEP, | |
568 mergestatemod.ACTION_KEEP_ABSENT, | |
569 ) | |
567 | 570 |
568 def __init__(self): | 571 def __init__(self): |
569 """ | 572 """ |
570 filemapping: dict of filename as keys and action related info as values | 573 filemapping: dict of filename as keys and action related info as values |
571 diverge: mapping of source name -> list of dest name for | 574 diverge: mapping of source name -> list of dest name for |
1173 continue | 1176 continue |
1174 # If keep is an option, just do it. | 1177 # If keep is an option, just do it. |
1175 if mergestatemod.ACTION_KEEP in bids: | 1178 if mergestatemod.ACTION_KEEP in bids: |
1176 repo.ui.note(_(b" %s: picking 'keep' action\n") % f) | 1179 repo.ui.note(_(b" %s: picking 'keep' action\n") % f) |
1177 mresult.addfile(f, *bids[mergestatemod.ACTION_KEEP][0]) | 1180 mresult.addfile(f, *bids[mergestatemod.ACTION_KEEP][0]) |
1181 continue | |
1182 # If keep absent is an option, just do that | |
1183 if mergestatemod.ACTION_KEEP_ABSENT in bids: | |
1184 repo.ui.note(_(b" %s: picking 'keep absent' action\n") % f) | |
1185 mresult.addfile(f, *bids[mergestatemod.ACTION_KEEP_ABSENT][0]) | |
1178 continue | 1186 continue |
1179 # If there are gets and they all agree [how could they not?], do it. | 1187 # If there are gets and they all agree [how could they not?], do it. |
1180 if mergestatemod.ACTION_GET in bids: | 1188 if mergestatemod.ACTION_GET in bids: |
1181 ga0 = bids[mergestatemod.ACTION_GET][0] | 1189 ga0 = bids[mergestatemod.ACTION_GET][0] |
1182 if all(a == ga0 for a in bids[mergestatemod.ACTION_GET][1:]): | 1190 if all(a == ga0 for a in bids[mergestatemod.ACTION_GET][1:]): |
1527 # keep (noop, just log it) | 1535 # keep (noop, just log it) |
1528 for f, args, msg in mresult.getactions( | 1536 for f, args, msg in mresult.getactions( |
1529 (mergestatemod.ACTION_KEEP,), sort=True | 1537 (mergestatemod.ACTION_KEEP,), sort=True |
1530 ): | 1538 ): |
1531 repo.ui.debug(b" %s: %s -> k\n" % (f, msg)) | 1539 repo.ui.debug(b" %s: %s -> k\n" % (f, msg)) |
1540 # no progress | |
1541 for f, args, msg in mresult.getactions( | |
1542 (mergestatemod.ACTION_KEEP_ABSENT,), sort=True | |
1543 ): | |
1544 repo.ui.debug(b" %s: %s -> ka\n" % (f, msg)) | |
1532 # no progress | 1545 # no progress |
1533 | 1546 |
1534 # directory rename, move local | 1547 # directory rename, move local |
1535 for f, args, msg in mresult.getactions( | 1548 for f, args, msg in mresult.getactions( |
1536 (mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL,), sort=True | 1549 (mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL,), sort=True |