##// END OF EJS Templates
merge-tools: when calling external merge tool, describe the resolve inputs...
Kyle Lippincott -
r40512:86dfae98 default
parent child Browse files
Show More
@@ -1193,6 +1193,9 b" coreconfigitem('ui', 'paginate',"
1193 1193 coreconfigitem('ui', 'patch',
1194 1194 default=None,
1195 1195 )
1196 coreconfigitem('ui', 'pre-merge-tool-output-template',
1197 default=None,
1198 )
1196 1199 coreconfigitem('ui', 'portablefilenames',
1197 1200 default='warn',
1198 1201 )
@@ -13,7 +13,11 b' import re'
13 13 import shutil
14 14
15 15 from .i18n import _
16 from .node import nullid, short
16 from .node import (
17 hex,
18 nullid,
19 short,
20 )
17 21
18 22 from . import (
19 23 encoding,
@@ -27,6 +31,7 b' from . import ('
27 31 tagmerge,
28 32 templatekw,
29 33 templater,
34 templateutil,
30 35 util,
31 36 )
32 37
@@ -536,6 +541,44 b' def _xmergeimm(repo, mynode, orig, fcd, '
536 541 raise error.InMemoryMergeConflictsError('in-memory merge does not support '
537 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 582 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
540 583 tool, toolpath, binary, symlink, scriptfn = toolconf
541 584 if fcd.isabsent() or fco.isabsent():
@@ -584,6 +627,7 b' def _xmerge(repo, mynode, orig, fcd, fco'
584 627 if scriptfn is None:
585 628 cmd = toolpath + ' ' + args
586 629 repo.ui.debug('launching merge tool: %s\n' % cmd)
630 _describemerge(ui, repo, mynode, fcd, fca, fco, env, toolpath, args)
587 631 r = ui.system(cmd, cwd=repo.root, environ=env,
588 632 blockedtag='mergetool')
589 633 else:
@@ -2296,6 +2296,16 b' User interface controls.'
2296 2296
2297 2297 On Windows, this configuration option is ignored and the command aborted.
2298 2298
2299 ``pre-merge-tool-output-template``
2300 A template that is printed before executing an external merge tool. This can
2301 be used to print out additional context that might be useful to have during
2302 the conflict resolution, such as the description of the various commits
2303 involved or bookmarks/tags.
2304
2305 Additional information is available in the ``local`, ``base``, and ``other``
2306 dicts. For example: ``{local.label}``, ``{base.name}``, or
2307 ``{other.islink}``.
2308
2299 2309 ``quiet``
2300 2310 Reduce the amount of output printed.
2301 2311 (default: False)
@@ -1946,6 +1946,25 b' internal merge tools is checked strictly'
1946 1946 0000: 00 01 02 03 |....|
1947 1947 $ hg merge --abort -q
1948 1948
1949 Check that the extra information is printed correctly
1950
1951 $ hg merge 9 \
1952 > --config merge-tools.testecho.executable='echo' \
1953 > --config merge-tools.testecho.args='merge runs here ...' \
1954 > --config merge-tools.testecho.binary=True \
1955 > --config ui.merge=testecho \
1956 > --config ui.pre-merge-tool-output-template='\n{label("extmerge.running_merge_tool", "Running merge tool for {path} ({toolpath}):")}\n{separate("\n", extmerge_section(local), extmerge_section(base), extmerge_section(other))}\n' \
1957 > --config 'templatealias.extmerge_section(sect)="- {pad("{sect.name} ({sect.label})", 20, left=True)}: {revset(sect.node)%"{rev}:{shortest(node,8)} {desc|firstline} {separate(" ", tags, bookmarks, branch)}"}"'
1958 merging b
1959
1960 Running merge tool for b (*/bin/echo): (glob)
1961 - local (working copy): 10:2d1f533d add binary file (#2) tip default
1962 - base (base): -1:00000000 default
1963 - other (merge rev): 9:1e7ad7d7 add binary file (#1) default
1964 merge runs here ...
1965 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1966 (branch merge, don't forget to commit)
1967
1949 1968 Check that debugpicktool examines which merge tool is chosen for
1950 1969 specified file as expected
1951 1970
General Comments 0
You need to be logged in to leave comments. Login now