Patchwork D3916: grep: reject --diff --all-files

login
register
mail settings
Submitter phabricator
Date July 11, 2018, 6:11 p.m.
Message ID <df18872f51c14e4f69eb820e0aad727c@localhost.localdomain>
Download mbox | patch
Permalink /patch/32788/
State Not Applicable
Headers show

Comments

phabricator - July 11, 2018, 6:11 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0d0f8bd692c4: grep: reject --diff --all-files (authored by yuja, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3916?vs=9533&id=9546

REVISION DETAIL
  https://phab.mercurial-scm.org/D3916

AFFECTED FILES
  mercurial/commands.py
  tests/test-grep.t

CHANGE DETAILS




To: yuja, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

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 @@ 
   $ 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
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2533,6 +2533,9 @@ 
     """
     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