D3826: grep : change default behaviour of grep

sangeet259 (Sangeet Kumar Mishra) phabricator at mercurial-scm.org
Thu Jun 21 18:42:53 UTC 2018


sangeet259 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  with this patch grep searches on the working directory by default
  and looks for all files tracked by the working directory and greps on them

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2399,7 +2399,7 @@
     ('l', 'files-with-matches', None,
      _('print only filenames and revisions that match')),
     ('n', 'line-number', None, _('print matching line numbers')),
-    ('r', 'rev', [],
+    ('r', 'rev', ["wdir()"],
      _('only search files changed within revision range'), _('REV')),
     ('', 'allfiles', False,
      _('include all files in the changeset while grepping (EXPERIMENTAL)')),
@@ -2431,6 +2431,10 @@
     Returns 0 if a match is found, 1 otherwise.
     """
     opts = pycompat.byteskwargs(opts)
+
+    if len(opts.get('rev')) ==1:
+        opts['allfiles'] = True
+
     reflags = re.M
     if opts.get('ignore_case'):
         reflags |= re.I



To: sangeet259, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list