comparison mercurial/filemerge.py @ 35291:46d7f0713a87

filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM Merge conflicts might be supported in the future, but for now are kept out of scope. Any places where we used to call `flushall()` should be replaced with some kind of exception. At this point, IMM M1 is no longer supported. Differential Revision: https://phab.mercurial-scm.org/D1212
author Phil Cohen <phillco@fb.com>
date Fri, 01 Dec 2017 00:07:23 -0800
parents 010179e21e91
children ef7e667a4f7b
comparison
equal deleted inserted replaced
35290:010179e21e91 35291:46d7f0713a87
239 """Asks the user which of the local `p1()` or the other `p2()` version to 239 """Asks the user which of the local `p1()` or the other `p2()` version to
240 keep as the merged version.""" 240 keep as the merged version."""
241 ui = repo.ui 241 ui = repo.ui
242 fd = fcd.path() 242 fd = fcd.path()
243 243
244 # Avoid prompting during an in-memory merge since it doesn't support merge
245 # conflicts.
246 if fcd.changectx().isinmemory():
247 raise error.InMemoryMergeConflictsError('in-memory merge does not '
248 'support file conflicts')
249
244 prompts = partextras(labels) 250 prompts = partextras(labels)
245 prompts['fd'] = fd 251 prompts['fd'] = fd
246 try: 252 try:
247 if fco.isabsent(): 253 if fco.isabsent():
248 index = ui.promptchoice( 254 index = ui.promptchoice(
463 runs successfully. Use :forcedump to forcibly write files out. 469 runs successfully. Use :forcedump to forcibly write files out.
464 """ 470 """
465 a = _workingpath(repo, fcd) 471 a = _workingpath(repo, fcd)
466 fd = fcd.path() 472 fd = fcd.path()
467 473
468 # Run ``flushall()`` to make any missing folders the following wwrite
469 # calls might be depending on.
470 from . import context 474 from . import context
471 if isinstance(fcd, context.overlayworkingfilectx): 475 if isinstance(fcd, context.overlayworkingfilectx):
472 fcd.changectx().flushall() 476 raise error.InMemoryMergeConflictsError('in-memory merge does not '
477 'support the :dump tool.')
473 478
474 util.writefile(a + ".local", fcd.decodeddata()) 479 util.writefile(a + ".local", fcd.decodeddata())
475 repo.wwrite(fd + ".other", fco.data(), fco.flags()) 480 repo.wwrite(fd + ".other", fco.data(), fco.flags())
476 repo.wwrite(fd + ".base", fca.data(), fca.flags()) 481 repo.wwrite(fd + ".base", fca.data(), fca.flags())
477 return False, 1, False 482 return False, 1, False
686 func = _xmerge 691 func = _xmerge
687 mergetype = fullmerge 692 mergetype = fullmerge
688 onfailure = _("merging %s failed!\n") 693 onfailure = _("merging %s failed!\n")
689 precheck = None 694 precheck = None
690 695
691 # If using deferred writes, must flush any deferred contents if running 696 if wctx.isinmemory():
692 # an external merge tool since it has arbitrary access to the working 697 raise error.InMemoryMergeConflictsError('in-memory merge does not '
693 # copy. 698 'support external merge '
694 wctx.flushall() 699 'tools')
695 700
696 toolconf = tool, toolpath, binary, symlink 701 toolconf = tool, toolpath, binary, symlink
697 702
698 if mergetype == nomerge: 703 if mergetype == nomerge:
699 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels) 704 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
708 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) 713 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
709 714
710 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, 715 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
711 toolconf): 716 toolconf):
712 if onfailure: 717 if onfailure:
718 if wctx.isinmemory():
719 raise error.InMemoryMergeConflictsError('in-memory merge does '
720 'not support merge '
721 'conflicts')
713 ui.warn(onfailure % fd) 722 ui.warn(onfailure % fd)
714 return True, 1, False 723 return True, 1, False
715 724
716 back = _makebackup(repo, ui, wctx, fcd, premerge) 725 back = _makebackup(repo, ui, wctx, fcd, premerge)
717 files = (None, None, None, back) 726 files = (None, None, None, back)
734 if needcheck: 743 if needcheck:
735 r = _check(repo, r, ui, tool, fcd, files) 744 r = _check(repo, r, ui, tool, fcd, files)
736 745
737 if r: 746 if r:
738 if onfailure: 747 if onfailure:
748 if wctx.isinmemory():
749 raise error.InMemoryMergeConflictsError('in-memory merge '
750 'does not support '
751 'merge conflicts')
739 ui.warn(onfailure % fd) 752 ui.warn(onfailure % fd)
740 _onfilemergefailure(ui) 753 _onfilemergefailure(ui)
741 754
742 return True, r, deleted 755 return True, r, deleted
743 finally: 756 finally: