Skip to content

Instantly share code, notes, and snippets.

@kanru
Created March 15, 2012 05:47
Show Gist options
  • Save kanru/2042223 to your computer and use it in GitHub Desktop.
Save kanru/2042223 to your computer and use it in GitHub Desktop.
hg grep
# from http://blog.axant.it/archives/283
import itertools, os, os.path
def hgrep(ui, repo, what, **opts):
files = []
status = repo.status(clean=True)
for f in itertools.chain(status[0], status[1], status[4], status[6]):
files.append(os.path.join(repo.root, f))
if files:
os.system("grep %s %s" % (what, ' '.join(files)))
cmdtable = {"hgrep": (hgrep, [], "[what]")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment