Wilka
Wilka

Reputation: 29583

Search for "TODO" only in files which changed in specific mercurial changeset(s)?

I'm working in a code base that already has a lot of "TODO" comments, and before I push my changeset(s) I want to make sure I haven't left any of my TODO comments in there (rather than actually doing it, or adding it to the new-feature database and removing the comment).

At the moment I'm just using "TODO: Wilka" in each of the comments, so it's easy to search for. But is there a way with Mercurial I can search for "TODO" only in the files that have changed in a collection of changesets? Ideally, it would only search the lines that have actually changed - but even just the files would be good.

Upvotes: 3

Views: 162

Answers (3)

msw
msw

Reputation: 43487

The automated way is via Mercurial commit hooks. The examples may be helpful as might the checkfiles extension referred to by mercurial developers.

In my experience, commit hooks are a mixed bag and often do what you want but are irksome when you really want to commit a TODO. The Shelve extension attempts to work around this, but the cure can be worse than the problem.

I haven't explored the possibility of something like hg com --but-ignore-my-TODO-hook which could be nifty.

Upvotes: 0

bbaja42
bbaja42

Reputation: 2169

Diff between wanted revisions piped to the grep, only modified files file be searched with the grep

hg diff -r 100:105 | grep TODO

EDIT: As mentioned in the comments, this is presumes that grep is installed (so non Windows enviroment)
@thanks Tim, if using Windoes, use findstr instead of the grep

Upvotes: 0

Leom Burke
Leom Burke

Reputation: 8271

to search a specific set of revisions you could do:

hg grep -r 0:3 "\bTODO:"

Upvotes: 1

Related Questions