Show More
@@ -2513,7 +2513,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2513 | yield ('+', b[i]) |
|
2513 | yield ('+', b[i]) | |
2514 |
|
2514 | |||
2515 | def display(fm, fn, ctx, pstates, states): |
|
2515 | def display(fm, fn, ctx, pstates, states): | |
2516 |
rev = ctx |
|
2516 | rev = scmutil.intrev(ctx) | |
2517 | if fm.isplain(): |
|
2517 | if fm.isplain(): | |
2518 | formatuser = ui.shortuser |
|
2518 | formatuser = ui.shortuser | |
2519 | else: |
|
2519 | else: | |
@@ -2526,7 +2526,10 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2526 | @util.cachefunc |
|
2526 | @util.cachefunc | |
2527 | def binary(): |
|
2527 | def binary(): | |
2528 | flog = getfile(fn) |
|
2528 | flog = getfile(fn) | |
|
2529 | try: | |||
2529 | return stringutil.binary(flog.read(ctx.filenode(fn))) |
|
2530 | return stringutil.binary(flog.read(ctx.filenode(fn))) | |
|
2531 | except error.WdirUnsupported: | |||
|
2532 | return ctx[fn].isbinary() | |||
2530 |
|
2533 | |||
2531 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} |
|
2534 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} | |
2532 | if opts.get('all'): |
|
2535 | if opts.get('all'): | |
@@ -2535,7 +2538,8 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2535 | iter = [('', l) for l in states] |
|
2538 | iter = [('', l) for l in states] | |
2536 | for change, l in iter: |
|
2539 | for change, l in iter: | |
2537 | fm.startitem() |
|
2540 | fm.startitem() | |
2538 |
fm.data(node=fm.hexfunc(ctx |
|
2541 | fm.data(node=fm.hexfunc(scmutil.binnode(ctx))) | |
|
2542 | ||||
2539 | cols = [ |
|
2543 | cols = [ | |
2540 | ('filename', fn, True), |
|
2544 | ('filename', fn, True), | |
2541 | ('rev', rev, True), |
|
2545 | ('rev', rev, True), | |
@@ -2601,8 +2605,10 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2601 | fnode = ctx.filenode(fn) |
|
2605 | fnode = ctx.filenode(fn) | |
2602 | except error.LookupError: |
|
2606 | except error.LookupError: | |
2603 | continue |
|
2607 | continue | |
2604 |
|
2608 | try: | ||
2605 | copied = flog.renamed(fnode) |
|
2609 | copied = flog.renamed(fnode) | |
|
2610 | except error.WdirUnsupported: | |||
|
2611 | copied = ctx[fn].renamed() | |||
2606 | copy = follow and copied and copied[0] |
|
2612 | copy = follow and copied and copied[0] | |
2607 | if copy: |
|
2613 | if copy: | |
2608 | copies.setdefault(rev, {})[fn] = copy |
|
2614 | copies.setdefault(rev, {})[fn] = copy | |
@@ -2613,7 +2619,11 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
2613 | files.append(fn) |
|
2619 | files.append(fn) | |
2614 |
|
2620 | |||
2615 | if fn not in matches[rev]: |
|
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 | pfn = copy or fn |
|
2628 | pfn = copy or fn | |
2619 | if pfn not in matches[parent]: |
|
2629 | if pfn not in matches[parent]: |
@@ -250,8 +250,11 b' Test wdir' | |||||
250 | $ hg stat |
|
250 | $ hg stat | |
251 | M port2 |
|
251 | M port2 | |
252 | $ hg grep -r 'wdir()' port |
|
252 | $ hg grep -r 'wdir()' port | |
253 | abort: working directory revision cannot be specified |
|
253 | port2:2147483647:export | |
254 | [255] |
|
254 | port2:2147483647:vaportight | |
|
255 | port2:2147483647:import/export | |||
|
256 | port2:2147483647:deport | |||
|
257 | port2:2147483647:wport | |||
255 |
|
258 | |||
256 | $ cd .. |
|
259 | $ cd .. | |
257 | $ hg init t2 |
|
260 | $ hg init t2 | |
@@ -368,3 +371,14 b' revisions printed, just their order.' | |||||
368 | binfile.bin:0:+: Binary file matches |
|
371 | binfile.bin:0:+: Binary file matches | |
369 |
|
372 | |||
370 | $ cd .. |
|
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