comparison mercurial/merge.py @ 45525:590a840fa367

mergestate: define NO_OP_ACTION in module scope instead of inside mergeresult This makes sure it isn't intended to be overridden by subclasses. Thanks to Yuya for the nice suggestion. Differential Revision: https://phab.mercurial-scm.org/D9025
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 16 Sep 2020 18:09:32 +0530
parents 6877b0ee5f9d
children 2b339c6c6e99
comparison
equal deleted inserted replaced
45524:6877b0ee5f9d 45525:590a840fa367
524 for f, action in mresult.filemap(): 524 for f, action in mresult.filemap():
525 if narrowmatch(f): 525 if narrowmatch(f):
526 pass 526 pass
527 elif not branchmerge: 527 elif not branchmerge:
528 mresult.removefile(f) # just updating, ignore changes outside clone 528 mresult.removefile(f) # just updating, ignore changes outside clone
529 elif action[0] in mergeresult.NO_OP_ACTIONS: 529 elif action[0] in mergestatemod.NO_OP_ACTIONS:
530 mresult.removefile(f) # merge does not affect file 530 mresult.removefile(f) # merge does not affect file
531 elif action[0] in nonconflicttypes: 531 elif action[0] in nonconflicttypes:
532 raise error.Abort( 532 raise error.Abort(
533 _( 533 _(
534 b'merge affects file \'%s\' outside narrow, ' 534 b'merge affects file \'%s\' outside narrow, '
546 class mergeresult(object): 546 class mergeresult(object):
547 ''''An object representing result of merging manifests. 547 ''''An object representing result of merging manifests.
548 548
549 It has information about what actions need to be performed on dirstate 549 It has information about what actions need to be performed on dirstate
550 mapping of divergent renames and other such cases. ''' 550 mapping of divergent renames and other such cases. '''
551
552 NO_OP_ACTIONS = (
553 mergestatemod.ACTION_KEEP,
554 mergestatemod.ACTION_KEEP_ABSENT,
555 mergestatemod.ACTION_KEEP_NEW,
556 )
557 551
558 def __init__(self): 552 def __init__(self):
559 """ 553 """
560 filemapping: dict of filename as keys and action related info as values 554 filemapping: dict of filename as keys and action related info as values
561 diverge: mapping of source name -> list of dest name for 555 diverge: mapping of source name -> list of dest name for
705 mergestatemod.ACTION_EXEC, 699 mergestatemod.ACTION_EXEC,
706 mergestatemod.ACTION_REMOVE, 700 mergestatemod.ACTION_REMOVE,
707 mergestatemod.ACTION_PATH_CONFLICT_RESOLVE, 701 mergestatemod.ACTION_PATH_CONFLICT_RESOLVE,
708 ) 702 )
709 and self._actionmapping[a] 703 and self._actionmapping[a]
710 and a not in self.NO_OP_ACTIONS 704 and a not in mergestatemod.NO_OP_ACTIONS
711 ): 705 ):
712 return True 706 return True
713 707
714 return False 708 return False
715 709
1396 for f, op in pycompat.iteritems(mresult.commitinfo): 1390 for f, op in pycompat.iteritems(mresult.commitinfo):
1397 # the other side of filenode was choosen while merging, store this in 1391 # the other side of filenode was choosen while merging, store this in
1398 # mergestate so that it can be reused on commit 1392 # mergestate so that it can be reused on commit
1399 ms.addcommitinfo(f, op) 1393 ms.addcommitinfo(f, op)
1400 1394
1401 numupdates = mresult.len() - mresult.len(mergeresult.NO_OP_ACTIONS) 1395 numupdates = mresult.len() - mresult.len(mergestatemod.NO_OP_ACTIONS)
1402 progress = repo.ui.makeprogress( 1396 progress = repo.ui.makeprogress(
1403 _(b'updating'), unit=_(b'files'), total=numupdates 1397 _(b'updating'), unit=_(b'files'), total=numupdates
1404 ) 1398 )
1405 1399
1406 if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_REMOVE]: 1400 if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_REMOVE]:
1500 ): 1494 ):
1501 repo.ui.debug(b" %s: %s -> am\n" % (f, msg)) 1495 repo.ui.debug(b" %s: %s -> am\n" % (f, msg))
1502 progress.increment(item=f) 1496 progress.increment(item=f)
1503 1497
1504 # keep (noop, just log it) 1498 # keep (noop, just log it)
1505 for a in mergeresult.NO_OP_ACTIONS: 1499 for a in mergestatemod.NO_OP_ACTIONS:
1506 for f, args, msg in mresult.getactions((a,), sort=True): 1500 for f, args, msg in mresult.getactions((a,), sort=True):
1507 repo.ui.debug(b" %s: %s -> %s\n" % (f, msg, a)) 1501 repo.ui.debug(b" %s: %s -> %s\n" % (f, msg, a))
1508 # no progress 1502 # no progress
1509 1503
1510 # directory rename, move local 1504 # directory rename, move local