Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 43304:8cb5f96db235
grep: enable all-files by default (BC)
This patch deprecates the `--all-files` flag and make the all-files
behaviour as default.
In test-grep.t, I removed '--all-files' from every command where it was
used, to reflect that all-files behaviour is default and there is no
change even after the removal.
And other changes in test files are because of changed behaviour.
Differential Revision: https://phab.mercurial-scm.org/D7000
.. bc::
`hg grep` now searches working copy file contents by default. We
recognize this is a significant change from past behavior, but
surveys of large bodies of users indicated nobody used (and almost
nobody understood) the previous no-flags behavior of `hg
grep`. The new behavior aligns with the behavior most users
expected (including hg's maintainers), which also happens to be
the behavior of `git grep`. Given that the old behavior was
confusing to the point of being unusable, we were comfortable
changing this behavior.
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Sun, 06 Oct 2019 11:06:10 -0400 |
parents | 8d02e3c86815 |
children | d782cce137fd |
comparison
equal
deleted
inserted
replaced
43303:26caf96a5fa9 | 43304:8cb5f96db235 |
---|---|
3308 ( | 3308 ( |
3309 b'', | 3309 b'', |
3310 b'all-files', | 3310 b'all-files', |
3311 None, | 3311 None, |
3312 _( | 3312 _( |
3313 b'include all files in the changeset while grepping (EXPERIMENTAL)' | 3313 b'include all files in the changeset while grepping (DEPRECATED)' |
3314 ), | 3314 ), |
3315 ), | 3315 ), |
3316 (b'u', b'user', None, _(b'list the author (long with -v)')), | 3316 (b'u', b'user', None, _(b'list the author (long with -v)')), |
3317 (b'd', b'date', None, _(b'list the date (short with -q)')), | 3317 (b'd', b'date', None, _(b'list the date (short with -q)')), |
3318 ] | 3318 ] |
3364 | 3364 |
3365 Returns 0 if a match is found, 1 otherwise. | 3365 Returns 0 if a match is found, 1 otherwise. |
3366 """ | 3366 """ |
3367 opts = pycompat.byteskwargs(opts) | 3367 opts = pycompat.byteskwargs(opts) |
3368 diff = opts.get(b'all') or opts.get(b'diff') | 3368 diff = opts.get(b'all') or opts.get(b'diff') |
3369 all_files = opts.get(b'all_files') | |
3370 if diff and opts.get(b'all_files'): | 3369 if diff and opts.get(b'all_files'): |
3371 raise error.Abort(_(b'--diff and --all-files are mutually exclusive')) | 3370 raise error.Abort(_(b'--diff and --all-files are mutually exclusive')) |
3372 # TODO: remove "not opts.get('rev')" if --all-files -rMULTIREV gets working | 3371 if opts.get(b'all_files') is None and not diff: |
3373 if opts.get(b'all_files') is None and not opts.get(b'rev') and not diff: | 3372 opts[b'all_files'] = True |
3374 # experimental config: commands.grep.all-files | |
3375 opts[b'all_files'] = ui.configbool(b'commands', b'grep.all-files') | |
3376 plaingrep = opts.get(b'all_files') and not opts.get(b'rev') | 3373 plaingrep = opts.get(b'all_files') and not opts.get(b'rev') |
3374 all_files = opts.get(b'all_files') | |
3377 if plaingrep: | 3375 if plaingrep: |
3378 opts[b'rev'] = [b'wdir()'] | 3376 opts[b'rev'] = [b'wdir()'] |
3379 | 3377 |
3380 reflags = re.M | 3378 reflags = re.M |
3381 if opts.get(b'ignore_case'): | 3379 if opts.get(b'ignore_case'): |