This is an archive of the discontinued Mercurial Phabricator instance.

grep: enable all-files by default (BC)
ClosedPublic

Authored by khanchi97 on Oct 6 2019, 12:14 PM.

Details

Summary

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.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

khanchi97 created this revision.Oct 6 2019, 12:14 PM
JordiGH added a subscriber: JordiGH.Oct 8 2019, 1:58 PM

The docstring needs an update too.

mercurial/commands.py
2742

No longer by default! Or perhaps at all.

The docstring needs a significant update too. Would you like me to suggest something?

Sure :)

How about something like this?

# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1571411921 14400
#      Fri Oct 18 11:18:41 2019 -0400
# Node ID 86cafc9dec2660561f65ec17d043f3117767a9a8
# Parent  8c0fe77f47c5956681238b79dc15093c92e79395
grep: update docs to reflect new --all-files default

These docs no longer even mention the old weird behaviour that was
poorly understood and underutilised. I think this undocumentation
effectively deprecates it.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3276,7 +3276,7 @@ statemod.addunfinished(
             b'diff',
             None,
             _(
-                b'print all revisions when the term was introduced '
+                b'search commit differences for when the term was added '
                 b'or removed'
             ),
         ),
@@ -3302,7 +3302,7 @@ statemod.addunfinished(
             b'r',
             b'rev',
             [],
-            _(b'only search files changed within revision range'),
+            _(b'search files changed within revision range'),
             _(b'REV'),
         ),
         (
@@ -3324,16 +3324,19 @@ statemod.addunfinished(
     intents={INTENT_READONLY},
 )
 def grep(ui, repo, pattern, *pats, **opts):
-    """search revision history for a pattern in specified files
-
-    Search revision history for a regular expression in the specified
-    files or the entire project.
-
-    By default, grep prints the most recent revision number for each
-    file in which it finds a match. To get it to print every revision
-    that contains a change in match status ("-" for a match that becomes
-    a non-match, or "+" for a non-match that becomes a match), use the
-    --diff flag.
+    """search for a pattern in specified files
+
+    Search the working directory or revision history for a regular
+    expression in the specified files or the entire project.
+
+    By default, grep searches the repository files in the working
+    directory and prints the files where it finds a match. To specify
+    historical revisions instead of the working directory, use the
+    --rev flag.
+
+    To search instead historical revision differences that contains a
+    change in match status ("-" for a match that becomes a non-match,
+    or "+" for a non-match that becomes a match), use the --diff flag.
 
     PATTERN can be any Python (roughly Perl-compatible) regular
     expression.
JordiGH added a comment.EditedOct 18 2019, 11:40 AM

Wait, I found some problems, here is an amendment:

# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1571411921 14400
#      Fri Oct 18 11:18:41 2019 -0400
# Node ID 60eb1feadbeebd2ddab16e0d1b4566dbf216333c
# Parent  8c0fe77f47c5956681238b79dc15093c92e79395
grep: update docs to reflect new --all-files default

These docs no longer even mention the old weird behaviour that was
poorly understood and underutilised. I think this undocumentation
effectively deprecates it.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3276,7 +3276,7 @@ statemod.addunfinished(
             b'diff',
             None,
             _(
-                b'print all revisions when the term was introduced '
+                b'search revision differences for when the pattern was added '
                 b'or removed'
             ),
         ),
@@ -3302,7 +3302,7 @@ statemod.addunfinished(
             b'r',
             b'rev',
             [],
-            _(b'only search files changed within revision range'),
+            _(b'search files changed within revision range'),
             _(b'REV'),
         ),
         (
@@ -3324,23 +3324,27 @@ statemod.addunfinished(
     intents={INTENT_READONLY},
 )
 def grep(ui, repo, pattern, *pats, **opts):
-    """search revision history for a pattern in specified files
-
-    Search revision history for a regular expression in the specified
-    files or the entire project.
-
-    By default, grep prints the most recent revision number for each
-    file in which it finds a match. To get it to print every revision
-    that contains a change in match status ("-" for a match that becomes
-    a non-match, or "+" for a non-match that becomes a match), use the
-    --diff flag.
+    """search for a pattern in specified files
+
+    Search the working directory or revision history for a regular
+    expression in the specified files for the entire repository.
+
+    By default, grep searches the repository files in the working
+    directory and prints the files where it finds a match. To specify
+    historical revisions instead of the working directory, use the
+    --rev flag.
+
+    To search instead historical revision differences that contains a
+    change in match status ("-" for a match that becomes a non-match,
+    or "+" for a non-match that becomes a match), use the --diff flag.
 
     PATTERN can be any Python (roughly Perl-compatible) regular
     expression.
 
-    If no FILEs are specified (and -f/--follow isn't set), all files in
-    the repository are searched, including those that don't exist in the
-    current branch or have been deleted in a prior changeset.
+    If no FILEs are specified and the --rev flag isn't supplied, all
+    files in the working directory are searched. When using the --rev
+    flag and specifying FILEs, use the --follow argument to also
+    follow the specified FILEs across renames and copies.
 
     .. container:: verbose
 
@@ -3363,6 +3367,7 @@ def grep(ui, repo, pattern, *pats, **opt
       See :hg:`help templates.operators` for the list expansion syntax.
 
     Returns 0 if a match is found, 1 otherwise.
+
     """
     opts = pycompat.byteskwargs(opts)
     diff = opts.get(b'all') or opts.get(b'diff')
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.