comparison mercurial/commands.py @ 39080:5797b0bbdd1d

grep: include format string in columns list This lets us correctly use %d as needed. Differential Revision: https://phab.mercurial-scm.org/D4239
author Augie Fackler <augie@google.com>
date Thu, 09 Aug 2018 23:13:35 -0400
parents 9126a4034621
children 1ea6772fb415
comparison
equal deleted inserted replaced
39079:9126a4034621 39080:5797b0bbdd1d
2648 fm.startitem() 2648 fm.startitem()
2649 fm.context(ctx=ctx) 2649 fm.context(ctx=ctx)
2650 fm.data(node=fm.hexfunc(scmutil.binnode(ctx))) 2650 fm.data(node=fm.hexfunc(scmutil.binnode(ctx)))
2651 2651
2652 cols = [ 2652 cols = [
2653 ('filename', fn, True), 2653 ('filename', '%s', fn, True),
2654 ('rev', rev, not plaingrep), 2654 ('rev', '%d', rev, not plaingrep),
2655 ('linenumber', l.linenum, opts.get('line_number')), 2655 ('linenumber', '%d', l.linenum, opts.get('line_number')),
2656 ] 2656 ]
2657 if diff: 2657 if diff:
2658 cols.append(('change', change, True)) 2658 cols.append(('change', '%s', change, True))
2659 cols.extend([ 2659 cols.extend([
2660 ('user', formatuser(ctx.user()), opts.get('user')), 2660 ('user', '%s', formatuser(ctx.user()), opts.get('user')),
2661 ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')), 2661 ('date', '%s', fm.formatdate(ctx.date(), datefmt),
2662 opts.get('date')),
2662 ]) 2663 ])
2663 lastcol = next(name for name, data, cond in reversed(cols) if cond) 2664 lastcol = next(
2664 for name, data, cond in cols: 2665 name for name, fmt, data, cond in reversed(cols) if cond)
2666 for name, fmt, data, cond in cols:
2665 field = fieldnamemap.get(name, name) 2667 field = fieldnamemap.get(name, name)
2666 fm.condwrite(cond, field, '%s', data, label='grep.%s' % name) 2668 fm.condwrite(cond, field, fmt, data, label='grep.%s' % name)
2667 if cond and name != lastcol: 2669 if cond and name != lastcol:
2668 fm.plain(sep, label='grep.sep') 2670 fm.plain(sep, label='grep.sep')
2669 if not opts.get('files_with_matches'): 2671 if not opts.get('files_with_matches'):
2670 fm.plain(sep, label='grep.sep') 2672 fm.plain(sep, label='grep.sep')
2671 if not opts.get('text') and binary(): 2673 if not opts.get('text') and binary():