comparison mercurial/filemerge.py @ 35463:ef7e667a4f7b

filemerge: only raise InMemoryMergeConflictsError when running _xmerge The old code here was overly broad and would raise in cases when we didn't end up calling `xmerge` and resolved using an internal tool (such as when `premerge=True`). Instead, let's swap out _xmerge if IMM is enabled and have the new tool raise when called, which is the behavior we want. Differential Revision: https://phab.mercurial-scm.org/D1739
author Phil Cohen <phillco@fb.com>
date Wed, 20 Dec 2017 17:22:16 -0600
parents 46d7f0713a87
children f1c54d003327
comparison
equal deleted inserted replaced
35462:6f754b0fe54e 35463:ef7e667a4f7b
488 Creates three versions of the files as same as :dump, but omits premerge. 488 Creates three versions of the files as same as :dump, but omits premerge.
489 """ 489 """
490 return _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, 490 return _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files,
491 labels=labels) 491 labels=labels)
492 492
493 def _xmergeimm(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
494 # In-memory merge simply raises an exception on all external merge tools,
495 # for now.
496 #
497 # It would be possible to run most tools with temporary files, but this
498 # raises the question of what to do if the user only partially resolves the
499 # file -- we can't leave a merge state. (Copy to somewhere in the .hg/
500 # directory and tell the user how to get it is my best idea, but it's
501 # clunky.)
502 raise error.InMemoryMergeConflictsError('in-memory merge does not support '
503 'external merge tools')
504
493 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): 505 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
494 tool, toolpath, binary, symlink = toolconf 506 tool, toolpath, binary, symlink = toolconf
495 if fcd.isabsent() or fco.isabsent(): 507 if fcd.isabsent() or fco.isabsent():
496 repo.ui.warn(_('warning: %s cannot merge change/delete conflict ' 508 repo.ui.warn(_('warning: %s cannot merge change/delete conflict '
497 'for %s\n') % (tool, fcd.path())) 509 'for %s\n') % (tool, fcd.path()))
686 func = internals[tool] 698 func = internals[tool]
687 mergetype = func.mergetype 699 mergetype = func.mergetype
688 onfailure = func.onfailure 700 onfailure = func.onfailure
689 precheck = func.precheck 701 precheck = func.precheck
690 else: 702 else:
691 func = _xmerge 703 if wctx.isinmemory():
704 func = _xmergeimm
705 else:
706 func = _xmerge
692 mergetype = fullmerge 707 mergetype = fullmerge
693 onfailure = _("merging %s failed!\n") 708 onfailure = _("merging %s failed!\n")
694 precheck = None 709 precheck = None
695
696 if wctx.isinmemory():
697 raise error.InMemoryMergeConflictsError('in-memory merge does not '
698 'support external merge '
699 'tools')
700 710
701 toolconf = tool, toolpath, binary, symlink 711 toolconf = tool, toolpath, binary, symlink
702 712
703 if mergetype == nomerge: 713 if mergetype == nomerge:
704 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels) 714 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels)