Show More
@@ -1871,6 +1871,10 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
1871 | 1871 | datefunc = ui.quiet and util.shortdate or util.datestr |
|
1872 | 1872 | found = False |
|
1873 | 1873 | filerevmatches = {} |
|
1874 | def binary(): | |
|
1875 | flog = getfile(fn) | |
|
1876 | return util.binary(flog.read(ctx.filenode(fn))) | |
|
1877 | ||
|
1874 | 1878 | if opts.get('all'): |
|
1875 | 1879 | iter = difflinestates(pstates, states) |
|
1876 | 1880 | else: |
@@ -1897,9 +1901,12 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
1897 | 1901 | after = l.line[l.colend:] |
|
1898 | 1902 | ui.write(sep.join(cols)) |
|
1899 | 1903 | if before is not None: |
|
1900 | ui.write(sep + before) | |
|
1901 | ui.write(match, label='grep.match') | |
|
1902 |
|
|
|
1904 | if not opts.get('text') and binary(): | |
|
1905 | ui.write(sep + " Binary file matches") | |
|
1906 | else: | |
|
1907 | ui.write(sep + before) | |
|
1908 | ui.write(match, label='grep.match') | |
|
1909 | ui.write(after) | |
|
1903 | 1910 | ui.write(eol) |
|
1904 | 1911 | found = True |
|
1905 | 1912 | return found |
@@ -4567,6 +4574,7 b' table = {' | |||
|
4567 | 4574 | (grep, |
|
4568 | 4575 | [('0', 'print0', None, _('end fields with NUL')), |
|
4569 | 4576 | ('', 'all', None, _('print all revisions that match')), |
|
4577 | ('a', 'text', None, _('treat all files as text')), | |
|
4570 | 4578 | ('f', 'follow', None, |
|
4571 | 4579 | _('follow changeset history,' |
|
4572 | 4580 | ' or file history across copies and renames')), |
@@ -235,7 +235,7 b' Show all commands + options' | |||
|
235 | 235 | debugsub: rev |
|
236 | 236 | debugwalk: include, exclude |
|
237 | 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 | 239 | heads: rev, topo, active, closed, style, template |
|
240 | 240 | help: |
|
241 | 241 | identify: rev, num, id, branch, tags, bookmarks |
@@ -166,3 +166,11 b' of just using revision numbers.' | |||
|
166 | 166 | $ hg grep --all red |
|
167 | 167 | color:3:-:red |
|
168 | 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