Patchwork [stable] grep: rewrite help to better document current (confusing) behavior

login
register
mail settings
Submitter Kevin Bullock
Date Sept. 23, 2016, 5:46 p.m.
Message ID <081544f94cd76301a5d6.1474652761@billings.local>
Download mbox | patch
Permalink /patch/16772/
State Accepted
Headers show

Comments

Kevin Bullock - Sept. 23, 2016, 5:46 p.m.
# HG changeset patch
# User Kevin Bullock <kbullock+mercurial@ringworld.org>
# Date 1474652710 18000
#      Fri Sep 23 12:45:10 2016 -0500
# Branch stable
# Node ID 081544f94cd76301a5d678b96f57baa2a1544df1
# Parent  e7766022a61a66a7c4218526b647f96bd442a4ce
grep: rewrite help to better document current (confusing) behavior
Augie Fackler - Sept. 23, 2016, 6:21 p.m.
On Fri, Sep 23, 2016 at 12:46:01PM -0500, Kevin Bullock wrote:
> # HG changeset patch
> # User Kevin Bullock <kbullock+mercurial@ringworld.org>
> # Date 1474652710 18000
> #      Fri Sep 23 12:45:10 2016 -0500
> # Branch stable
> # Node ID 081544f94cd76301a5d678b96f57baa2a1544df1
> # Parent  e7766022a61a66a7c4218526b647f96bd442a4ce
> grep: rewrite help to better document current (confusing) behavior

Queued per both my review and Jordi's review on IRC. Thanks.

>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4288,20 +4288,23 @@ def _dograft(ui, repo, *revs, **opts):
>      _('[OPTION]... PATTERN [FILE]...'),
>      inferrepo=True)
>  def grep(ui, repo, pattern, *pats, **opts):
> -    """search for a pattern in specified files and revisions
> -
> -    Search revisions of files for a regular expression.
> -
> -    This command behaves differently than Unix grep. It only accepts
> -    Python/Perl regexps. It searches repository history, not the
> -    working directory. It always prints the revision number in which a
> -    match appears.
> -
> -    By default, grep only prints output for the first revision of a
> +    """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 --all flag.
> +    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
> +    --all 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.
>
>      Returns 0 if a match is found, 1 otherwise.
>      """
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4288,20 +4288,23 @@  def _dograft(ui, repo, *revs, **opts):
     _('[OPTION]... PATTERN [FILE]...'),
     inferrepo=True)
 def grep(ui, repo, pattern, *pats, **opts):
-    """search for a pattern in specified files and revisions
-
-    Search revisions of files for a regular expression.
-
-    This command behaves differently than Unix grep. It only accepts
-    Python/Perl regexps. It searches repository history, not the
-    working directory. It always prints the revision number in which a
-    match appears.
-
-    By default, grep only prints output for the first revision of a
+    """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 --all flag.
+    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
+    --all 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.
 
     Returns 0 if a match is found, 1 otherwise.
     """