comparison mercurial/merge.py @ 23640:b46b9865dd08

merge: let _forgetremoved() work on the file->action dict By moving the conversion from the file->action dict after _forgetremoved(), we make that method shorter by removing the need for the confusing 'xactions' variable.
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 11 Dec 2014 21:58:49 -0800
parents 35c724903157
children a7a0f32a383f
comparison
equal deleted inserted replaced
23639:35c724903157 23640:b46b9865dd08
316 If we're merging, and the other revision has removed a file 316 If we're merging, and the other revision has removed a file
317 that is not present in the working directory, we need to mark it 317 that is not present in the working directory, we need to mark it
318 as removed. 318 as removed.
319 """ 319 """
320 320
321 ractions = [] 321 actions = {}
322 factions = xactions = [] 322 m = 'f'
323 if branchmerge: 323 if branchmerge:
324 xactions = ractions 324 m = 'r'
325 for f in wctx.deleted(): 325 for f in wctx.deleted():
326 if f not in mctx: 326 if f not in mctx:
327 xactions.append((f, None, "forget deleted")) 327 actions[f] = m, None, "forget deleted"
328 328
329 if not branchmerge: 329 if not branchmerge:
330 for f in wctx.removed(): 330 for f in wctx.removed():
331 if f not in mctx: 331 if f not in mctx:
332 factions.append((f, None, "forget removed")) 332 actions[f] = 'f', None, "forget removed"
333 333
334 return ractions, factions 334 return actions
335 335
336 def _checkcollision(repo, wmf, actions): 336 def _checkcollision(repo, wmf, actions):
337 # build provisional merged manifest up 337 # build provisional merged manifest up
338 pmmf = set(wmf) 338 pmmf = set(wmf)
339 339
615 continue 615 continue
616 repo.ui.note(_('end of auction\n\n')) 616 repo.ui.note(_('end of auction\n\n'))
617 617
618 _resolvetrivial(repo, wctx, mctx, ancestors[0], actions) 618 _resolvetrivial(repo, wctx, mctx, ancestors[0], actions)
619 619
620 if wctx.rev() is None:
621 fractions = _forgetremoved(wctx, mctx, branchmerge)
622 actions.update(fractions)
623
620 # Convert to dictionary-of-lists format 624 # Convert to dictionary-of-lists format
621 actionbyfile = actions 625 actionbyfile = actions
622 actions = dict((m, []) for m in 'a f g cd dc r dm dg m e k'.split()) 626 actions = dict((m, []) for m in 'a f g cd dc r dm dg m e k'.split())
623 for f, (m, args, msg) in actionbyfile.iteritems(): 627 for f, (m, args, msg) in actionbyfile.iteritems():
624 actions[m].append((f, args, msg)) 628 actions[m].append((f, args, msg))
625
626 if wctx.rev() is None:
627 ractions, factions = _forgetremoved(wctx, mctx, branchmerge)
628 actions['r'].extend(ractions)
629 actions['f'].extend(factions)
630 629
631 return actions, diverge, renamedelete 630 return actions, diverge, renamedelete
632 631
633 def batchremove(repo, actions): 632 def batchremove(repo, actions):
634 """apply removes to the working directory 633 """apply removes to the working directory