Show More
@@ -2513,7 +2513,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
2513 | 2513 | yield ('+', b[i]) |
|
2514 | 2514 | |
|
2515 | 2515 | def display(fm, fn, ctx, pstates, states): |
|
2516 |
rev = ctx |
|
|
2516 | rev = scmutil.intrev(ctx) | |
|
2517 | 2517 | if fm.isplain(): |
|
2518 | 2518 | formatuser = ui.shortuser |
|
2519 | 2519 | else: |
@@ -2526,7 +2526,10 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
2526 | 2526 | @util.cachefunc |
|
2527 | 2527 | def binary(): |
|
2528 | 2528 | flog = getfile(fn) |
|
2529 | try: | |
|
2529 | 2530 | return stringutil.binary(flog.read(ctx.filenode(fn))) |
|
2531 | except error.WdirUnsupported: | |
|
2532 | return ctx[fn].isbinary() | |
|
2530 | 2533 | |
|
2531 | 2534 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} |
|
2532 | 2535 | if opts.get('all'): |
@@ -2535,7 +2538,8 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
2535 | 2538 | iter = [('', l) for l in states] |
|
2536 | 2539 | for change, l in iter: |
|
2537 | 2540 | fm.startitem() |
|
2538 |
fm.data(node=fm.hexfunc(ctx |
|
|
2541 | fm.data(node=fm.hexfunc(scmutil.binnode(ctx))) | |
|
2542 | ||
|
2539 | 2543 | cols = [ |
|
2540 | 2544 | ('filename', fn, True), |
|
2541 | 2545 | ('rev', rev, True), |
@@ -2601,8 +2605,10 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
2601 | 2605 | fnode = ctx.filenode(fn) |
|
2602 | 2606 | except error.LookupError: |
|
2603 | 2607 | continue |
|
2604 | ||
|
2608 | try: | |
|
2605 | 2609 | copied = flog.renamed(fnode) |
|
2610 | except error.WdirUnsupported: | |
|
2611 | copied = ctx[fn].renamed() | |
|
2606 | 2612 | copy = follow and copied and copied[0] |
|
2607 | 2613 | if copy: |
|
2608 | 2614 | copies.setdefault(rev, {})[fn] = copy |
@@ -2613,7 +2619,11 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
2613 | 2619 | files.append(fn) |
|
2614 | 2620 | |
|
2615 | 2621 | if fn not in matches[rev]: |
|
2616 | grepbody(fn, rev, flog.read(fnode)) | |
|
2622 | try: | |
|
2623 | content = flog.read(fnode) | |
|
2624 | except error.WdirUnsupported: | |
|
2625 | content = ctx[fn].data() | |
|
2626 | grepbody(fn, rev, content) | |
|
2617 | 2627 | |
|
2618 | 2628 | pfn = copy or fn |
|
2619 | 2629 | if pfn not in matches[parent]: |
@@ -250,8 +250,11 b' Test wdir' | |||
|
250 | 250 | $ hg stat |
|
251 | 251 | M port2 |
|
252 | 252 | $ hg grep -r 'wdir()' port |
|
253 | abort: working directory revision cannot be specified | |
|
254 | [255] | |
|
253 | port2:2147483647:export | |
|
254 | port2:2147483647:vaportight | |
|
255 | port2:2147483647:import/export | |
|
256 | port2:2147483647:deport | |
|
257 | port2:2147483647:wport | |
|
255 | 258 | |
|
256 | 259 | $ cd .. |
|
257 | 260 | $ hg init t2 |
@@ -368,3 +371,14 b' revisions printed, just their order.' | |||
|
368 | 371 | binfile.bin:0:+: Binary file matches |
|
369 | 372 | |
|
370 | 373 | $ cd .. |
|
374 | ||
|
375 | Fix_Wdir(): test that passing wdir() t -r flag does greps on the | |
|
376 | files modified in the working directory | |
|
377 | ||
|
378 | $ cd a | |
|
379 | $ echo "abracadara" >> a | |
|
380 | $ hg add a | |
|
381 | $ hg grep -r "wdir()" "abra" | |
|
382 | a:2147483647:abracadara | |
|
383 | ||
|
384 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now