Pulkit Goyal <7895pulkit@gmail.com> [Thu, 06 Aug 2020 13:51:43 +0530] rev 45349
merge: drop commitinfo argument to applyupdates (API)
We now pass the mergeresult object and hence there is no need to have a separate
commitinfo argument as the required info is present in mergeresult object.
Differential Revision: https://phab.mercurial-scm.org/D8904
Pulkit Goyal <7895pulkit@gmail.com> [Thu, 06 Aug 2020 13:27:38 +0530] rev 45348
merge: remove emptyactions() and use collections.defaultdict(list) instead
emptyactions() used to return a dict which was populated and passed into
applyupdates(). However, with recent changes, we no longer pass a plain dict,
instead we pass the mergeresult object.
There was only one usage of emptyactions and that too inside mergeresult object.
That usage is replaced with collections.defaultdict(list) instead.
Not sure why we were not using collections.defaultdict(list) from the beginning.
Differential Revision: https://phab.mercurial-scm.org/D8903
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 16:52:51 +0530] rev 45347
merge: pass mergeresult obj in _forgetremoved() (API)
Instead of returning a dict of actions and then updating it, let's pass the
object directly and update it there.
This makes `updateactions()` on mergeresult unused and this patch removes that.
After this patch, we have couple of methods left on mergeresult class which
still exposes the internal dict based action storage.
Differential Revision: https://phab.mercurial-scm.org/D8889
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 16:00:25 +0530] rev 45346
mergeresult: introduce filemap() which yields filename based mapping
We wanted to remove `actions` as this was leaking how we store things internally
and was direct access to one of the member. This introduces filemap() which
yields a map of `filename` -> `action, args, msg`.
`mergeresult.actions` has been deleted as it's no longer required.
Differential Revision: https://phab.mercurial-scm.org/D8888
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 15:41:23 +0530] rev 45345
mergeresult: add `files()` and use it
`files()` will return a list of files on which an action needs to be performed.
This is a step to stop exposing the underlying map to the user of this object.
Differential Revision: https://phab.mercurial-scm.org/D8887
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 15:37:26 +0530] rev 45344
mergeresult: introduce getfile() and use it where required
We want to hide the underlying dictionary from the users and provide API for
valid and sane use cases.
Differential Revision: https://phab.mercurial-scm.org/D8886
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 14:03:59 +0530] rev 45343
merge: use ACTION_* constants instead of values in _filternarrowactions()
It makes easier to check what noconflicttypes are and which are not included.
I hope we can have a state where we always use ACTION_* constants instead of
these values which are very hard to understand.
Differential Revision: https://phab.mercurial-scm.org/D8885
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 13:50:49 +0530] rev 45342
merge: rework iteration over mergeresult object in checkpathconflicts()
Instead of following pattern:
```
for f, (m, args, msg) in mresult.actions.items():
if m == mergestatemod.ACTION_*:
...
elif m == mergestatemod.ACTION_*:
...
....
```
We do:
```
for (f, args, msg) in mresult.getaction((mergestatemod.ACTION_*,)):
...
for (f, args, msg) in mresult.getaction((mergestatemod.ACTION_*,)):
...
....
```
This makes code bit easier to understand and prevent iterating over actions
which we don't need.
Differential Revision: https://phab.mercurial-scm.org/D8884
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 13:21:06 +0530] rev 45341
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
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 03 Aug 2020 18:08:37 +0530] rev 45340
mergeresult: yield from getactions() instead of buidling a list and returning
Only 7 out of 29 callers change the underlying dict while iterating. So it's
better to yield and wrap the 7 callers with `list()`.
Differential Revision: https://phab.mercurial-scm.org/D8882