##// END OF EJS Templates
grep: colorize all fields...
Idan Kamara -
r17806:dc7010ed default
parent child Browse files
Show More
@@ -224,6 +224,13 b' except ImportError:'
224 224 _terminfo_params = False
225 225
226 226 _styles = {'grep.match': 'red bold',
227 'grep.linenumber': 'green',
228 'grep.rev': 'green',
229 'grep.change': 'green',
230 'grep.sep': 'cyan',
231 'grep.filename': 'magenta',
232 'grep.user': 'magenta',
233 'grep.date': 'magenta',
227 234 'bookmarks.current': 'green',
228 235 'branches.active': 'none',
229 236 'branches.closed': 'black bold',
@@ -2994,16 +2994,17 b' def grep(ui, repo, pattern, *pats, **opt'
2994 2994 else:
2995 2995 iter = [('', l) for l in states]
2996 2996 for change, l in iter:
2997 cols = [fn, str(rev)]
2997 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
2998 2998 before, match, after = None, None, None
2999
2999 3000 if opts.get('line_number'):
3000 cols.append(str(l.linenum))
3001 cols.append((str(l.linenum), 'grep.linenumber'))
3001 3002 if opts.get('all'):
3002 cols.append(change)
3003 cols.append((change, 'grep.change'))
3003 3004 if opts.get('user'):
3004 cols.append(ui.shortuser(ctx.user()))
3005 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3005 3006 if opts.get('date'):
3006 cols.append(datefunc(ctx.date()))
3007 cols.append((datefunc(ctx.date()), 'grep.date'))
3007 3008 if opts.get('files_with_matches'):
3008 3009 c = (fn, rev)
3009 3010 if c in filerevmatches:
@@ -3013,12 +3014,16 b' def grep(ui, repo, pattern, *pats, **opt'
3013 3014 before = l.line[:l.colstart]
3014 3015 match = l.line[l.colstart:l.colend]
3015 3016 after = l.line[l.colend:]
3016 ui.write(sep.join(cols))
3017 for col, label in cols[:-1]:
3018 ui.write(col, label=label)
3019 ui.write(sep, label='grep.sep')
3020 ui.write(cols[-1][0], label=cols[-1][1])
3017 3021 if before is not None:
3022 ui.write(sep, label='grep.sep')
3018 3023 if not opts.get('text') and binary():
3019 ui.write(sep + " Binary file matches")
3024 ui.write(" Binary file matches")
3020 3025 else:
3021 ui.write(sep + before)
3026 ui.write(before)
3022 3027 ui.write(match, label='grep.match')
3023 3028 ui.write(after)
3024 3029 ui.write(eol)
@@ -32,9 +32,9 b' simple with color'
32 32
33 33 $ hg --config extensions.color= grep --config color.mode=ansi \
34 34 > --color=always port port
35 port:4:ex\x1b[0;31;1mport\x1b[0m (esc)
36 port:4:va\x1b[0;31;1mport\x1b[0might (esc)
37 port:4:im\x1b[0;31;1mport\x1b[0m/export (esc)
35 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32m4\x1b[0m\x1b[0;36m:\x1b[0mex\x1b[0;31;1mport\x1b[0m (esc)
36 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32m4\x1b[0m\x1b[0;36m:\x1b[0mva\x1b[0;31;1mport\x1b[0might (esc)
37 \x1b[0;35mport\x1b[0m\x1b[0;36m:\x1b[0m\x1b[0;32m4\x1b[0m\x1b[0;36m:\x1b[0mim\x1b[0;31;1mport\x1b[0m/export (esc)
38 38
39 39 all
40 40
General Comments 0
You need to be logged in to leave comments. Login now