[PATCH] grep: restore usage of --include/--exclude options

Jordi Gutiérrez Hermoso jordigh at octave.org
Sat Feb 3 00:13:31 UTC 2024


# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh at octave.org>
# Date 1706834135 18000
#      Thu Feb 01 19:35:35 2024 -0500
# Node ID e9a040016017d5cd001119c4aff23d4ce343e572
# Parent  99869dcf3ba06679d73db591a87e739d035770be
grep: restore usage of --include/--exclude options

The refactor in 4a73df6eb67d accidentally forgot to transform the opts
argument for walkopts into a byteskwargs. This resulted in its options
being ignored. In particular, the -X/-I pair of options was missing.

A simple fix restores its usage. Tests included, of course.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3680,7 +3680,7 @@ def grep(ui, repo, pattern, *pats, **opt
 
     wopts = logcmdutil.walkopts(
         pats=pats,
-        opts=opts,
+        opts=pycompat.byteskwargs(opts),
         revspec=opts['rev'],
         include_pats=opts['include'],
         exclude_pats=opts['exclude'],
diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -525,6 +525,23 @@ Test wdir
   port2:2147483647:deport
   port2:2147483647:wport
 
+Testing include/exclude
+
+  $ hg cp port tort
+  $ hg grep port -X tort
+  port:export
+  port:vaportight
+  port:import/export
+  port2:export
+  port2:vaportight
+  port2:import/export
+  port2:deport
+  port2:wport
+  $ hg grep port -I tort
+  tort:export
+  tort:vaportight
+  tort:import/export
+
   $ cd ..
   $ hg init t2
   $ cd t2


More information about the Mercurial-devel mailing list