Patchwork D3826: grep : change default behaviour of grep

login
register
mail settings
Submitter phabricator
Date June 21, 2018, 6:42 p.m.
Message ID <differential-rev-PHID-DREV-uaxamlmzmz2yxw3fd64k-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32366/
State Superseded
Headers show

Comments

phabricator - June 21, 2018, 6:42 p.m.
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




To: sangeet259, #hg-reviewers
Cc: mercurial-devel
phabricator - June 21, 2018, 6:49 p.m.
sangeet259 added a comment.


  I need some help with the tests failing here.

REPOSITORY
  rHG Mercurial

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

To: sangeet259, #hg-reviewers
Cc: mercurial-devel
phabricator - July 9, 2018, 8:53 p.m.
durin42 requested changes to this revision.
durin42 added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> commands.py:2518
>  
>      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

I think you need to update this line in the help? That is, by default we now search the working directory, and you have to say something else to search history.

REPOSITORY
  rHG Mercurial

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

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

Patch

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