Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
41041:3913223417ea | 41042:54c3b4bd01f2 |
---|---|
1539 | 1539 |
1540 def isempty(self): | 1540 def isempty(self): |
1541 return (not self.updatedcount and not self.mergedcount | 1541 return (not self.updatedcount and not self.mergedcount |
1542 and not self.removedcount and not self.unresolvedcount) | 1542 and not self.removedcount and not self.unresolvedcount) |
1543 | 1543 |
1544 def emptyactions(): | |
1545 """create an actions dict, to be populated and passed to applyupdates()""" | |
1546 return dict((m, []) | |
1547 for m in ( | |
1548 ACTION_ADD, | |
1549 ACTION_ADD_MODIFIED, | |
1550 ACTION_FORGET, | |
1551 ACTION_GET, | |
1552 ACTION_CHANGED_DELETED, | |
1553 ACTION_DELETED_CHANGED, | |
1554 ACTION_REMOVE, | |
1555 ACTION_DIR_RENAME_MOVE_LOCAL, | |
1556 ACTION_LOCAL_DIR_RENAME_GET, | |
1557 ACTION_MERGE, | |
1558 ACTION_EXEC, | |
1559 ACTION_KEEP, | |
1560 ACTION_PATH_CONFLICT, | |
1561 ACTION_PATH_CONFLICT_RESOLVE)) | |
1562 | |
1544 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None): | 1563 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None): |
1545 """apply the merge action list to the working directory | 1564 """apply the merge action list to the working directory |
1546 | 1565 |
1547 wctx is the working copy context | 1566 wctx is the working copy context |
1548 mctx is the context to be merged into the working copy | 1567 mctx is the context to be merged into the working copy |
2088 'prompt recreating') | 2107 'prompt recreating') |
2089 else: | 2108 else: |
2090 del actionbyfile[f] | 2109 del actionbyfile[f] |
2091 | 2110 |
2092 # Convert to dictionary-of-lists format | 2111 # Convert to dictionary-of-lists format |
2093 actions = dict((m, []) | 2112 actions = emptyactions() |
2094 for m in ( | |
2095 ACTION_ADD, | |
2096 ACTION_ADD_MODIFIED, | |
2097 ACTION_FORGET, | |
2098 ACTION_GET, | |
2099 ACTION_CHANGED_DELETED, | |
2100 ACTION_DELETED_CHANGED, | |
2101 ACTION_REMOVE, | |
2102 ACTION_DIR_RENAME_MOVE_LOCAL, | |
2103 ACTION_LOCAL_DIR_RENAME_GET, | |
2104 ACTION_MERGE, | |
2105 ACTION_EXEC, | |
2106 ACTION_KEEP, | |
2107 ACTION_PATH_CONFLICT, | |
2108 ACTION_PATH_CONFLICT_RESOLVE)) | |
2109 for f, (m, args, msg) in actionbyfile.iteritems(): | 2113 for f, (m, args, msg) in actionbyfile.iteritems(): |
2110 if m not in actions: | 2114 if m not in actions: |
2111 actions[m] = [] | 2115 actions[m] = [] |
2112 actions[m].append((f, args, msg)) | 2116 actions[m].append((f, args, msg)) |
2113 | 2117 |