Mercurial > hg
comparison mercurial/mergestate.py @ 48715:7d073df49a54
merge-actions: add some information about the "changes" the action do
This will be useful when processing merges action outside of the narrow-spec.
"support" outside of narrow file on commit
Differential Revision: https://phab.mercurial-scm.org/D12118
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 30 Jan 2022 06:01:42 +0100 |
parents | c5f05c0d1c8c |
children | d169e651066b |
comparison
equal
deleted
inserted
replaced
48714:c5f05c0d1c8c | 48715:7d073df49a54 |
---|---|
96 # This record was release in 3.7 and usage was removed in 5.6 | 96 # This record was release in 3.7 and usage was removed in 5.6 |
97 LEGACY_MERGE_DRIVER_STATE = b'm' | 97 LEGACY_MERGE_DRIVER_STATE = b'm' |
98 # This record was release in 3.7 and usage was removed in 5.6 | 98 # This record was release in 3.7 and usage was removed in 5.6 |
99 LEGACY_MERGE_DRIVER_MERGE = b'D' | 99 LEGACY_MERGE_DRIVER_MERGE = b'D' |
100 | 100 |
101 CHANGE_ADDED = b'added' | |
102 CHANGE_REMOVED = b'removed' | |
103 CHANGE_MODIFIED = b'modified' | |
104 | |
101 | 105 |
102 class MergeAction(object): | 106 class MergeAction(object): |
103 """represent an "action" merge need to take for a given file | 107 """represent an "action" merge need to take for a given file |
104 | 108 |
105 Attributes: | 109 Attributes: |
109 no_op: True if the action does affect the file content or tracking status | 113 no_op: True if the action does affect the file content or tracking status |
110 | 114 |
111 narrow_safe: | 115 narrow_safe: |
112 True if the action can be safely used for a file outside of the narrow | 116 True if the action can be safely used for a file outside of the narrow |
113 set | 117 set |
118 | |
119 changes: | |
120 The types of changes that this actions involves. This is a work in | |
121 progress and not all actions have one yet. In addition, some requires | |
122 user changes and cannot be fully decided. The value currently available | |
123 are: | |
124 | |
125 - ADDED: the files is new in both parents | |
126 - REMOVED: the files existed in one parent and is getting removed | |
127 - MODIFIED: the files existed in at least one parent and is getting changed | |
114 """ | 128 """ |
115 | 129 |
116 ALL_ACTIONS = weakref.WeakSet() | 130 ALL_ACTIONS = weakref.WeakSet() |
117 NO_OP_ACTIONS = weakref.WeakSet() | 131 NO_OP_ACTIONS = weakref.WeakSet() |
118 | 132 |
119 def __init__(self, short, no_op=False, narrow_safe=False): | 133 def __init__(self, short, no_op=False, narrow_safe=False, changes=None): |
120 self._short = short | 134 self._short = short |
121 self.ALL_ACTIONS.add(self) | 135 self.ALL_ACTIONS.add(self) |
122 self.no_op = no_op | 136 self.no_op = no_op |
123 if self.no_op: | 137 if self.no_op: |
124 self.NO_OP_ACTIONS.add(self) | 138 self.NO_OP_ACTIONS.add(self) |
125 self.narrow_safe = narrow_safe | 139 self.narrow_safe = narrow_safe |
140 self.changes = changes | |
126 | 141 |
127 def __hash__(self): | 142 def __hash__(self): |
128 return hash(self._short) | 143 return hash(self._short) |
129 | 144 |
130 def __repr__(self): | 145 def __repr__(self): |
141 | 156 |
142 def __lt__(self, other): | 157 def __lt__(self, other): |
143 return self._short < other._short | 158 return self._short < other._short |
144 | 159 |
145 | 160 |
146 ACTION_FORGET = MergeAction(b'f', narrow_safe=True) | 161 ACTION_FORGET = MergeAction(b'f', narrow_safe=True, changes=CHANGE_REMOVED) |
147 ACTION_REMOVE = MergeAction(b'r', narrow_safe=True) | 162 ACTION_REMOVE = MergeAction(b'r', narrow_safe=True, changes=CHANGE_REMOVED) |
148 ACTION_ADD = MergeAction(b'a', narrow_safe=True) | 163 ACTION_ADD = MergeAction(b'a', narrow_safe=True, changes=CHANGE_ADDED) |
149 ACTION_GET = MergeAction(b'g', narrow_safe=True) | 164 ACTION_GET = MergeAction(b'g', narrow_safe=True, changes=CHANGE_MODIFIED) |
150 ACTION_PATH_CONFLICT = MergeAction(b'p') | 165 ACTION_PATH_CONFLICT = MergeAction(b'p') |
151 ACTION_PATH_CONFLICT_RESOLVE = MergeAction('pr') | 166 ACTION_PATH_CONFLICT_RESOLVE = MergeAction('pr') |
152 ACTION_ADD_MODIFIED = MergeAction(b'am', narrow_safe=True) | 167 ACTION_ADD_MODIFIED = MergeAction( |
153 ACTION_CREATED = MergeAction(b'c', narrow_safe=True) | 168 b'am', narrow_safe=True, changes=CHANGE_ADDED |
169 ) # not 100% about the changes value here | |
170 ACTION_CREATED = MergeAction(b'c', narrow_safe=True, changes=CHANGE_ADDED) | |
154 ACTION_DELETED_CHANGED = MergeAction(b'dc') | 171 ACTION_DELETED_CHANGED = MergeAction(b'dc') |
155 ACTION_CHANGED_DELETED = MergeAction(b'cd') | 172 ACTION_CHANGED_DELETED = MergeAction(b'cd') |
156 ACTION_MERGE = MergeAction(b'm') | 173 ACTION_MERGE = MergeAction(b'm') |
157 ACTION_LOCAL_DIR_RENAME_GET = MergeAction(b'dg') | 174 ACTION_LOCAL_DIR_RENAME_GET = MergeAction(b'dg') |
158 ACTION_DIR_RENAME_MOVE_LOCAL = MergeAction(b'dm') | 175 ACTION_DIR_RENAME_MOVE_LOCAL = MergeAction(b'dm') |
162 # of file deletion, rename etc.) | 179 # of file deletion, rename etc.) |
163 ACTION_KEEP_ABSENT = MergeAction(b'ka', no_op=True) | 180 ACTION_KEEP_ABSENT = MergeAction(b'ka', no_op=True) |
164 # the file is absent on the ancestor and remote side of the merge | 181 # the file is absent on the ancestor and remote side of the merge |
165 # hence this file is new and we should keep it | 182 # hence this file is new and we should keep it |
166 ACTION_KEEP_NEW = MergeAction(b'kn', no_op=True) | 183 ACTION_KEEP_NEW = MergeAction(b'kn', no_op=True) |
167 ACTION_EXEC = MergeAction(b'e', narrow_safe=True) | 184 ACTION_EXEC = MergeAction(b'e', narrow_safe=True, changes=CHANGE_MODIFIED) |
168 ACTION_CREATED_MERGE = MergeAction(b'cm', narrow_safe=True) | 185 ACTION_CREATED_MERGE = MergeAction( |
186 b'cm', narrow_safe=True, changes=CHANGE_ADDED | |
187 ) | |
169 | 188 |
170 | 189 |
171 # Used by concert to detect situation it does not like, not sure what the exact | 190 # Used by concert to detect situation it does not like, not sure what the exact |
172 # criteria is | 191 # criteria is |
173 CONVERT_MERGE_ACTIONS = ( | 192 CONVERT_MERGE_ACTIONS = ( |