comparison mercurial/commands.py @ 37500:8bb3899a0f47

formatter: make nested items somewhat readable in template output
author Yuya Nishihara <yuya@tcha.org>
date Thu, 15 Mar 2018 22:27:16 +0900
parents aacfca6f9767
children d110167610db
comparison
equal deleted inserted replaced
37499:75c13343cf38 37500:8bb3899a0f47
384 if not opts.get('text') and fctx.isbinary(): 384 if not opts.get('text') and fctx.isbinary():
385 rootfm.plain(_("%s: binary file\n") 385 rootfm.plain(_("%s: binary file\n")
386 % ((pats and m.rel(abs)) or abs)) 386 % ((pats and m.rel(abs)) or abs))
387 continue 387 continue
388 388
389 fm = rootfm.nested('lines') 389 fm = rootfm.nested('lines', tmpl='{rev}: {line}')
390 lines = fctx.annotate(follow=follow, skiprevs=skiprevs, 390 lines = fctx.annotate(follow=follow, skiprevs=skiprevs,
391 diffopts=diffopts) 391 diffopts=diffopts)
392 if not lines: 392 if not lines:
393 fm.end() 393 fm.end()
394 continue 394 continue
2504 if not opts.get('files_with_matches'): 2504 if not opts.get('files_with_matches'):
2505 fm.plain(sep, label='grep.sep') 2505 fm.plain(sep, label='grep.sep')
2506 if not opts.get('text') and binary(): 2506 if not opts.get('text') and binary():
2507 fm.plain(_(" Binary file matches")) 2507 fm.plain(_(" Binary file matches"))
2508 else: 2508 else:
2509 displaymatches(fm.nested('texts'), l) 2509 displaymatches(fm.nested('texts', tmpl='{text}'), l)
2510 fm.plain(eol) 2510 fm.plain(eol)
2511 found = True 2511 found = True
2512 if opts.get('files_with_matches'): 2512 if opts.get('files_with_matches'):
2513 break 2513 break
2514 return found 2514 return found
2846 2846
2847 if num: 2847 if num:
2848 numoutput = ["%d" % p.rev() for p in parents] 2848 numoutput = ["%d" % p.rev() for p in parents]
2849 output.append("%s%s" % ('+'.join(numoutput), dirty)) 2849 output.append("%s%s" % ('+'.join(numoutput), dirty))
2850 2850
2851 fn = fm.nested('parents') 2851 fn = fm.nested('parents', tmpl='{rev}:{node|formatnode}', sep=' ')
2852 for p in parents: 2852 for p in parents:
2853 fn.startitem() 2853 fn.startitem()
2854 fn.data(rev=p.rev()) 2854 fn.data(rev=p.rev())
2855 fn.data(node=p.hex()) 2855 fn.data(node=p.hex())
2856 fn.context(ctx=p) 2856 fn.context(ctx=p)
5613 isinternals = [] 5613 isinternals = []
5614 for name, module in extensions.extensions(): 5614 for name, module in extensions.extensions():
5615 names.append(name) 5615 names.append(name)
5616 vers.append(extensions.moduleversion(module) or None) 5616 vers.append(extensions.moduleversion(module) or None)
5617 isinternals.append(extensions.ismoduleinternal(module)) 5617 isinternals.append(extensions.ismoduleinternal(module))
5618 fn = fm.nested("extensions") 5618 fn = fm.nested("extensions", tmpl='{name}\n')
5619 if names: 5619 if names:
5620 namefmt = " %%-%ds " % max(len(n) for n in names) 5620 namefmt = " %%-%ds " % max(len(n) for n in names)
5621 places = [_("external"), _("internal")] 5621 places = [_("external"), _("internal")]
5622 for n, v, p in zip(names, vers, isinternals): 5622 for n, v, p in zip(names, vers, isinternals):
5623 fn.startitem() 5623 fn.startitem()