# HG changeset patch # User Yuya Nishihara # Date 2018-07-11 12:23:18 # Node ID 0d0f8bd692c46aa4d1939500f9ec6d6ff886ec1a # Parent ffd08ec229556f82ecb636b746a6d7d2e3f25056 grep: reject --diff --all-files This combination doesn't make any sense since --diff is the flag to search change history, whereas --all-files is to include unmodified contents. Differential Revision: https://phab.mercurial-scm.org/D3916 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2533,6 +2533,9 @@ def grep(ui, repo, pattern, *pats, **opt """ opts = pycompat.byteskwargs(opts) diff = opts.get('all') or opts.get('diff') + if diff and opts.get('all_files'): + raise error.Abort(_('--diff and --all-files are mutually exclusive')) + reflags = re.M if opts.get('ignore_case'): reflags |= re.I diff --git a/tests/test-grep.t b/tests/test-grep.t --- a/tests/test-grep.t +++ b/tests/test-grep.t @@ -412,6 +412,12 @@ Test for showing working of allfiles fla $ hg grep -r "." "unmod" --all-files um:1:unmod +--diff --all-files makes no sense since --diff is the option to grep history + + $ hg grep --diff --all-files um + abort: --diff and --all-files are mutually exclusive + [255] + $ cd .. Fix_Wdir(): test that passing wdir() t -r flag does greps on the