534 # directory and tell the user how to get it is my best idea, but it's |
539 # directory and tell the user how to get it is my best idea, but it's |
535 # clunky.) |
540 # clunky.) |
536 raise error.InMemoryMergeConflictsError('in-memory merge does not support ' |
541 raise error.InMemoryMergeConflictsError('in-memory merge does not support ' |
537 'external merge tools') |
542 'external merge tools') |
538 |
543 |
|
544 def _describemerge(ui, repo, mynode, fcl, fcb, fco, env, toolpath, args): |
|
545 tmpl = ui.config('ui', 'pre-merge-tool-output-template') |
|
546 if not tmpl: |
|
547 return |
|
548 |
|
549 mappingdict = templateutil.mappingdict |
|
550 props = {'ctx': fcl.changectx(), |
|
551 'node': hex(mynode), |
|
552 'path': fcl.path(), |
|
553 'local': mappingdict({'ctx': fcl.changectx(), |
|
554 'fctx': fcl, |
|
555 'node': hex(mynode), |
|
556 'name': _('local'), |
|
557 'islink': 'l' in fcl.flags(), |
|
558 'label': env['HG_MY_LABEL']}), |
|
559 'base': mappingdict({'ctx': fcb.changectx(), |
|
560 'fctx': fcb, |
|
561 'name': _('base'), |
|
562 'islink': 'l' in fcb.flags(), |
|
563 'label': env['HG_BASE_LABEL']}), |
|
564 'other': mappingdict({'ctx': fco.changectx(), |
|
565 'fctx': fco, |
|
566 'name': _('other'), |
|
567 'islink': 'l' in fco.flags(), |
|
568 'label': env['HG_OTHER_LABEL']}), |
|
569 'toolpath': toolpath, |
|
570 'toolargs': args} |
|
571 |
|
572 # TODO: make all of this something that can be specified on a per-tool basis |
|
573 tmpl = templater.unquotestring(tmpl) |
|
574 |
|
575 # Not using cmdutil.rendertemplate here since it causes errors importing |
|
576 # things for us to import cmdutil. |
|
577 tres = formatter.templateresources(ui, repo) |
|
578 t = formatter.maketemplater(ui, tmpl, defaults=templatekw.keywords, |
|
579 resources=tres) |
|
580 ui.status(t.renderdefault(props)) |
|
581 |
539 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
582 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
540 tool, toolpath, binary, symlink, scriptfn = toolconf |
583 tool, toolpath, binary, symlink, scriptfn = toolconf |
541 if fcd.isabsent() or fco.isabsent(): |
584 if fcd.isabsent() or fco.isabsent(): |
542 repo.ui.warn(_('warning: %s cannot merge change/delete conflict ' |
585 repo.ui.warn(_('warning: %s cannot merge change/delete conflict ' |
543 'for %s\n') % (tool, fcd.path())) |
586 'for %s\n') % (tool, fcd.path())) |
582 repo.ui.status(_('running merge tool %s for file %s\n') % |
625 repo.ui.status(_('running merge tool %s for file %s\n') % |
583 (tool, fcd.path())) |
626 (tool, fcd.path())) |
584 if scriptfn is None: |
627 if scriptfn is None: |
585 cmd = toolpath + ' ' + args |
628 cmd = toolpath + ' ' + args |
586 repo.ui.debug('launching merge tool: %s\n' % cmd) |
629 repo.ui.debug('launching merge tool: %s\n' % cmd) |
|
630 _describemerge(ui, repo, mynode, fcd, fca, fco, env, toolpath, args) |
587 r = ui.system(cmd, cwd=repo.root, environ=env, |
631 r = ui.system(cmd, cwd=repo.root, environ=env, |
588 blockedtag='mergetool') |
632 blockedtag='mergetool') |
589 else: |
633 else: |
590 repo.ui.debug('launching python merge script: %s:%s\n' % |
634 repo.ui.debug('launching python merge script: %s:%s\n' % |
591 (toolpath, scriptfn)) |
635 (toolpath, scriptfn)) |