[PATCH] commands: grep:don't print control sequence for binary file matches(issue2614)

Matt Mackall mpm at selenic.com
Mon Apr 4 09:09:32 CDT 2011


On Mon, 2011-04-04 at 09:22 +0530, Md.O.Shayan wrote:
> # HG changeset patch
> # User Md.O.Shayan<mdoshayan at gmail.com>
> # Date 1301888586 -19800
> # Node ID 82160ae12a3a0755b1d7e5eaea3b28aa507e0504
> # Parent  0995eee8ffe4a24478379fb16fd6c38812bc3dd5
> commands: grep:don't print control sequence for binary file matches(issue2614)

This should be something like:

"grep: don't print data from binary files for matches (issue2614)"

Note the spacing differences.

This is probably a good idea, but it's incomplete without a -a flag to
override the behavior. See 'hg diff'.

> +            if binary:
> +                ui.write(sep+" Binary file")

I can tell you didn't run all the tests. This line will fail check-code.

> +            if fn not in binary:
> +                flog = getfile(fn)
> +                binary[fn] = util.binary(flog.read(ctx.filenode(fn)))

That's expensive. It'd be better to do flog.read() only once. Also, it's
probably incorrect to have a notion of "x is binary if one revision of x
we've looked at is binary". Instead, we should probably check whether a
revision is binary after we've decided to display a line from it.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list