comparison mercurial/commands.py @ 29862:37d838e8eb0b

grep: build list of columns without "grep." label prefix Prepares for formatter support. We need field names without "grep.".
author Yuya Nishihara <yuya@tcha.org>
date Thu, 18 Aug 2016 14:23:29 +0900
parents fac24eab65a4
children 0418cdf67efb
comparison
equal deleted inserted replaced
29861:fac24eab65a4 29862:37d838e8eb0b
4395 if opts.get('all'): 4395 if opts.get('all'):
4396 iter = difflinestates(pstates, states) 4396 iter = difflinestates(pstates, states)
4397 else: 4397 else:
4398 iter = [('', l) for l in states] 4398 iter = [('', l) for l in states]
4399 for change, l in iter: 4399 for change, l in iter:
4400 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')] 4400 cols = [(fn, 'filename'), (str(rev), 'rev')]
4401 4401
4402 if opts.get('line_number'): 4402 if opts.get('line_number'):
4403 cols.append((str(l.linenum), 'grep.linenumber')) 4403 cols.append((str(l.linenum), 'linenumber'))
4404 if opts.get('all'): 4404 if opts.get('all'):
4405 cols.append((change, 'grep.change')) 4405 cols.append((change, 'change'))
4406 if opts.get('user'): 4406 if opts.get('user'):
4407 cols.append((ui.shortuser(ctx.user()), 'grep.user')) 4407 cols.append((ui.shortuser(ctx.user()), 'user'))
4408 if opts.get('date'): 4408 if opts.get('date'):
4409 cols.append((datefunc(ctx.date()), 'grep.date')) 4409 cols.append((datefunc(ctx.date()), 'date'))
4410 for col, label in cols[:-1]: 4410 for col, field in cols[:-1]:
4411 ui.write(col, label=label) 4411 ui.write(col, label='grep.%s' % field)
4412 ui.write(sep, label='grep.sep') 4412 ui.write(sep, label='grep.sep')
4413 ui.write(cols[-1][0], label=cols[-1][1]) 4413 ui.write(cols[-1][0], label='grep.%s' % cols[-1][1])
4414 if not opts.get('files_with_matches'): 4414 if not opts.get('files_with_matches'):
4415 ui.write(sep, label='grep.sep') 4415 ui.write(sep, label='grep.sep')
4416 if not opts.get('text') and binary(): 4416 if not opts.get('text') and binary():
4417 ui.write(_(" Binary file matches")) 4417 ui.write(_(" Binary file matches"))
4418 else: 4418 else: