comparison mercurial/merge.py @ 45466:14b3dbfa4eeb

mergeresult: introduce dedicated tuple for no-op actions This will help us in adding more no-op actions in next patch while keeping the code cleaner.
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 14 Sep 2020 13:51:39 +0530
parents c1d6e930ac8a
children bb9888d32601
comparison
equal deleted inserted replaced
45465:9bd60ec60601 45466:14b3dbfa4eeb
521 521
522 Raise an exception if the merge cannot be completed because the repo is 522 Raise an exception if the merge cannot be completed because the repo is
523 narrowed. 523 narrowed.
524 """ 524 """
525 # TODO: handle with nonconflicttypes 525 # TODO: handle with nonconflicttypes
526 nooptypes = {mergestatemod.ACTION_KEEP}
527 nonconflicttypes = { 526 nonconflicttypes = {
528 mergestatemod.ACTION_ADD, 527 mergestatemod.ACTION_ADD,
529 mergestatemod.ACTION_ADD_MODIFIED, 528 mergestatemod.ACTION_ADD_MODIFIED,
530 mergestatemod.ACTION_CREATED, 529 mergestatemod.ACTION_CREATED,
531 mergestatemod.ACTION_CREATED_MERGE, 530 mergestatemod.ACTION_CREATED_MERGE,
539 for f, action in mresult.filemap(): 538 for f, action in mresult.filemap():
540 if narrowmatch(f): 539 if narrowmatch(f):
541 pass 540 pass
542 elif not branchmerge: 541 elif not branchmerge:
543 mresult.removefile(f) # just updating, ignore changes outside clone 542 mresult.removefile(f) # just updating, ignore changes outside clone
544 elif action[0] in nooptypes: 543 elif action[0] in mergeresult.NO_OP_ACTIONS:
545 mresult.removefile(f) # merge does not affect file 544 mresult.removefile(f) # merge does not affect file
546 elif action[0] in nonconflicttypes: 545 elif action[0] in nonconflicttypes:
547 raise error.Abort( 546 raise error.Abort(
548 _( 547 _(
549 b'merge affects file \'%s\' outside narrow, ' 548 b'merge affects file \'%s\' outside narrow, '
561 class mergeresult(object): 560 class mergeresult(object):
562 ''''An object representing result of merging manifests. 561 ''''An object representing result of merging manifests.
563 562
564 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
565 mapping of divergent renames and other such cases. ''' 564 mapping of divergent renames and other such cases. '''
565
566 NO_OP_ACTIONS = (mergestatemod.ACTION_KEEP,)
566 567
567 def __init__(self): 568 def __init__(self):
568 """ 569 """
569 filemapping: dict of filename as keys and action related info as values 570 filemapping: dict of filename as keys and action related info as values
570 diverge: mapping of source name -> list of dest name for 571 diverge: mapping of source name -> list of dest name for
709 for a in self._actionmapping.keys(): 710 for a in self._actionmapping.keys():
710 if ( 711 if (
711 a 712 a
712 not in ( 713 not in (
713 mergestatemod.ACTION_GET, 714 mergestatemod.ACTION_GET,
714 mergestatemod.ACTION_KEEP,
715 mergestatemod.ACTION_EXEC, 715 mergestatemod.ACTION_EXEC,
716 mergestatemod.ACTION_REMOVE, 716 mergestatemod.ACTION_REMOVE,
717 mergestatemod.ACTION_PATH_CONFLICT_RESOLVE, 717 mergestatemod.ACTION_PATH_CONFLICT_RESOLVE,
718 ) 718 )
719 and self._actionmapping[a] 719 and self._actionmapping[a]
720 and a not in self.NO_OP_ACTIONS
720 ): 721 ):
721 return True 722 return True
722 723
723 return False 724 return False
724 725
1418 if wctx[f].lexists(): 1419 if wctx[f].lexists():
1419 repo.ui.debug(b"removing %s\n" % f) 1420 repo.ui.debug(b"removing %s\n" % f)
1420 wctx[f].audit() 1421 wctx[f].audit()
1421 wctx[f].remove() 1422 wctx[f].remove()
1422 1423
1423 numupdates = mresult.len() - mresult.len((mergestatemod.ACTION_KEEP,)) 1424 numupdates = mresult.len() - mresult.len(mergeresult.NO_OP_ACTIONS)
1424 progress = repo.ui.makeprogress( 1425 progress = repo.ui.makeprogress(
1425 _(b'updating'), unit=_(b'files'), total=numupdates 1426 _(b'updating'), unit=_(b'files'), total=numupdates
1426 ) 1427 )
1427 1428
1428 if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_REMOVE]: 1429 if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_REMOVE]: