Mercurial > public > mercurial-scm > hg-stable
diff mercurial/merge.py @ 41042:54c3b4bd01f2
merge: extract helper for creating empty "actions" dict
Replicating the set of actions in multiple places is bad.
Differential Revision: https://phab.mercurial-scm.org/D5472
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 21 Dec 2018 09:48:30 -0800 |
parents | 24e493ec2229 |
children | 6faaf3a1c6ec |
line wrap: on
line diff
--- a/mercurial/merge.py Mon Dec 03 22:22:23 2018 -0800 +++ b/mercurial/merge.py Fri Dec 21 09:48:30 2018 -0800 @@ -1541,6 +1541,25 @@ return (not self.updatedcount and not self.mergedcount and not self.removedcount and not self.unresolvedcount) +def emptyactions(): + """create an actions dict, to be populated and passed to applyupdates()""" + return dict((m, []) + for m in ( + ACTION_ADD, + ACTION_ADD_MODIFIED, + ACTION_FORGET, + ACTION_GET, + ACTION_CHANGED_DELETED, + ACTION_DELETED_CHANGED, + ACTION_REMOVE, + ACTION_DIR_RENAME_MOVE_LOCAL, + ACTION_LOCAL_DIR_RENAME_GET, + ACTION_MERGE, + ACTION_EXEC, + ACTION_KEEP, + ACTION_PATH_CONFLICT, + ACTION_PATH_CONFLICT_RESOLVE)) + def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None): """apply the merge action list to the working directory @@ -2090,22 +2109,7 @@ del actionbyfile[f] # Convert to dictionary-of-lists format - actions = dict((m, []) - for m in ( - ACTION_ADD, - ACTION_ADD_MODIFIED, - ACTION_FORGET, - ACTION_GET, - ACTION_CHANGED_DELETED, - ACTION_DELETED_CHANGED, - ACTION_REMOVE, - ACTION_DIR_RENAME_MOVE_LOCAL, - ACTION_LOCAL_DIR_RENAME_GET, - ACTION_MERGE, - ACTION_EXEC, - ACTION_KEEP, - ACTION_PATH_CONFLICT, - ACTION_PATH_CONFLICT_RESOLVE)) + actions = emptyactions() for f, (m, args, msg) in actionbyfile.iteritems(): if m not in actions: actions[m] = []