[Updated] D8880: mergeresult: implement a len() function and use it
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Sat Aug 8 16:56:15 UTC 2020
Closed by commit rHG72b8c082676b: mergeresult: implement a len() function and use it (authored by pulkit).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8880?vs=22302&id=22338
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8880/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8880
AFFECTED FILES
mercurial/merge.py
CHANGE DETAILS
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -623,6 +623,17 @@
res.append((f, args, msg))
return res
+ def len(self, actions=None):
+ """ returns number of files which needs actions
+
+ if actions is passed, total of number of files in that action
+ only is returned """
+
+ if actions is None:
+ return len(self._filemapping)
+
+ return sum(len(self._actionmapping[a]) for a in actions)
+
@property
def actions(self):
return self._filemapping
@@ -1409,9 +1420,7 @@
wctx[f].audit()
wctx[f].remove()
- numupdates = len(mresult.actions) - len(
- mresult._actionmapping[mergestatemod.ACTION_KEEP]
- )
+ numupdates = mresult.len() - mresult.len((mergestatemod.ACTION_KEEP,))
progress = repo.ui.makeprogress(
_(b'updating'), unit=_(b'files'), total=numupdates
)
@@ -1454,7 +1463,7 @@
)
for i, item in prog:
progress.increment(step=i, item=item)
- removed = len(mresult._actionmapping[mergestatemod.ACTION_REMOVE])
+ removed = mresult.len((mergestatemod.ACTION_REMOVE,))
# resolve path conflicts (must come before getting)
for f, args, msg in mresult.getactions(
@@ -1489,7 +1498,7 @@
else:
i, item = res
progress.increment(step=i, item=item)
- updated = len(mresult._actionmapping[mergestatemod.ACTION_GET])
+ updated = mresult.len((mergestatemod.ACTION_GET,))
if b'.hgsubstate' in mresult._actionmapping[mergestatemod.ACTION_GET]:
subrepoutil.submerge(repo, wctx, mctx, wctx, overwrite, labels)
@@ -1664,9 +1673,7 @@
progress.complete()
assert len(getfiledata) == (
- len(mresult._actionmapping[mergestatemod.ACTION_GET])
- if wantfiledata
- else 0
+ mresult.len((mergestatemod.ACTION_GET,)) if wantfiledata else 0
)
return updateresult(updated, merged, removed, unresolved), getfiledata
@@ -2031,11 +2038,8 @@
# note that we're in the middle of an update
repo.vfs.write(b'updatestate', p2.hex())
- # Convert to dictionary-of-lists format
- actions = mresult.actionsdict
-
_advertisefsmonitor(
- repo, len(actions[mergestatemod.ACTION_GET]), p1.node()
+ repo, mresult.len((mergestatemod.ACTION_GET,)), p1.node()
)
wantfiledata = updatedirstate and not branchmerge
To: pulkit, #hg-reviewers, indygreg
Cc: indygreg, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200808/ddf328c9/attachment-0002.html>
More information about the Mercurial-patches
mailing list