comparison mercurial/filemerge.py @ 27033:089dab8794dc

filemerge: return whether the file is deleted from all other merge tools This is required for change/delete conflicts -- see the previous patch for more information.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 18 Nov 2015 13:55:31 -0800
parents 28ee7af4b685
children 86ede9eda252
comparison
equal deleted inserted replaced
27032:28ee7af4b685 27033:089dab8794dc
305 a, b, c, back = files 305 a, b, c, back = files
306 306
307 ui = repo.ui 307 ui = repo.ui
308 308
309 r = simplemerge.simplemerge(ui, a, b, c, label=labels, mode=mode) 309 r = simplemerge.simplemerge(ui, a, b, c, label=labels, mode=mode)
310 return True, r 310 return True, r, False
311 311
312 @internaltool('union', fullmerge, 312 @internaltool('union', fullmerge,
313 _("warning: conflicts while merging %s! " 313 _("warning: conflicts while merging %s! "
314 "(edit, then use 'hg resolve --mark')\n"), 314 "(edit, then use 'hg resolve --mark')\n"),
315 precheck=_mergecheck) 315 precheck=_mergecheck)
366 def _imergelocal(*args, **kwargs): 366 def _imergelocal(*args, **kwargs):
367 """ 367 """
368 Like :merge, but resolve all conflicts non-interactively in favor 368 Like :merge, but resolve all conflicts non-interactively in favor
369 of the local changes.""" 369 of the local changes."""
370 success, status = _imergeauto(localorother='local', *args, **kwargs) 370 success, status = _imergeauto(localorother='local', *args, **kwargs)
371 return success, status 371 return success, status, False
372 372
373 @internaltool('merge-other', mergeonly, precheck=_mergecheck) 373 @internaltool('merge-other', mergeonly, precheck=_mergecheck)
374 def _imergeother(*args, **kwargs): 374 def _imergeother(*args, **kwargs):
375 """ 375 """
376 Like :merge, but resolve all conflicts non-interactively in favor 376 Like :merge, but resolve all conflicts non-interactively in favor
377 of the other changes.""" 377 of the other changes."""
378 success, status = _imergeauto(localorother='other', *args, **kwargs) 378 success, status = _imergeauto(localorother='other', *args, **kwargs)
379 return success, status 379 return success, status, False
380 380
381 @internaltool('tagmerge', mergeonly, 381 @internaltool('tagmerge', mergeonly,
382 _("automatic tag merging of %s failed! " 382 _("automatic tag merging of %s failed! "
383 "(use 'hg resolve --tool :merge' or another merge " 383 "(use 'hg resolve --tool :merge' or another merge "
384 "tool of your choice)\n")) 384 "tool of your choice)\n"))
385 def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): 385 def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
386 """ 386 """
387 Uses the internal tag merge algorithm (experimental). 387 Uses the internal tag merge algorithm (experimental).
388 """ 388 """
389 return tagmerge.merge(repo, fcd, fco, fca) 389 success, status = tagmerge.merge(repo, fcd, fco, fca)
390 return success, status, False
390 391
391 @internaltool('dump', fullmerge) 392 @internaltool('dump', fullmerge)
392 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): 393 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
393 """ 394 """
394 Creates three versions of the files to merge, containing the 395 Creates three versions of the files to merge, containing the
402 fd = fcd.path() 403 fd = fcd.path()
403 404
404 util.copyfile(a, a + ".local") 405 util.copyfile(a, a + ".local")
405 repo.wwrite(fd + ".other", fco.data(), fco.flags()) 406 repo.wwrite(fd + ".other", fco.data(), fco.flags())
406 repo.wwrite(fd + ".base", fca.data(), fca.flags()) 407 repo.wwrite(fd + ".base", fca.data(), fca.flags())
407 return False, 1 408 return False, 1, False
408 409
409 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): 410 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
410 tool, toolpath, binary, symlink = toolconf 411 tool, toolpath, binary, symlink = toolconf
411 a, b, c, back = files 412 a, b, c, back = files
412 out = "" 413 out = ""
429 lambda s: util.shellquote(util.localpath(s))) 430 lambda s: util.shellquote(util.localpath(s)))
430 cmd = toolpath + ' ' + args 431 cmd = toolpath + ' ' + args
431 repo.ui.debug('launching merge tool: %s\n' % cmd) 432 repo.ui.debug('launching merge tool: %s\n' % cmd)
432 r = ui.system(cmd, cwd=repo.root, environ=env) 433 r = ui.system(cmd, cwd=repo.root, environ=env)
433 repo.ui.debug('merge tool returned: %s\n' % r) 434 repo.ui.debug('merge tool returned: %s\n' % r)
434 return True, r 435 return True, r, False
435 436
436 def _formatconflictmarker(repo, ctx, template, label, pad): 437 def _formatconflictmarker(repo, ctx, template, label, pad):
437 """Applies the given template to the ctx, prefixed by the label. 438 """Applies the given template to the ctx, prefixed by the label.
438 439
439 Pad is the minimum width of the label prefix, so that multiple markers 440 Pad is the minimum width of the label prefix, so that multiple markers
572 if premerge and mergetype == fullmerge: 573 if premerge and mergetype == fullmerge:
573 r = _premerge(repo, toolconf, files, labels=labels) 574 r = _premerge(repo, toolconf, files, labels=labels)
574 # complete if premerge successful (r is 0) 575 # complete if premerge successful (r is 0)
575 return not r, r 576 return not r, r
576 577
577 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, files, 578 needcheck, r, deleted = func(repo, mynode, orig, fcd, fco, fca,
578 labels=labels) 579 toolconf, files, labels=labels)
580
579 if needcheck: 581 if needcheck:
580 r = _check(r, ui, tool, fcd, files) 582 r = _check(r, ui, tool, fcd, files)
581 583
582 if r: 584 if r:
583 if onfailure: 585 if onfailure: