Mercurial > public > mercurial-scm > hg
comparison mercurial/mergestate.py @ 48713:5dfaca4464d1
merge-actions: add an explicite "no_op" attribute
This make the MergeAction smarter and able to describe themself. This is useful
to help introducing more MergeAction object that better the complexity of the
situation.
Differential Revision: https://phab.mercurial-scm.org/D12116
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 28 Jan 2022 15:19:58 +0100 |
parents | 773ad0f5152d |
children | c5f05c0d1c8c |
comparison
equal
deleted
inserted
replaced
48712:773ad0f5152d | 48713:5dfaca4464d1 |
---|---|
103 """represent an "action" merge need to take for a given file | 103 """represent an "action" merge need to take for a given file |
104 | 104 |
105 Attributes: | 105 Attributes: |
106 | 106 |
107 _short: internal representation used to identify each action | 107 _short: internal representation used to identify each action |
108 | |
109 no_op: True if the action does affect the file content or tracking status | |
108 """ | 110 """ |
109 | 111 |
110 ALL_ACTIONS = weakref.WeakSet() | 112 ALL_ACTIONS = weakref.WeakSet() |
111 | 113 NO_OP_ACTIONS = weakref.WeakSet() |
112 def __init__(self, short): | 114 |
115 def __init__(self, short, no_op=False): | |
113 self._short = short | 116 self._short = short |
114 self.ALL_ACTIONS.add(self) | 117 self.ALL_ACTIONS.add(self) |
118 self.no_op = no_op | |
119 if self.no_op: | |
120 self.NO_OP_ACTIONS.add(self) | |
115 | 121 |
116 def __hash__(self): | 122 def __hash__(self): |
117 return hash(self._short) | 123 return hash(self._short) |
118 | 124 |
119 def __repr__(self): | 125 def __repr__(self): |
143 ACTION_DELETED_CHANGED = MergeAction(b'dc') | 149 ACTION_DELETED_CHANGED = MergeAction(b'dc') |
144 ACTION_CHANGED_DELETED = MergeAction(b'cd') | 150 ACTION_CHANGED_DELETED = MergeAction(b'cd') |
145 ACTION_MERGE = MergeAction(b'm') | 151 ACTION_MERGE = MergeAction(b'm') |
146 ACTION_LOCAL_DIR_RENAME_GET = MergeAction(b'dg') | 152 ACTION_LOCAL_DIR_RENAME_GET = MergeAction(b'dg') |
147 ACTION_DIR_RENAME_MOVE_LOCAL = MergeAction(b'dm') | 153 ACTION_DIR_RENAME_MOVE_LOCAL = MergeAction(b'dm') |
148 ACTION_KEEP = MergeAction(b'k') | 154 ACTION_KEEP = MergeAction(b'k', no_op=True) |
149 # the file was absent on local side before merge and we should | 155 # the file was absent on local side before merge and we should |
150 # keep it absent (absent means file not present, it can be a result | 156 # keep it absent (absent means file not present, it can be a result |
151 # of file deletion, rename etc.) | 157 # of file deletion, rename etc.) |
152 ACTION_KEEP_ABSENT = MergeAction(b'ka') | 158 ACTION_KEEP_ABSENT = MergeAction(b'ka', no_op=True) |
153 # the file is absent on the ancestor and remote side of the merge | 159 # the file is absent on the ancestor and remote side of the merge |
154 # hence this file is new and we should keep it | 160 # hence this file is new and we should keep it |
155 ACTION_KEEP_NEW = MergeAction(b'kn') | 161 ACTION_KEEP_NEW = MergeAction(b'kn', no_op=True) |
156 ACTION_EXEC = MergeAction(b'e') | 162 ACTION_EXEC = MergeAction(b'e') |
157 ACTION_CREATED_MERGE = MergeAction(b'cm') | 163 ACTION_CREATED_MERGE = MergeAction(b'cm') |
158 | 164 |
159 # actions which are no op | |
160 NO_OP_ACTIONS = ( | |
161 ACTION_KEEP, | |
162 ACTION_KEEP_ABSENT, | |
163 ACTION_KEEP_NEW, | |
164 ) | |
165 | 165 |
166 # Used by concert to detect situation it does not like, not sure what the exact | 166 # Used by concert to detect situation it does not like, not sure what the exact |
167 # criteria is | 167 # criteria is |
168 CONVERT_MERGE_ACTIONS = ( | 168 CONVERT_MERGE_ACTIONS = ( |
169 ACTION_MERGE, | 169 ACTION_MERGE, |