开发者

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

开发者 https://www.devze.com 2023-03-17 22:35 出处:网络
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 do

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 li开发者_如何学Pythonnes that have actually changed - but even just the files would be good.


to search a specific set of revisions you could do:

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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消