Mercurial > hg-stable
changeset 45362: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 |
files | mercurial/merge.py |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Mon Aug 03 18:08:37 2020 +0530 +++ b/mercurial/merge.py Wed Aug 05 13:21:06 2020 +0530 @@ -1500,7 +1500,6 @@ else: i, item = res progress.increment(step=i, item=item) - updated = mresult.len((mergestatemod.ACTION_GET,)) if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_GET]: subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels) @@ -1544,7 +1543,6 @@ wctx[f].audit() wctx[f].write(wctx.filectx(f0).data(), flags) wctx[f0].remove() - updated += 1 # local directory rename, get for f, args, msg in mresult.getactions( @@ -1555,7 +1553,6 @@ f0, flags = args repo.ui.note(_(b"getting %s to %s\n") % (f0, f)) wctx[f].write(mctx.filectx(f0).data(), flags) - updated += 1 # exec for f, args, msg in mresult.getactions( @@ -1566,8 +1563,16 @@ (flags,) = args wctx[f].audit() wctx[f].setflags(b'l' in flags, b'x' in flags) - updated += 1 + # these actions updates the file + updated = mresult.len( + ( + mergestatemod.ACTION_GET, + mergestatemod.ACTION_EXEC, + mergestatemod.ACTION_LOCAL_DIR_RENAME_GET, + mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL, + ) + ) # the ordering is important here -- ms.mergedriver will raise if the merge # driver has changed, and we want to be able to bypass it when overwrite is # True