Overview

Grepfile extension for Mercurial

Installing

Clone the repository:

hg clone http://bitbucket.org/troter/hg-grepfile/

Edit the [extensions] section in your ~/.hgrc file:

[extensions]
grepfile = [path to]/hg-grepfile/grepfile.py

Usage

This extension adds a new command grepfile that search files for a regular expression.

Example:

hg grepfile -i -n ctx.walk

Similar commands and difference

hg grepfile regexp (this extension)

  • search files. not history.
  • behave linke git grep.
  • can search uncommitted changes.
  • can search other revision's file.

hg grep regexp

  • search history. not files.
  • behave like git log -S.
  • cannot search uncommitted changes. because, uncommitted changes are not history.

hg locate 'set:grep(regexp)'

  • faster than hg grepfile.
  • can search uncommitted changes.
  • can search other revision's file.
  • cannot display matched line, filename only.

hg locate | xargs grep regexp

  • require xargs command and grep command.
  • search features are more powerful, because grep command has many options.
  • cannot search other revision's files. current revision's files only.
  • slower than hg grepfile.