comparison mercurial/merge.py @ 45341:e335936cd4e1

applyupdates: simplfy calculation of number of updated files Instead of increasing the `updated` variable each time in a loop, let's use the mergeresult object API to calculate the updated value in one call. Differential Revision: https://phab.mercurial-scm.org/D8883
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 05 Aug 2020 13:21:06 +0530
parents cdc50e1929b0
children 150900a17ec2
comparison
equal deleted inserted replaced
45340:cdc50e1929b0 45341:e335936cd4e1
1498 if final: 1498 if final:
1499 getfiledata = res 1499 getfiledata = res
1500 else: 1500 else:
1501 i, item = res 1501 i, item = res
1502 progress.increment(step=i, item=item) 1502 progress.increment(step=i, item=item)
1503 updated = mresult.len((mergestatemod.ACTION_GET,))
1504 1503
1505 if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_GET]: 1504 if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_GET]:
1506 subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels) 1505 subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels)
1507 1506
1508 # forget (manifest only, just log it) (must come first) 1507 # forget (manifest only, just log it) (must come first)
1542 f0, flags = args 1541 f0, flags = args
1543 repo.ui.note(_(b"moving %s to %s\n") % (f0, f)) 1542 repo.ui.note(_(b"moving %s to %s\n") % (f0, f))
1544 wctx[f].audit() 1543 wctx[f].audit()
1545 wctx[f].write(wctx.filectx(f0).data(), flags) 1544 wctx[f].write(wctx.filectx(f0).data(), flags)
1546 wctx[f0].remove() 1545 wctx[f0].remove()
1547 updated += 1
1548 1546
1549 # local directory rename, get 1547 # local directory rename, get
1550 for f, args, msg in mresult.getactions( 1548 for f, args, msg in mresult.getactions(
1551 (mergestatemod.ACTION_LOCAL_DIR_RENAME_GET,), sort=True 1549 (mergestatemod.ACTION_LOCAL_DIR_RENAME_GET,), sort=True
1552 ): 1550 ):
1553 repo.ui.debug(b" %s: %s -> dg\n" % (f, msg)) 1551 repo.ui.debug(b" %s: %s -> dg\n" % (f, msg))
1554 progress.increment(item=f) 1552 progress.increment(item=f)
1555 f0, flags = args 1553 f0, flags = args
1556 repo.ui.note(_(b"getting %s to %s\n") % (f0, f)) 1554 repo.ui.note(_(b"getting %s to %s\n") % (f0, f))
1557 wctx[f].write(mctx.filectx(f0).data(), flags) 1555 wctx[f].write(mctx.filectx(f0).data(), flags)
1558 updated += 1
1559 1556
1560 # exec 1557 # exec
1561 for f, args, msg in mresult.getactions( 1558 for f, args, msg in mresult.getactions(
1562 (mergestatemod.ACTION_EXEC,), sort=True 1559 (mergestatemod.ACTION_EXEC,), sort=True
1563 ): 1560 ):
1564 repo.ui.debug(b" %s: %s -> e\n" % (f, msg)) 1561 repo.ui.debug(b" %s: %s -> e\n" % (f, msg))
1565 progress.increment(item=f) 1562 progress.increment(item=f)
1566 (flags,) = args 1563 (flags,) = args
1567 wctx[f].audit() 1564 wctx[f].audit()
1568 wctx[f].setflags(b'l' in flags, b'x' in flags) 1565 wctx[f].setflags(b'l' in flags, b'x' in flags)
1569 updated += 1 1566
1570 1567 # these actions updates the file
1568 updated = mresult.len(
1569 (
1570 mergestatemod.ACTION_GET,
1571 mergestatemod.ACTION_EXEC,
1572 mergestatemod.ACTION_LOCAL_DIR_RENAME_GET,
1573 mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL,
1574 )
1575 )
1571 # the ordering is important here -- ms.mergedriver will raise if the merge 1576 # the ordering is important here -- ms.mergedriver will raise if the merge
1572 # driver has changed, and we want to be able to bypass it when overwrite is 1577 # driver has changed, and we want to be able to bypass it when overwrite is
1573 # True 1578 # True
1574 usemergedriver = not overwrite and mergeactions and ms.mergedriver 1579 usemergedriver = not overwrite and mergeactions and ms.mergedriver
1575 1580