Mercurial > hg
comparison mercurial/merge.py @ 45287:4ad6c4e9e35f
merge: pass mergeresult instead of actions in _checkunknownfiles() (API)
Differential Revision: https://phab.mercurial-scm.org/D8825
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 24 Jul 2020 17:57:23 +0530 |
parents | 00e9c5edcd58 |
children | 3f5ac87ae10f |
comparison
equal
deleted
inserted
replaced
45286:00e9c5edcd58 | 45287:4ad6c4e9e35f |
---|---|
124 if relf not in repo.dirstate: | 124 if relf not in repo.dirstate: |
125 return f | 125 return f |
126 return None | 126 return None |
127 | 127 |
128 | 128 |
129 def _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce): | 129 def _checkunknownfiles(repo, wctx, mctx, force, mresult, mergeforce): |
130 """ | 130 """ |
131 Considers any actions that care about the presence of conflicting unknown | 131 Considers any actions that care about the presence of conflicting unknown |
132 files. For some actions, the result is to abort; for others, it is to | 132 files. For some actions, the result is to abort; for others, it is to |
133 choose a different action. | 133 choose a different action. |
134 """ | 134 """ |
148 abortconflicts.update(conflicts) | 148 abortconflicts.update(conflicts) |
149 elif config == b'warn': | 149 elif config == b'warn': |
150 warnconflicts.update(conflicts) | 150 warnconflicts.update(conflicts) |
151 | 151 |
152 checkunknowndirs = _unknowndirschecker() | 152 checkunknowndirs = _unknowndirschecker() |
153 for f, (m, args, msg) in pycompat.iteritems(actions): | 153 for f, (m, args, msg) in pycompat.iteritems(mresult.actions): |
154 if m in ( | 154 if m in ( |
155 mergestatemod.ACTION_CREATED, | 155 mergestatemod.ACTION_CREATED, |
156 mergestatemod.ACTION_DELETED_CHANGED, | 156 mergestatemod.ACTION_DELETED_CHANGED, |
157 ): | 157 ): |
158 if _checkunknownfile(repo, wctx, mctx, f): | 158 if _checkunknownfile(repo, wctx, mctx, f): |
169 ignoredconflicts = {c for c in allconflicts if repo.dirstate._ignore(c)} | 169 ignoredconflicts = {c for c in allconflicts if repo.dirstate._ignore(c)} |
170 unknownconflicts = allconflicts - ignoredconflicts | 170 unknownconflicts = allconflicts - ignoredconflicts |
171 collectconflicts(ignoredconflicts, ignoredconfig) | 171 collectconflicts(ignoredconflicts, ignoredconfig) |
172 collectconflicts(unknownconflicts, unknownconfig) | 172 collectconflicts(unknownconflicts, unknownconfig) |
173 else: | 173 else: |
174 for f, (m, args, msg) in pycompat.iteritems(actions): | 174 for f, (m, args, msg) in pycompat.iteritems(mresult.actions): |
175 if m == mergestatemod.ACTION_CREATED_MERGE: | 175 if m == mergestatemod.ACTION_CREATED_MERGE: |
176 fl2, anc = args | 176 fl2, anc = args |
177 different = _checkunknownfile(repo, wctx, mctx, f) | 177 different = _checkunknownfile(repo, wctx, mctx, f) |
178 if repo.dirstate._ignore(f): | 178 if repo.dirstate._ignore(f): |
179 config = ignoredconfig | 179 config = ignoredconfig |
191 # (1) this is probably the wrong behavior here -- we should | 191 # (1) this is probably the wrong behavior here -- we should |
192 # probably abort, but some actions like rebases currently | 192 # probably abort, but some actions like rebases currently |
193 # don't like an abort happening in the middle of | 193 # don't like an abort happening in the middle of |
194 # merge.update. | 194 # merge.update. |
195 if not different: | 195 if not different: |
196 actions[f] = ( | 196 mresult.addfile( |
197 f, | |
197 mergestatemod.ACTION_GET, | 198 mergestatemod.ACTION_GET, |
198 (fl2, False), | 199 (fl2, False), |
199 b'remote created', | 200 b'remote created', |
200 ) | 201 ) |
201 elif mergeforce or config == b'abort': | 202 elif mergeforce or config == b'abort': |
202 actions[f] = ( | 203 mresult.addfile( |
204 f, | |
203 mergestatemod.ACTION_MERGE, | 205 mergestatemod.ACTION_MERGE, |
204 (f, f, None, False, anc), | 206 (f, f, None, False, anc), |
205 b'remote differs from untracked local', | 207 b'remote differs from untracked local', |
206 ) | 208 ) |
207 elif config == b'abort': | 209 elif config == b'abort': |
208 abortconflicts.add(f) | 210 abortconflicts.add(f) |
209 else: | 211 else: |
210 if config == b'warn': | 212 if config == b'warn': |
211 warnconflicts.add(f) | 213 warnconflicts.add(f) |
212 actions[f] = ( | 214 mresult.addfile( |
215 f, | |
213 mergestatemod.ACTION_GET, | 216 mergestatemod.ACTION_GET, |
214 (fl2, True), | 217 (fl2, True), |
215 b'remote created', | 218 b'remote created', |
216 ) | 219 ) |
217 | 220 |
236 if repo.wvfs.isfileorlink(f): | 239 if repo.wvfs.isfileorlink(f): |
237 repo.ui.warn(_(b"%s: replacing untracked file\n") % f) | 240 repo.ui.warn(_(b"%s: replacing untracked file\n") % f) |
238 else: | 241 else: |
239 repo.ui.warn(_(b"%s: replacing untracked files in directory\n") % f) | 242 repo.ui.warn(_(b"%s: replacing untracked files in directory\n") % f) |
240 | 243 |
241 for f, (m, args, msg) in pycompat.iteritems(actions): | 244 for f, (m, args, msg) in pycompat.iteritems(mresult.actions): |
242 if m == mergestatemod.ACTION_CREATED: | 245 if m == mergestatemod.ACTION_CREATED: |
243 backup = ( | 246 backup = ( |
244 f in fileconflicts | 247 f in fileconflicts |
245 or f in pathconflicts | 248 or f in pathconflicts |
246 or any(p in pathconflicts for p in pathutil.finddirs(f)) | 249 or any(p in pathconflicts for p in pathutil.finddirs(f)) |
247 ) | 250 ) |
248 (flags,) = args | 251 (flags,) = args |
249 actions[f] = (mergestatemod.ACTION_GET, (flags, backup), msg) | 252 mresult.addfile(f, mergestatemod.ACTION_GET, (flags, backup), msg) |
250 | 253 |
251 | 254 |
252 def _forgetremoved(wctx, mctx, branchmerge): | 255 def _forgetremoved(wctx, mctx, branchmerge): |
253 """ | 256 """ |
254 Forget removed files | 257 Forget removed files |
1020 force, | 1023 force, |
1021 matcher, | 1024 matcher, |
1022 acceptremote, | 1025 acceptremote, |
1023 followcopies, | 1026 followcopies, |
1024 ) | 1027 ) |
1025 _checkunknownfiles(repo, wctx, mctx, force, mresult.actions, mergeforce) | 1028 _checkunknownfiles(repo, wctx, mctx, force, mresult, mergeforce) |
1026 | 1029 |
1027 else: # only when merge.preferancestor=* - the default | 1030 else: # only when merge.preferancestor=* - the default |
1028 repo.ui.note( | 1031 repo.ui.note( |
1029 _(b"note: merging %s and %s using bids from ancestors %s\n") | 1032 _(b"note: merging %s and %s using bids from ancestors %s\n") |
1030 % ( | 1033 % ( |
1053 matcher, | 1056 matcher, |
1054 acceptremote, | 1057 acceptremote, |
1055 followcopies, | 1058 followcopies, |
1056 forcefulldiff=True, | 1059 forcefulldiff=True, |
1057 ) | 1060 ) |
1058 _checkunknownfiles( | 1061 _checkunknownfiles(repo, wctx, mctx, force, mresult1, mergeforce) |
1059 repo, wctx, mctx, force, mresult1.actions, mergeforce | |
1060 ) | |
1061 | 1062 |
1062 # Track the shortest set of warning on the theory that bid | 1063 # Track the shortest set of warning on the theory that bid |
1063 # merge will correctly incorporate more information | 1064 # merge will correctly incorporate more information |
1064 if diverge is None or len(mresult1.diverge) < len(diverge): | 1065 if diverge is None or len(mresult1.diverge) < len(diverge): |
1065 diverge = mresult1.diverge | 1066 diverge = mresult1.diverge |