##// END OF EJS Templates
grep: make use of output labeling
Brodie Rao -
r10816:635d601e default
parent child Browse files
Show More
@@ -1353,6 +1353,7 b' def grep(ui, repo, pattern, *pats, **opt'
1353 iter = [('', l) for l in states]
1353 iter = [('', l) for l in states]
1354 for change, l in iter:
1354 for change, l in iter:
1355 cols = [fn, str(rev)]
1355 cols = [fn, str(rev)]
1356 before, match, after = None, None, None
1356 if opts.get('line_number'):
1357 if opts.get('line_number'):
1357 cols.append(str(l.linenum))
1358 cols.append(str(l.linenum))
1358 if opts.get('all'):
1359 if opts.get('all'):
@@ -1367,8 +1368,15 b' def grep(ui, repo, pattern, *pats, **opt'
1367 continue
1368 continue
1368 filerevmatches[c] = 1
1369 filerevmatches[c] = 1
1369 else:
1370 else:
1370 cols.append(l.line)
1371 before = l.line[:l.colstart]
1371 ui.write(sep.join(cols), eol)
1372 match = l.line[l.colstart:l.colend]
1373 after = l.line[l.colend:]
1374 ui.write(sep.join(cols))
1375 if before is not None:
1376 ui.write(sep + before)
1377 ui.write(match, label='grep.match')
1378 ui.write(after)
1379 ui.write(eol)
1372 found = True
1380 found = True
1373 return found
1381 return found
1374
1382
General Comments 0
You need to be logged in to leave comments. Login now