313 |
313 |
314 # Avoid prompting during an in-memory merge since it doesn't support merge |
314 # Avoid prompting during an in-memory merge since it doesn't support merge |
315 # conflicts. |
315 # conflicts. |
316 if fcd.changectx().isinmemory(): |
316 if fcd.changectx().isinmemory(): |
317 raise error.InMemoryMergeConflictsError( |
317 raise error.InMemoryMergeConflictsError( |
318 b'in-memory merge does not ' b'support file conflicts' |
318 b'in-memory merge does not support file conflicts' |
319 ) |
319 ) |
320 |
320 |
321 prompts = partextras(labels) |
321 prompts = partextras(labels) |
322 prompts[b'fd'] = uipathfn(fd) |
322 prompts[b'fd'] = uipathfn(fd) |
323 try: |
323 try: |
413 except error.ConfigError: |
413 except error.ConfigError: |
414 premerge = _toolstr(ui, tool, b"premerge", b"").lower() |
414 premerge = _toolstr(ui, tool, b"premerge", b"").lower() |
415 if premerge not in validkeep: |
415 if premerge not in validkeep: |
416 _valid = b', '.join([b"'" + v + b"'" for v in validkeep]) |
416 _valid = b', '.join([b"'" + v + b"'" for v in validkeep]) |
417 raise error.ConfigError( |
417 raise error.ConfigError( |
418 _(b"%s.premerge not valid " b"('%s' is neither boolean nor %s)") |
418 _(b"%s.premerge not valid ('%s' is neither boolean nor %s)") |
419 % (tool, premerge, _valid) |
419 % (tool, premerge, _valid) |
420 ) |
420 ) |
421 |
421 |
422 if premerge: |
422 if premerge: |
423 if premerge == b'keep-merge3': |
423 if premerge == b'keep-merge3': |
438 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf): |
438 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf): |
439 tool, toolpath, binary, symlink, scriptfn = toolconf |
439 tool, toolpath, binary, symlink, scriptfn = toolconf |
440 uipathfn = scmutil.getuipathfn(repo) |
440 uipathfn = scmutil.getuipathfn(repo) |
441 if symlink: |
441 if symlink: |
442 repo.ui.warn( |
442 repo.ui.warn( |
443 _(b'warning: internal %s cannot merge symlinks ' b'for %s\n') |
443 _(b'warning: internal %s cannot merge symlinks for %s\n') |
444 % (tool, uipathfn(fcd.path())) |
444 % (tool, uipathfn(fcd.path())) |
445 ) |
445 ) |
446 return False |
446 return False |
447 if fcd.isabsent() or fco.isabsent(): |
447 if fcd.isabsent() or fco.isabsent(): |
448 repo.ui.warn( |
448 repo.ui.warn( |
604 |
604 |
605 from . import context |
605 from . import context |
606 |
606 |
607 if isinstance(fcd, context.overlayworkingfilectx): |
607 if isinstance(fcd, context.overlayworkingfilectx): |
608 raise error.InMemoryMergeConflictsError( |
608 raise error.InMemoryMergeConflictsError( |
609 b'in-memory merge does not ' b'support the :dump tool.' |
609 b'in-memory merge does not support the :dump tool.' |
610 ) |
610 ) |
611 |
611 |
612 util.writefile(a + b".local", fcd.decodeddata()) |
612 util.writefile(a + b".local", fcd.decodeddata()) |
613 repo.wwrite(fd + b".other", fco.data(), fco.flags()) |
613 repo.wwrite(fd + b".other", fco.data(), fco.flags()) |
614 repo.wwrite(fd + b".base", fca.data(), fca.flags()) |
614 repo.wwrite(fd + b".base", fca.data(), fca.flags()) |
633 # raises the question of what to do if the user only partially resolves the |
633 # raises the question of what to do if the user only partially resolves the |
634 # file -- we can't leave a merge state. (Copy to somewhere in the .hg/ |
634 # file -- we can't leave a merge state. (Copy to somewhere in the .hg/ |
635 # directory and tell the user how to get it is my best idea, but it's |
635 # directory and tell the user how to get it is my best idea, but it's |
636 # clunky.) |
636 # clunky.) |
637 raise error.InMemoryMergeConflictsError( |
637 raise error.InMemoryMergeConflictsError( |
638 b'in-memory merge does not support ' b'external merge tools' |
638 b'in-memory merge does not support external merge tools' |
639 ) |
639 ) |
640 |
640 |
641 |
641 |
642 def _describemerge(ui, repo, mynode, fcl, fcb, fco, env, toolpath, args): |
642 def _describemerge(ui, repo, mynode, fcl, fcb, fco, env, toolpath, args): |
643 tmpl = ui.config(b'ui', b'pre-merge-tool-output-template') |
643 tmpl = ui.config(b'ui', b'pre-merge-tool-output-template') |
696 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
696 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
697 tool, toolpath, binary, symlink, scriptfn = toolconf |
697 tool, toolpath, binary, symlink, scriptfn = toolconf |
698 uipathfn = scmutil.getuipathfn(repo) |
698 uipathfn = scmutil.getuipathfn(repo) |
699 if fcd.isabsent() or fco.isabsent(): |
699 if fcd.isabsent() or fco.isabsent(): |
700 repo.ui.warn( |
700 repo.ui.warn( |
701 _(b'warning: %s cannot merge change/delete conflict ' b'for %s\n') |
701 _(b'warning: %s cannot merge change/delete conflict for %s\n') |
702 % (tool, uipathfn(fcd.path())) |
702 % (tool, uipathfn(fcd.path())) |
703 ) |
703 ) |
704 return False, 1, None |
704 return False, 1, None |
705 unused, unused, unused, back = files |
705 unused, unused, unused, back = files |
706 localpath = _workingpath(repo, fcd) |
706 localpath = _workingpath(repo, fcd) |
1062 |
1062 |
1063 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, toolconf): |
1063 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, toolconf): |
1064 if onfailure: |
1064 if onfailure: |
1065 if wctx.isinmemory(): |
1065 if wctx.isinmemory(): |
1066 raise error.InMemoryMergeConflictsError( |
1066 raise error.InMemoryMergeConflictsError( |
1067 b'in-memory merge does ' b'not support merge ' b'conflicts' |
1067 b'in-memory merge does not support merge conflicts' |
1068 ) |
1068 ) |
1069 ui.warn(onfailure % fduipath) |
1069 ui.warn(onfailure % fduipath) |
1070 return True, 1, False |
1070 return True, 1, False |
1071 |
1071 |
1072 back = _makebackup(repo, ui, wctx, fcd, premerge) |
1072 back = _makebackup(repo, ui, wctx, fcd, premerge) |
1148 |
1148 |
1149 |
1149 |
1150 def _onfilemergefailure(ui): |
1150 def _onfilemergefailure(ui): |
1151 action = ui.config(b'merge', b'on-failure') |
1151 action = ui.config(b'merge', b'on-failure') |
1152 if action == b'prompt': |
1152 if action == b'prompt': |
1153 msg = _(b'continue merge operation (yn)?' b'$$ &Yes $$ &No') |
1153 msg = _(b'continue merge operation (yn)?$$ &Yes $$ &No') |
1154 if ui.promptchoice(msg, 0) == 1: |
1154 if ui.promptchoice(msg, 0) == 1: |
1155 _haltmerge() |
1155 _haltmerge() |
1156 if action == b'halt': |
1156 if action == b'halt': |
1157 _haltmerge() |
1157 _haltmerge() |
1158 # default action is 'continue', in which case we neither prompt nor halt |
1158 # default action is 'continue', in which case we neither prompt nor halt |