Show More
@@ -2391,6 +2391,8 b' def _stopgraft(ui, repo, graftstate):' | |||||
2391 | @command('grep', |
|
2391 | @command('grep', | |
2392 | [('0', 'print0', None, _('end fields with NUL')), |
|
2392 | [('0', 'print0', None, _('end fields with NUL')), | |
2393 | ('', 'all', None, _('print all revisions that match')), |
|
2393 | ('', 'all', None, _('print all revisions that match')), | |
|
2394 | ('', 'diff', None, _('print all revisions when the term was introduced ' | |||
|
2395 | 'or removed')), | |||
2394 | ('a', 'text', None, _('treat all files as text')), |
|
2396 | ('a', 'text', None, _('treat all files as text')), | |
2395 | ('f', 'follow', None, |
|
2397 | ('f', 'follow', None, | |
2396 | _('follow changeset history,' |
|
2398 | _('follow changeset history,' | |
@@ -2419,7 +2421,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2419 | file in which it finds a match. To get it to print every revision |
|
2421 | file in which it finds a match. To get it to print every revision | |
2420 | that contains a change in match status ("-" for a match that becomes |
|
2422 | that contains a change in match status ("-" for a match that becomes | |
2421 | a non-match, or "+" for a non-match that becomes a match), use the |
|
2423 | a non-match, or "+" for a non-match that becomes a match), use the | |
2422 | --all flag. |
|
2424 | --diff/--all flag. | |
2423 |
|
2425 | |||
2424 | PATTERN can be any Python (roughly Perl-compatible) regular |
|
2426 | PATTERN can be any Python (roughly Perl-compatible) regular | |
2425 | expression. |
|
2427 | expression. | |
@@ -2431,6 +2433,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2431 | Returns 0 if a match is found, 1 otherwise. |
|
2433 | Returns 0 if a match is found, 1 otherwise. | |
2432 | """ |
|
2434 | """ | |
2433 | opts = pycompat.byteskwargs(opts) |
|
2435 | opts = pycompat.byteskwargs(opts) | |
|
2436 | diff = opts.get('all') or opts.get('diff') | |||
2434 | reflags = re.M |
|
2437 | reflags = re.M | |
2435 | if opts.get('ignore_case'): |
|
2438 | if opts.get('ignore_case'): | |
2436 | reflags |= re.I |
|
2439 | reflags |= re.I | |
@@ -2527,7 +2530,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2527 | return ctx[fn].isbinary() |
|
2530 | return ctx[fn].isbinary() | |
2528 |
|
2531 | |||
2529 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} |
|
2532 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} | |
2530 | if opts.get('all'): |
|
2533 | if diff: | |
2531 | iter = difflinestates(pstates, states) |
|
2534 | iter = difflinestates(pstates, states) | |
2532 | else: |
|
2535 | else: | |
2533 | iter = [('', l) for l in states] |
|
2536 | iter = [('', l) for l in states] | |
@@ -2540,7 +2543,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2540 | ('rev', rev, True), |
|
2543 | ('rev', rev, True), | |
2541 | ('linenumber', l.linenum, opts.get('line_number')), |
|
2544 | ('linenumber', l.linenum, opts.get('line_number')), | |
2542 | ] |
|
2545 | ] | |
2543 |
if |
|
2546 | if diff: | |
2544 | cols.append(('change', change, True)) |
|
2547 | cols.append(('change', change, True)) | |
2545 | cols.extend([ |
|
2548 | cols.extend([ | |
2546 | ('user', formatuser(ctx.user()), opts.get('user')), |
|
2549 | ('user', formatuser(ctx.user()), opts.get('user')), | |
@@ -2644,7 +2647,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2644 | if pstates or states: |
|
2647 | if pstates or states: | |
2645 | r = display(fm, fn, ctx, pstates, states) |
|
2648 | r = display(fm, fn, ctx, pstates, states) | |
2646 | found = found or r |
|
2649 | found = found or r | |
2647 |
if r and not |
|
2650 | if r and not diff: | |
2648 | skip[fn] = True |
|
2651 | skip[fn] = True | |
2649 | if copy: |
|
2652 | if copy: | |
2650 | skip[copy] = True |
|
2653 | skip[copy] = True |
@@ -313,7 +313,7 b' Show all commands + options' | |||||
313 | debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure |
|
313 | debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure | |
314 | files: rev, print0, include, exclude, template, subrepos |
|
314 | files: rev, print0, include, exclude, template, subrepos | |
315 | graft: rev, continue, stop, edit, log, force, currentdate, currentuser, date, user, tool, dry-run |
|
315 | graft: rev, continue, stop, edit, log, force, currentdate, currentuser, date, user, tool, dry-run | |
316 | grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, allfiles, user, date, template, include, exclude |
|
316 | grep: print0, all, diff, text, follow, ignore-case, files-with-matches, line-number, rev, allfiles, user, date, template, include, exclude | |
317 | heads: rev, topo, active, closed, style, template |
|
317 | heads: rev, topo, active, closed, style, template | |
318 | help: extension, command, keyword, system |
|
318 | help: extension, command, keyword, system | |
319 | identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template |
|
319 | identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template |
@@ -281,6 +281,11 b' Test wdir' | |||||
281 | color:2:-:orange |
|
281 | color:2:-:orange | |
282 | color:1:+:orange |
|
282 | color:1:+:orange | |
283 |
|
283 | |||
|
284 | $ hg grep --diff orange | |||
|
285 | color:3:+:orange | |||
|
286 | color:2:-:orange | |||
|
287 | color:1:+:orange | |||
|
288 | ||||
284 | test substring match: '^' should only match at the beginning |
|
289 | test substring match: '^' should only match at the beginning | |
285 |
|
290 | |||
286 | $ hg grep '^.' --config extensions.color= --color debug |
|
291 | $ hg grep '^.' --config extensions.color= --color debug | |
@@ -349,6 +354,10 b' of just using revision numbers.' | |||||
349 | color:3:-:red |
|
354 | color:3:-:red | |
350 | color:1:+:red |
|
355 | color:1:+:red | |
351 |
|
356 | |||
|
357 | $ hg grep --diff red | |||
|
358 | color:3:-:red | |||
|
359 | color:1:+:red | |||
|
360 | ||||
352 | Issue3885: test that changing revision order does not alter the |
|
361 | Issue3885: test that changing revision order does not alter the | |
353 | revisions printed, just their order. |
|
362 | revisions printed, just their order. | |
354 |
|
363 | |||
@@ -360,6 +369,14 b' revisions printed, just their order.' | |||||
360 | color:3:-:red |
|
369 | color:3:-:red | |
361 | color:1:+:red |
|
370 | color:1:+:red | |
362 |
|
371 | |||
|
372 | $ hg grep --diff red -r "all()" | |||
|
373 | color:1:+:red | |||
|
374 | color:3:-:red | |||
|
375 | ||||
|
376 | $ hg grep --diff red -r "reverse(all())" | |||
|
377 | color:3:-:red | |||
|
378 | color:1:+:red | |||
|
379 | ||||
363 | $ cd .. |
|
380 | $ cd .. | |
364 |
|
381 | |||
365 | $ hg init a |
|
382 | $ hg init a | |
@@ -370,6 +387,9 b' revisions printed, just their order.' | |||||
370 | $ hg grep "MaCam" --all |
|
387 | $ hg grep "MaCam" --all | |
371 | binfile.bin:0:+: Binary file matches |
|
388 | binfile.bin:0:+: Binary file matches | |
372 |
|
389 | |||
|
390 | $ hg grep "MaCam" --diff | |||
|
391 | binfile.bin:0:+: Binary file matches | |||
|
392 | ||||
373 | $ cd .. |
|
393 | $ cd .. | |
374 |
|
394 | |||
375 | Test for showing working of allfiles flag |
|
395 | Test for showing working of allfiles flag |
General Comments 0
You need to be logged in to leave comments.
Login now