D3763: grep: add `--diff` flag

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Mon Jun 18 16:15:57 EDT 2018


pulkit added inline comments.

INLINE COMMENTS

> commands.py:2419
>      ('', 'all', None, _('print all revisions that match')),
> +    ('', 'diff', None, _('print all revisions that match')),
>      ('a', 'text', None, _('treat all files as text')),

We definitely need better help text here to mention that it looks at the diff not all the content.

> commands.py:2446
>      a non-match, or "+" for a non-match that becomes a match), use the
> -    --all flag.
> +    --diff/--all(DEPRECATED) flag.
>  

To deprecate a flag, we need to add (DEPRECATED) after the help text of the flag. Look for DEPRECATED, EXPERIMENTAL, ADVANCED in commands.py, you will find examples.

Also, I suggest you to make a separate patch for deprecating the flag.

> commands.py:2554
>          fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'}
> -        if opts.get('all'):
> +        if opts.get('all') or opts.get('diff'):
>              iter = difflinestates(pstates, states)

nit: it will be better if we can initialize a variable and store `opts.get('all') and opts.get('diff')` in it and reuse that.

REPOSITORY
  rHG Mercurial

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

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


More information about the Mercurial-devel mailing list