Show More
@@ -1871,6 +1871,10 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
1871 | datefunc = ui.quiet and util.shortdate or util.datestr |
|
1871 | datefunc = ui.quiet and util.shortdate or util.datestr | |
1872 | found = False |
|
1872 | found = False | |
1873 | filerevmatches = {} |
|
1873 | filerevmatches = {} | |
|
1874 | def binary(): | |||
|
1875 | flog = getfile(fn) | |||
|
1876 | return util.binary(flog.read(ctx.filenode(fn))) | |||
|
1877 | ||||
1874 | if opts.get('all'): |
|
1878 | if opts.get('all'): | |
1875 | iter = difflinestates(pstates, states) |
|
1879 | iter = difflinestates(pstates, states) | |
1876 | else: |
|
1880 | else: | |
@@ -1897,9 +1901,12 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
1897 | after = l.line[l.colend:] |
|
1901 | after = l.line[l.colend:] | |
1898 | ui.write(sep.join(cols)) |
|
1902 | ui.write(sep.join(cols)) | |
1899 | if before is not None: |
|
1903 | if before is not None: | |
1900 | ui.write(sep + before) |
|
1904 | if not opts.get('text') and binary(): | |
1901 | ui.write(match, label='grep.match') |
|
1905 | ui.write(sep + " Binary file matches") | |
1902 |
|
|
1906 | else: | |
|
1907 | ui.write(sep + before) | |||
|
1908 | ui.write(match, label='grep.match') | |||
|
1909 | ui.write(after) | |||
1903 | ui.write(eol) |
|
1910 | ui.write(eol) | |
1904 | found = True |
|
1911 | found = True | |
1905 | return found |
|
1912 | return found | |
@@ -4567,6 +4574,7 b' table = {' | |||||
4567 | (grep, |
|
4574 | (grep, | |
4568 | [('0', 'print0', None, _('end fields with NUL')), |
|
4575 | [('0', 'print0', None, _('end fields with NUL')), | |
4569 | ('', 'all', None, _('print all revisions that match')), |
|
4576 | ('', 'all', None, _('print all revisions that match')), | |
|
4577 | ('a', 'text', None, _('treat all files as text')), | |||
4570 | ('f', 'follow', None, |
|
4578 | ('f', 'follow', None, | |
4571 | _('follow changeset history,' |
|
4579 | _('follow changeset history,' | |
4572 | ' or file history across copies and renames')), |
|
4580 | ' or file history across copies and renames')), |
@@ -235,7 +235,7 b' Show all commands + options' | |||||
235 | debugsub: rev |
|
235 | debugsub: rev | |
236 | debugwalk: include, exclude |
|
236 | debugwalk: include, exclude | |
237 | debugwireargs: three, four, ssh, remotecmd, insecure |
|
237 | debugwireargs: three, four, ssh, remotecmd, insecure | |
238 | grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude |
|
238 | grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude | |
239 | heads: rev, topo, active, closed, style, template |
|
239 | heads: rev, topo, active, closed, style, template | |
240 | help: |
|
240 | help: | |
241 | identify: rev, num, id, branch, tags, bookmarks |
|
241 | identify: rev, num, id, branch, tags, bookmarks |
@@ -166,3 +166,11 b' of just using revision numbers.' | |||||
166 | $ hg grep --all red |
|
166 | $ hg grep --all red | |
167 | color:3:-:red |
|
167 | color:3:-:red | |
168 | color:1:+:red |
|
168 | color:1:+:red | |
|
169 | ||||
|
170 | $ hg init a | |||
|
171 | $ cd a | |||
|
172 | $ cp $TESTDIR/binfile.bin . | |||
|
173 | $ hg add binfile.bin | |||
|
174 | $ hg ci -m 'add binfile.bin' | |||
|
175 | $ hg grep "MaCam" --all | |||
|
176 | binfile.bin:0:+: Binary file matches |
General Comments 0
You need to be logged in to leave comments.
Login now