comparison mercurial/merge.py @ 45347:1aef38d973e8

merge: pass mergeresult obj in _forgetremoved() (API) Instead of returning a dict of actions and then updating it, let's pass the object directly and update it there. This makes `updateactions()` on mergeresult unused and this patch removes that. After this patch, we have couple of methods left on mergeresult class which still exposes the internal dict based action storage. Differential Revision: https://phab.mercurial-scm.org/D8889
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 05 Aug 2020 16:52:51 +0530
parents 3c783ff08d40
children 490607efc992
comparison
equal deleted inserted replaced
45346:3c783ff08d40 45347:1aef38d973e8
253 ) 253 )
254 (flags,) = args 254 (flags,) = args
255 mresult.addfile(f, mergestatemod.ACTION_GET, (flags, backup), msg) 255 mresult.addfile(f, mergestatemod.ACTION_GET, (flags, backup), msg)
256 256
257 257
258 def _forgetremoved(wctx, mctx, branchmerge): 258 def _forgetremoved(wctx, mctx, branchmerge, mresult):
259 """ 259 """
260 Forget removed files 260 Forget removed files
261 261
262 If we're jumping between revisions (as opposed to merging), and if 262 If we're jumping between revisions (as opposed to merging), and if
263 neither the working directory nor the target rev has the file, 263 neither the working directory nor the target rev has the file,
268 If we're merging, and the other revision has removed a file 268 If we're merging, and the other revision has removed a file
269 that is not present in the working directory, we need to mark it 269 that is not present in the working directory, we need to mark it
270 as removed. 270 as removed.
271 """ 271 """
272 272
273 actions = {}
274 m = mergestatemod.ACTION_FORGET 273 m = mergestatemod.ACTION_FORGET
275 if branchmerge: 274 if branchmerge:
276 m = mergestatemod.ACTION_REMOVE 275 m = mergestatemod.ACTION_REMOVE
277 for f in wctx.deleted(): 276 for f in wctx.deleted():
278 if f not in mctx: 277 if f not in mctx:
279 actions[f] = m, None, b"forget deleted" 278 mresult.addfile(f, m, None, b"forget deleted")
280 279
281 if not branchmerge: 280 if not branchmerge:
282 for f in wctx.removed(): 281 for f in wctx.removed():
283 if f not in mctx: 282 if f not in mctx:
284 actions[f] = ( 283 mresult.addfile(
285 mergestatemod.ACTION_FORGET, 284 f, mergestatemod.ACTION_FORGET, None, b"forget removed",
286 None,
287 b"forget removed",
288 ) 285 )
289
290 return actions
291 286
292 287
293 def _checkcollision(repo, wmf, mresult): 288 def _checkcollision(repo, wmf, mresult):
294 """ 289 """
295 Check for case-folding collisions. 290 Check for case-folding collisions.
701 def setactions(self, actions): 696 def setactions(self, actions):
702 self._filemapping = actions 697 self._filemapping = actions
703 self._actionmapping = collections.defaultdict(dict) 698 self._actionmapping = collections.defaultdict(dict)
704 for f, (act, data, msg) in pycompat.iteritems(self._filemapping): 699 for f, (act, data, msg) in pycompat.iteritems(self._filemapping):
705 self._actionmapping[act][f] = data, msg 700 self._actionmapping[act][f] = data, msg
706
707 def updateactions(self, updates):
708 for f, (a, data, msg) in pycompat.iteritems(updates):
709 self.addfile(f, a, data, msg)
710 701
711 def hasconflicts(self): 702 def hasconflicts(self):
712 """ tells whether this merge resulted in some actions which can 703 """ tells whether this merge resulted in some actions which can
713 result in conflicts or not """ 704 result in conflicts or not """
714 for a in self._actionmapping.keys(): 705 for a in self._actionmapping.keys():
1194 repo.ui.note(_(b'end of auction\n\n')) 1185 repo.ui.note(_(b'end of auction\n\n'))
1195 # TODO: think about commitinfo when bid merge is used 1186 # TODO: think about commitinfo when bid merge is used
1196 mresult.updatevalues(diverge, renamedelete, {}) 1187 mresult.updatevalues(diverge, renamedelete, {})
1197 1188
1198 if wctx.rev() is None: 1189 if wctx.rev() is None:
1199 fractions = _forgetremoved(wctx, mctx, branchmerge) 1190 _forgetremoved(wctx, mctx, branchmerge, mresult)
1200 mresult.updateactions(fractions)
1201 1191
1202 sparse.filterupdatesactions(repo, wctx, mctx, branchmerge, mresult) 1192 sparse.filterupdatesactions(repo, wctx, mctx, branchmerge, mresult)
1203 _resolvetrivial(repo, wctx, mctx, ancestors[0], mresult) 1193 _resolvetrivial(repo, wctx, mctx, ancestors[0], mresult)
1204 1194
1205 return mresult 1195 return mresult