Mercurial > hg
comparison mercurial/merge.py @ 45348:490607efc992
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
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Thu, 06 Aug 2020 13:27:38 +0530 |
parents | 1aef38d973e8 |
children | 442823f66889 |
comparison
equal
deleted
inserted
replaced
45347:1aef38d973e8 | 45348:490607efc992 |
---|---|
685 | 685 |
686 @property | 686 @property |
687 def actionsdict(self): | 687 def actionsdict(self): |
688 """ returns a dictionary of actions to be perfomed with action as key | 688 """ returns a dictionary of actions to be perfomed with action as key |
689 and a list of files and related arguments as values """ | 689 and a list of files and related arguments as values """ |
690 res = emptyactions() | 690 res = collections.defaultdict(list) |
691 for a, d in pycompat.iteritems(self._actionmapping): | 691 for a, d in pycompat.iteritems(self._actionmapping): |
692 for f, (args, msg) in pycompat.iteritems(d): | 692 for f, (args, msg) in pycompat.iteritems(d): |
693 res[a].append((f, args, msg)) | 693 res[a].append((f, args, msg)) |
694 return res | 694 return res |
695 | 695 |
1334 self.updatedcount | 1334 self.updatedcount |
1335 or self.mergedcount | 1335 or self.mergedcount |
1336 or self.removedcount | 1336 or self.removedcount |
1337 or self.unresolvedcount | 1337 or self.unresolvedcount |
1338 ) | 1338 ) |
1339 | |
1340 | |
1341 def emptyactions(): | |
1342 """create an actions dict, to be populated and passed to applyupdates()""" | |
1343 return { | |
1344 m: [] | |
1345 for m in ( | |
1346 mergestatemod.ACTION_ADD, | |
1347 mergestatemod.ACTION_ADD_MODIFIED, | |
1348 mergestatemod.ACTION_FORGET, | |
1349 mergestatemod.ACTION_GET, | |
1350 mergestatemod.ACTION_CHANGED_DELETED, | |
1351 mergestatemod.ACTION_DELETED_CHANGED, | |
1352 mergestatemod.ACTION_REMOVE, | |
1353 mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL, | |
1354 mergestatemod.ACTION_LOCAL_DIR_RENAME_GET, | |
1355 mergestatemod.ACTION_MERGE, | |
1356 mergestatemod.ACTION_EXEC, | |
1357 mergestatemod.ACTION_KEEP, | |
1358 mergestatemod.ACTION_PATH_CONFLICT, | |
1359 mergestatemod.ACTION_PATH_CONFLICT_RESOLVE, | |
1360 ) | |
1361 } | |
1362 | 1339 |
1363 | 1340 |
1364 def applyupdates( | 1341 def applyupdates( |
1365 repo, | 1342 repo, |
1366 mresult, | 1343 mresult, |